问题描述
简而言之:我试图更改 MediaStream
对象的 VideoTrack
。
(文档:,并且MediaStream也存在两个。
您应该将单独的媒体流添加到对等连接,以便它可以触发重新协商并处理流。 Chrome中的轨道添加/删除功能非常幼稚,并非非常细小,您应该尽可能远离它。
In a Nutshell: I'm trying to change the VideoTrack
of a MediaStream
object.
(Documentation: https://developer.mozilla.org/en-US/docs/WebRTC/MediaStream_API)
I have a MediaStream object __o_jsep_stream_audiovideo
which is created by the sipml library.
__o_jsep_stream_audiovideo
looks like this:
So it has one AudioTrack and one VideoTrack. At first the VideoTrack comes from the users camera (e.g label: "FaceTime Camera"
).
According to the Documentation:
So we should be fine adding more Tracks to this Stream.
I'm trying to switch/exchange the VideoTrack with that from another stream. The other stream (streamB
) originates from Chromes ScreenCapture api (label: "Screen"
)
I tried:
__o_jsep_stream_audiovideo.addTrack(streamB.getVideoTracks()[0])
which doesn't seem to have any effect.
I also tried assigning the videoTracks directly (which was desperate I know).
I must be missing something obvious could you point me in the right direction?
I'm running
- Chrome (Version 34.0.1847.131) and
- Canary (Version 36.0.1976.2 canary)
- OSX 10.9.2
Adding and removing tracks on a MediaStream object do not signal a renegotiation and there are also issues with a MediaStream having two tracks of the same type in chrome.
You should probably just add the separate mediastream to the peer connection so that it can fire a re-negotiation and handle the streams. The Track add/remove functionality in chrome is very naive and not very granular and you should move away from it as much as you can.
这篇关于更改MediaStream对象的VideoTrack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!