Reputation: 629
I have two webcams that I would like to share, but I do not want to have to negotiate two sets of the signaling process (SDP, ICE, all that jazz). Is there any way for me to combine these two stream into one before it goes to another user, or I am stuck with making double negotiations for any other stream device I would like to add. Also I am working with chrome if that is important.
Upvotes: 4
Views: 4777
Reputation: 36590
There is a new way to achieve this. Take a look at replaceTrack
This is something new and the most magic of this is: it does not require renegotiation, it just replace the track directly either video or audio:
// addTrack to remote peer, track does not have to be within stream1/2, but remote will receive that
rtpSender = RTCPeerConnection.addTrack(track, stream1, stream2);
// use the rtpSender to replace remote track
rtpSender.repalceTrack(track);
Upvotes: 1
Reputation: 783
As suggested in others answers, webRTC allow to send more than one track in the PeerConnection (which is the "channel" to establish the connection). It is common to add more than one stream, for instance, a screensharing and the webCam.
So, you don't need to combine the streams, and they will be received separately by the other peer. This way, the receiver application has the freedom to show them as it needs.
Regarding the SDP issues, you can take a look at https://webrtchacks.com/sdp-anatomy/, a graphical explanation of each field in the SDP, very useful for troubleshooting.
Upvotes: 1
Reputation: 17330
you can add multiple streams to the peerconnection, just call pc.addStream with each stream.
Note that the way this is currently signaled in SDP is not compatible between Chrome and Firefox.
Upvotes: 4