sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.39k stars 424 forks source link

SDPAudioVideoMediaFormat WithUpdated methods should use current object not a format parameter #1131

Closed SteveAyre closed 2 weeks ago

SteveAyre commented 1 month ago

SDPAudioVideoMediaFormat has 3 WithUpdated methods:

        public SDPAudioVideoMediaFormat WithUpdatedID(int id, SDPAudioVideoMediaFormat format)
        public SDPAudioVideoMediaFormat WithUpdatedRtpmap(string rtpmap, SDPAudioVideoMediaFormat format)
        public SDPAudioVideoMediaFormat WithUpdatedFmtp(string fmtp, SDPAudioVideoMediaFormat format)

This format parameter would suggest these are static methods, but they are object methods. As such it would make more sense to copy the this object.

This is the approach already used on SDPApplicationMediaFormat:

        public SDPApplicationMediaFormat WithUpdatedID(string id)
        public SDPApplicationMediaFormat WithUpdatedRtpmap(string rtpmap)
        public SDPApplicationMediaFormat WithUpdatedFmtp(string fmtp)

It would make sense to use this interface on both for consistency.