Ok, the idea is to create an utilitiy to allow doing plan B SDP O/A on unified plan peerconnections.
The idea is similar to https://github.com/jitsi/sdp-interop and we will borrow several ideas from them.
We assume that bundling and rtcp-mux is used always.
#CASE A: unified calls plan B
In this case browser creates an SDP with one m-line per track. We are going to take that SDP, and create one unified local offer to be used in the PC setLocalDescription and one plan-B offer to send to the remote peer.
To create the unified local offer, we will rename each m-line mid so they are unique and make them sendonly.
To create the plan-B offer we will merge all the audio m-lines and all the video m-lines into one of each, and add the ssrc and msids accordingly.
When we recive the plan B answer, we will have to create a unified plan SDP in order to pass it to the PC setRemoteDescription.
For each m-line in the unified original offer, we will create an m-line recvonly with same msid as the original one, filtering out the codecs/extensions not offered. We will pass this answer to the PC setRemoteDescription as "answer"
Then, for each stream on the plan B answer, we will create an m-line with send only (renaming the misd) and we will call setRemoteDescription as "offer". We will create a local description, and put it as is.
#CASE B: plan B calls unified
We will get the plan B offer, and create an unified plan SDP to be set on the PC.
For each stream track present on the offer, we will create a send-only m-line copy copying all the m-line data and renaming the m-line. We will get all the local media streams, and for each track create a recvonly m-line.
Once done we will set that SDP to the PC in setRemoteDescription
After calling the createAnswer we will get the unified plan SDP, we will merge all the audio m-lines and all the video m-lines into one of each, and add the ssrc and msids accordingly.
The unified plan SDP will be passed to the PC setLocalDescription as is.
#CASE C: Renegotiation
TBD
TBD