diff --git a/include/rtc/description.hpp b/include/rtc/description.hpp index f6bc186..2a53784 100644 --- a/include/rtc/description.hpp +++ b/include/rtc/description.hpp @@ -190,17 +190,21 @@ public: public: Audio(string mid = "audio", Direction dir = Direction::SendOnly); - void addAudioCodec(int payloadType, const string &codec); + void addAudioCodec(int payloadType, const string &codec, const std::optional& profile= + "minptime=10; maxaveragebitrate=96000; stereo=1; sprop-stereo=1; useinbandfec=1"); void addOpusCodec(int payloadType); - - void addRTXCodec(unsigned int payloadType, unsigned int originalPayloadType, unsigned int clockRate); }; class RTC_CPP_EXPORT Video : public Media { public: Video(string mid = "video", Direction dir = Direction::SendOnly); - void addVideoCodec(int payloadType, const string &codec); + // Use Constrained Baseline profile Level 4.2 (necessary for Firefox) + // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#Supported_video_codecs + // TODO: Should be 42E0 but 42C0 appears to be more compatible. Investigate this. + void addVideoCodec(int payloadType, const string &codec, const std::optional& + profile="profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1"); + void addH264Codec(int payloadType); void addVP8Codec(int payloadType); void addVP9Codec(int payloadType); diff --git a/src/description.cpp b/src/description.cpp index a3c0f10..84dc404 100644 --- a/src/description.cpp +++ b/src/description.cpp @@ -702,30 +702,15 @@ void Description::Media::removeFormat(const string &fmt) { } } -void Description::Video::addVideoCodec(int payloadType, const string &codec) { +void Description::Video::addVideoCodec(int payloadType, const string &codec, const std::optional& profile) { RTPMap map(std::to_string(payloadType) + ' ' + codec + "/90000"); map.addFB("nack"); map.addFB("nack pli"); - // map.addFB("nack fir"); + // map.addFB("ccm fir"); map.addFB("goog-remb"); - if (codec == "H264") { - // Use Constrained Baseline profile Level 4.2 (necessary for Firefox) - // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#Supported_video_codecs - // TODO: Should be 42E0 but 42C0 appears to be more compatible. Investigate this. - map.fmtps.emplace_back( - "profile-level-id=4de01f;packetization-mode=1;level-asymmetry-allowed=1"); - - // Because certain Android devices don't like me, let us just negotiate some random -// { -// RTPMap map(std::to_string(payloadType + 1) + ' ' + codec + "/90000"); -// map.addFB("nack"); -// map.addFB("nack pli"); -// // map.addFB("nack fir"); -// map.addFB("goog-remb"); -// addRTPMap(map); -// } - } - addRTPMap(map); + if (profile) + map.fmtps.emplace_back(*profile); + addRTPMap(map); // // RTX Packets /* TODO @@ -741,10 +726,11 @@ void Description::Video::addVideoCodec(int payloadType, const string &codec) { // ";rtx-time=3000"); addRTPMap(rtx); } -void Description::Audio::addAudioCodec(int payloadType, const string &codec) { +void Description::Audio::addAudioCodec(int payloadType, const string &codec, const std::optional& profile) { // TODO This 48000/2 should be parameterized RTPMap map(std::to_string(payloadType) + ' ' + codec + "/48000/2"); - map.fmtps.emplace_back("minptime=10; maxaveragebitrate=96000; stereo=1; sprop-stereo=1; useinbandfec=1"); + if (profile) + map.fmtps.emplace_back(*profile); addRTPMap(map); }