I need to manipulate the SDP of an answer to an Invite request before it is sent out. Specifically, I want to disable the video stream in the answer SDP by setting the port in the "m=video" line to 0, in accordance with RFC 3264, section 6.
I know that there is the RTCSession "sdp" event for that purpose. However, there is a problem with the way this is currently implemented in JsSIP. The problem lies in the sequence of operations in RTCSession._createLocalDescription(). Currently it is like this:
1. RTCPeerConnection.createAnswer() is invoked to create the SDP answer
2. That SDP answer is handed over to WebRTC via RTCPeerConnection.setLocalDescription()
3. Only once the ICE gathering is complete the "sdp" event is emitted and the app can manipulate the SDP, before it is sent out via SIP
The problem with that approach is that WebRTC is not aware of any of the SDP manipulations the app might have done in its "sdp" event handler, because setLocalDescription() has already been invoked before, with the original SDP.
In our case, when we disable the video stream by setting the port to 0 in the m=video line in our "sdp" event handler, WebRTC doesn't know anything about that change and therefore throws errors during the ICE connectivity check phase of the video ICE candidates, since the other end thinks the video media is disabled and does not participate in the connectivity check (it received the manipulated SDP via SIP).
In short: we need a way to have JsSIP use our manipulated SDP when invoking RTCPeerConnection.setLocalDescription(). Is there a way to achieve that which I am not aware of?