-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi,
I am trying to swap video streams in the middle of the call, because I need to change resolution dynamically. I found out, that probably only working solution is to remove old Stream from LocalPeer, add new Stream and then renegotiate with all RemotePeers.
Problem is, if I renegotiate only once after I removed old Stream and replaced it with new one, nothing happens.. RemotePeer thinks it is still the same Stream (with same stream.stream.id).
If I renegotiate twice: first time after removing old Stream and second time after adding new one, it could solve the problem, but another problem appears at the side of the peer which changed the stream.
After recieving an answer from first renegotiation:
Uncaught (in promise) DOMException: Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Failed to set local offer sdp: The m= section with mid='1' should be rejected. from peer_connection.ts:342
After receiving an answer from second renegotiation:
Uncaught (in promise) DOMException: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Session error code: ERROR_CONTENT. Session error description: The m= section with mid='1' should be rejected.. from peer_connection.ts:293
It seems like a bug to me, or am I misunderstanding something?
This is problematic part of code:
updateVideo(isHd) {
let options = isHd ? this.hdVideoOptions() : this.basicVideoOptions();
this.model.room.local.stream().then(s => {
s.stop();
});
this.model.room.local.removeStream();
this.renegotiateAllPeers(); // Renegotiation #1
this.model.room.local.addStream(options)
.then(newStream => {
this.localStream = newStream;
this.displayStream(this.localStream, $('#myVideo'));
this.renegotiateAllPeers(); // Renegotiation #2
})
.catch((err) => console.error(err.message));
}
renegotiateAllPeers() {
for (let peer of this.peers) {
peer.negotiate();
}
}