My goal is to enable screen sharing in the middle of a video or audio call using webrtc web application .
Well I found that I can use MediaStreamTrack.applyConstraints()
to change video property but is it possible to change the video source ? further more how can I add video to an existing audio stream .
I need this to work on chrome only for now .
localStream.stop();
peerconnection.removeStream(localStream);
I was able to find the solution by following steps
remove the current stream
add new stream
create new offer
Note that removeStream
is deprecated and no longer in the spec, and not implemented in all browsers. E.g. this won't work in Firefox. stream.stop()
is also deprecated in favor of stream.getTracks().forEach(track => track.stop())