Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC - how to differentiate between two MediaStreamTracks sent over the same connection?

I want to send two video streams from Peer1 to Peer2 using WebRTC: let's use front and rear camera as an example.

Conceptually, how does Peer2 know which stream comes from which camera?

MediaStream documentation mentions that all MediaStream and MediaStreamTrack fields are read-only, so I can't attach any information directly to them. I cannot send a dictionary like {"stream1 id": "camera", "stream2 id": "screenshare"} over a signalling channel, because Peer2 will generate its own id for each stream and track.

like image 387
Adam Zielinski Avatar asked Jan 04 '16 16:01

Adam Zielinski


1 Answers

https://datatracker.ietf.org/doc/html/draft-ietf-mmusic-msid-11

In the RTP specification, media streams are identified using the SSRC
field.  Streams are grouped into RTP Sessions, and also carry a
CNAME.  Neither CNAME nor RTP session correspond to a MediaStream.
Therefore, the association of an RTP media stream to MediaStreams
need to be explicitly signaled.

WebRTC defines a mapping (documented in [I-D.ietf-rtcweb-jsep]) where
one SDP media description is used to describe each MediaStreamTrack,
and the BUNDLE mechanism [I-D.ietf-mmusic-sdp-bundle-negotiation] is
used to group MediaStreamTracks into RTP sessions.  Therefore, the
need is to specify the ID of a MediaStreamTrack and its associated
MediaStream for each media description, which can be accomplished
with a media-level SDP attribute.

This document defines a new SDP [RFC4566] media-level "msid"
attribute.  This new attribute allows endpoints to associate RTP
media streams that are described in different media descriptions with
the same MediaStreams as defined in [W3C.WD-webrtc-20150210]., and to
carry an identifier for each MediaStreamTrack in its "appdata" field.

So it seems that this cannot be done until custom msid is supported by browsers.

like image 184
Adam Zielinski Avatar answered Nov 14 '22 17:11

Adam Zielinski