Changing the VideoTrack of a MediaStream object

205 views
Skip to first unread message

wpp

unread,
May 6, 2014, 10:44:31 AM5/6/14
to discuss...@googlegroups.com
I'm basically trying to change the VideoTrack of a MediaStream object.

I have a MediaStream object `__o_jsep_stream_audiovideo` which is created by [the sipml library](https://code.google.com/p/sipml5/).

It has *one* AudioTrack and *one* VideoTrack.
At first the VideoTrack comes from the users camera (e.g `label: "FaceTime Camera"`).
Now 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 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

Note I also asked this question on stackoverflow (better formatting):

Vikas

unread,
May 6, 2014, 6:20:56 PM5/6/14
to discuss...@googlegroups.com
Hi,

Did you try use the removeTrack() method to remove the track first and then do addTrack()? Also I think you would need to renegotiate as well.

/Vikas

Mamadou

unread,
May 7, 2014, 12:57:14 AM5/7/14
to discuss...@googlegroups.com
This static variable was used as a workaround to cache the stream when the site is not using "https" scheme (to avoid asking permission to access audio/video device for each call). You must not try to use it and it'll be removed in the next versions. The MediaStream object you've to change is "o_local_stream" from "tmedia_session_jsep" prototype. This is a member reference and each session has it's own MediaStream object.

wpp

unread,
May 7, 2014, 3:57:58 AM5/7/14
to discuss...@googlegroups.com
@Vikas yes I was able to change the videoTrack, it seems like the addtrack and removetrack events (https://developer.mozilla.org/en-US/docs/WebRTC/MediaStream_API) fired and needed to be handled.

@Mamadou Thank you for that insight (and all of your hard word on sipml and the forums! <3)
I will keep in mind that "__o_jsep_stream_audiovideo" will be removed in the future.

It was suggested to me that the "add/removeTrack" implementations are still very fragile and I should try to
"add the separate mediastream to the peer connection so that it can fire a re-negotiation and handle the streams"
(because the "add/removeTrack" do not fire a negotiationneeded event - https://code.google.com/p/webrtc/issues/detail?id=1565).
Can you tell me how I could manually re-negotitate the peer?

Thanks for your help!
Reply all
Reply to author
Forward
0 new messages