I created a video-call + multiple screen sharing app that works well in every case except one.
The main flow is:
- A user (P1) join an empty room, nothing happens
- A second user (P2) join the room. P1 sends an offer to P2 which sends a response to P1.
- Other users (PN) join the room. Every user already in the room send offers to the PN user. PN user send answers for every offer.
- During the main app flow, every user can share their screen (multiple times). When this happens, the user send an offer to every already-connected peers and receive answers from them.
The webcam flow always works well, while the screen sharing breaks in a specific case:
- P1 Is a Chrome user that joins the Room. Nothing happens.
- P2 Is a Firefox user that joins the Room. P1 (Chrome) sends his offer to P2 Webcam connection works well as usual.
- P2 (Firefox) share a screen. The Offer throws an error:
Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Failed to parse SessionDescription. a=rtpmap:127 H264/90000 Duplicate payload type with conflicting codec name or clock rate
Looking at the offer's SDP, i see that the payload for the line a=rtpmap:127
is duplicated:
a=rtpmap:127 H264/90000
...
a=rtpmap:127 rtx/90000
This error happens ONLY in the specified flow (Chrome sends an offer first, Firefox answers (and camera works well), Firefox share a screen and i get the SDP error). If the first offer is sent by a Firefox user, everything works well. If the first offer is sent by a Chrome, everything works well if the first screen sharing is started by a Chrome user.
If the first offer is sent by a Chrome user and then a Firefox user shares a screen, it breaks. Only in this case.
So, the problem is that the offer created by the Firefox user during the first screen sharing contains that payload conflict.
Why does it happen (only in that case) and how can i prevent this error?