From c77c4cfd4dd33c1f1b779abb5829ef4752437dd3 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Fri, 30 Apr 2021 15:15:35 +0800 Subject: [PATCH] =?UTF-8?q?sdp=E7=9B=B8=E5=85=B3=E7=89=B9=E6=80=A7?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E6=88=90=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Sdp.cpp | 36 ++++++++++++++++++------------------ webrtc/Sdp.h | 12 ++++++++++++ webrtc/WebRtcTransport.cpp | 2 +- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 3c137fde..987d095f 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1250,28 +1250,28 @@ bool RtcSession::supportRtcpFb(const string &name, TrackType type) const { return ref.find(name) != ref.end(); } -static string const kTWCCRtcpFb = "transport-cc"; -static string const kTWCCExtMap = "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"; -static string const kRembRtcpFb = "goog-remb"; -static string const kRembExtMap = "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; +string const SdpConst::kTWCCRtcpFb = "transport-cc"; +string const SdpConst::kTWCCExtMap = "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"; +string const SdpConst::kRembRtcpFb = "goog-remb"; +string const SdpConst::kRembExtMap = "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; void RtcConfigure::RtcTrackConfigure::enableTWCC(bool enable){ if (!enable) { - rtcp_fb.erase(kTWCCRtcpFb); - extmap.erase(kTWCCExtMap); + rtcp_fb.erase(SdpConst::kTWCCRtcpFb); + extmap.erase(SdpConst::kTWCCExtMap); } else { - rtcp_fb.emplace(kTWCCRtcpFb); - extmap.emplace(kTWCCExtMap); + rtcp_fb.emplace(SdpConst::kTWCCRtcpFb); + extmap.emplace(SdpConst::kTWCCExtMap); } } void RtcConfigure::RtcTrackConfigure::enableREMB(bool enable){ if (!enable) { - rtcp_fb.erase(kRembRtcpFb); - extmap.erase(kRembExtMap); + rtcp_fb.erase(SdpConst::kRembRtcpFb); + extmap.erase(SdpConst::kRembExtMap); } else { - rtcp_fb.emplace(kRembRtcpFb); - extmap.emplace(kRembExtMap); + rtcp_fb.emplace(SdpConst::kRembRtcpFb); + extmap.emplace(SdpConst::kRembExtMap); } } @@ -1290,10 +1290,10 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){ case TrackAudio: { //此处调整偏好的编码格式优先级 preferred_codec = {CodecAAC, CodecG711U, CodecG711A, CodecOpus}; - rtcp_fb = {kTWCCRtcpFb, kRembRtcpFb}; + rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb}; extmap = { - kTWCCExtMap, - kRembExtMap, + SdpConst::kTWCCExtMap, + SdpConst::kRembExtMap, "urn:ietf:params:rtp-hdrext:ssrc-audio-level", "urn:ietf:params:rtp-hdrext:sdes:mid", "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", @@ -1304,10 +1304,10 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){ case TrackVideo: { //此处调整偏好的编码格式优先级 preferred_codec = {CodecH264, CodecH265}; - rtcp_fb = {kTWCCRtcpFb, kRembRtcpFb, "nack", "ccm fir", "nack pli"}; + rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb, "nack", "ccm fir", "nack pli"}; extmap = { - kTWCCExtMap, - kRembExtMap, + SdpConst::kTWCCExtMap, + SdpConst::kRembExtMap, "urn:ietf:params:rtp-hdrext:toffset", "urn:3gpp:video-orientation", "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay", diff --git a/webrtc/Sdp.h b/webrtc/Sdp.h index a180c5ee..fa7f31a3 100644 --- a/webrtc/Sdp.h +++ b/webrtc/Sdp.h @@ -730,5 +730,17 @@ private: RtcCodecPlan::Ptr _rtsp_audio_plan; }; +class SdpConst { +public: + static string const kTWCCRtcpFb; + static string const kTWCCExtMap; + static string const kRembRtcpFb; + static string const kRembExtMap; + +private: + SdpConst() = delete; + ~SdpConst() = delete; +}; + #endif //ZLMEDIAKIT_SDP_H diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index cfe70132..484400db 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -623,7 +623,7 @@ void WebRtcTransportImp::onSortedRtp(const RtpPayloadInfo &info, RtpPacket::Ptr //开启remb,则发送remb包调节比特率 GET_CONFIG(size_t, remb_bit_rate, RTC::kRembBitRate); - if (remb_bit_rate) { + if (remb_bit_rate && getSdp(SdpType::answer).supportRtcpFb(SdpConst::kRembRtcpFb)) { sendRtcpRemb(_recv_video_ssrc, remb_bit_rate); } }