sipsorcery icon indicating copy to clipboard operation
sipsorcery copied to clipboard

Select an exact VideoFormat/AudioFormat during Webrtc SDP

Open mikhaylo1 opened this issue 3 years ago • 1 comments

I would like to use an exact VideoFormat (i.e Name H264, FormatID 125, Codec H264, ClockRate 90000, Parameters level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f ) during SDP negotiation.

For this I am adding a Local VideoTrack

var videoTrack = new MediaStreamTrack(videoFormat, MediaStreamStatusEnum.RecvOnly);
peerConnection.addTrack(videoTrack);

Once I receive an offer from other party I do this:

peerConnection.setRemoteDescription(message);

For a some reason the Capabilities of my peerConnection.VideoLocalTrack changes after setRemoteDescription and do not contain only the single VideoFormat which I specified on the beginning, but all the H264 video formats received from other peer (including the one I specified initially)

than, after doing peerConnection.createAnswer(); the code includes all the extra VideoFormats into the SDP and let's the other party choose whatever format it wants, not the one I specified in VideoLocalTrack

Probably it happens because of this https://github.com/sipsorcery-org/sipsorcery/blob/fc8555d30e48c56e0e697fcaee88ddcfbb17a79d/src/net/RTP/RTPSession.cs#L772

Please advise how can I restrict the format to the particular one (sdp offer is generated by other party, I want to select one of the supported formats from the sdp offer and use exactly that format) ?

mikhaylo1 avatar Jan 26 '22 00:01 mikhaylo1

This is the reason for the behaviour you've observed.

Please advise how can I restrict the format to the particular one (sdp offer is generated by other party, I want to select one of the supported formats from the sdp offer and use exactly that format) ?

It's not currently possible. It will require an enhancement to the code in the location linked to above. PR's welceom :).

sipsorcery avatar Jan 26 '22 19:01 sipsorcery