We are using wowza webrtc and able to implement it in live.
But on wowza server, seperate streams are getting recorded for every user. As per documentation, compositing on wowza server is not supported. we have to merge streams at client side and republish it.
we compositing all streams via the canvas element and able to add all video track to canvas stream whenever new user joins .
But there is issue, when trying to add new audio track to existing peer connection that is when new user joins video chat its audio track should get added at correct time .
we are trying below methods:
1.When we want to add new audio track to our existing canvas stream peer connection, we are using below code.
peerConnections[localUser].addTrack(new_stream.getAudioTracks()[0],canvas_stream);
peerConnections[localUser].addEventListener(“negotiationneeded”, ev => {
peerConnections[localUser].createOffer(gotLocalDescription, errorHandler);
}, false);
But in gotLocalDescription function, below code is written to send offer-
wsConnection.send(’{“direction”:“publish”, “command”:“sendOffer”, “streamInfo”:’ + JSON.stringify(streamInfo) + ‘, “sdp”:’ + JSON.stringify(description) + ‘, “userData”:’ + JSON.stringify({}) + ‘}’);
But it is giving error that stream name is already in use.
- So tried another method.
When we want to add new audio track to our existing canvas stream peer connection, we closed existing peer connection and created new one. added audio track to canvas_stream and sending new composite stream to peer connection. But in this method, we are facing audio-video sync that is audio got attached from start and not in the middle in recorded video file.
Does anyone know how to solve this problem?