I'm writing a simple streaming service.
A browser An open a web socket to a server, then another browser B open a new socket to the same server.
Browser A register a video by its camera (MediaRecorder API) and send it to the server.
The server broadcast this video to others connected browsers.
I have a working version with Socket.IO, but I'd like to do it in vanilla JavaScript (WebSocket.Server on Node.js server and webSocket on client).
This is the problem:
With socket.io a can write something like this:
this.socket.emit('broadcast', {
stream: new Blob(stream, {'type': `video/webm${MEDIA_CHARSET}`}),
from: {id: this.socket.id}
});
Stream comes from mediarecorder -> dataavailable event listener
But with native websocket I can't send blob embed in a JSON object, because websocket can send only string or arraybuffer.
I tried many different ways in order to send JSON and blob together, but nothing works.
Any help?
Is it possible to use only Engine.IO on client side in order to pack a message with blob and JSON together? Any ideas about this way?