WebRtc audio with webrtc-stream-manager v2
AnsweredHello,
I'm trying to get audio on a camera using the webrtc-stream-manager-v2 but my stream has only one track and it's a video only.
On track event, I checked the track but it's only video, the streams var contains only one stream with one video track.
I succeeded getting deeper recreating a stream with all available tracks using the RTCPeerConnection but these are private members:
const stream = new MediaStream();
((cameraStream.connection as any).basePc.pc as RTCPeerConnection).getReceivers().forEach(r => {
if (r.track) {
stream.addTrack(r.track);
}
});
In my example there were 2 receivers with a track each (1 for audio and 1 for video).
Is there a better way to have a stream with all the track combined and not only the video one?
Regards,
Jean-Baptiste
-
Hi
Thanks for your question. Two separate things here.
At the SDP level it isn't a library choice. The library is the answerer, not the offerer. The Nx server sends the offer and
peer-connection.jsdoessetRemoteDescriptionthencreateAnswer. Under unified-plan, audio and video are separatem-lines, so ontrack fires once per track. Any WebRTC receiver gets two tracks by-design.At the library level the split is deliberate and video-only.
CameraConnectionignores the server's stream grouping and builds its ownmanagedStream, then emits streams: [this.managedStream] instead of event.streams.Reason: it keeps two live peer connections (low-res base, high-res upgrade) and
swaps the video track in placeso srcObject identity never changes and you don't get a black flash on quality switches. That swap is inherently per-track. The MSE path forces it too, since video there comes from MseRenderer'scaptureStream(), not from the RTP track.If you need the audio track,
PeerConnectionWrapperre-emitsevent.streamsuntouched one layer down.So, in fact, you have done the proper implementation.
Thanks for your questions and understanding.0
Please sign in to leave a comment.
Comments
1 comment