我想使用WebRTC将两个视频流从Peer1发送到Peer2:让我们使用前后摄像头作为示例。
从概念上讲,Peer2如何知道哪个流来自哪个摄像头?
MediaStream documentation提到所有MediaStream
和MediaStreamTrack
字段都是只读字段,因此我无法将任何信息直接附加到它们。我不能通过信令通道发送像{"stream1 id": "camera", "stream2 id": "screenshare"}
这样的字典,因为Peer2会为每个流和轨道生成自己的id。
答案 0 :(得分:0)
https://tools.ietf.org/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.
因此,在浏览器支持自定义msid
之前,似乎无法做到这一点。