sdp相关特性暴露成常量

This commit is contained in:
xia-chu 2021-04-30 15:15:35 +08:00
parent dc2c882994
commit c77c4cfd4d
3 changed files with 31 additions and 19 deletions

View File

@ -1250,28 +1250,28 @@ bool RtcSession::supportRtcpFb(const string &name, TrackType type) const {
return ref.find(name) != ref.end(); return ref.find(name) != ref.end();
} }
static string const kTWCCRtcpFb = "transport-cc"; string const SdpConst::kTWCCRtcpFb = "transport-cc";
static string const kTWCCExtMap = "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"; string const SdpConst::kTWCCExtMap = "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01";
static string const kRembRtcpFb = "goog-remb"; string const SdpConst::kRembRtcpFb = "goog-remb";
static string const kRembExtMap = "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; string const SdpConst::kRembExtMap = "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
void RtcConfigure::RtcTrackConfigure::enableTWCC(bool enable){ void RtcConfigure::RtcTrackConfigure::enableTWCC(bool enable){
if (!enable) { if (!enable) {
rtcp_fb.erase(kTWCCRtcpFb); rtcp_fb.erase(SdpConst::kTWCCRtcpFb);
extmap.erase(kTWCCExtMap); extmap.erase(SdpConst::kTWCCExtMap);
} else { } else {
rtcp_fb.emplace(kTWCCRtcpFb); rtcp_fb.emplace(SdpConst::kTWCCRtcpFb);
extmap.emplace(kTWCCExtMap); extmap.emplace(SdpConst::kTWCCExtMap);
} }
} }
void RtcConfigure::RtcTrackConfigure::enableREMB(bool enable){ void RtcConfigure::RtcTrackConfigure::enableREMB(bool enable){
if (!enable) { if (!enable) {
rtcp_fb.erase(kRembRtcpFb); rtcp_fb.erase(SdpConst::kRembRtcpFb);
extmap.erase(kRembExtMap); extmap.erase(SdpConst::kRembExtMap);
} else { } else {
rtcp_fb.emplace(kRembRtcpFb); rtcp_fb.emplace(SdpConst::kRembRtcpFb);
extmap.emplace(kRembExtMap); extmap.emplace(SdpConst::kRembExtMap);
} }
} }
@ -1290,10 +1290,10 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
case TrackAudio: { case TrackAudio: {
//此处调整偏好的编码格式优先级 //此处调整偏好的编码格式优先级
preferred_codec = {CodecAAC, CodecG711U, CodecG711A, CodecOpus}; preferred_codec = {CodecAAC, CodecG711U, CodecG711A, CodecOpus};
rtcp_fb = {kTWCCRtcpFb, kRembRtcpFb}; rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb};
extmap = { extmap = {
kTWCCExtMap, SdpConst::kTWCCExtMap,
kRembExtMap, SdpConst::kRembExtMap,
"urn:ietf:params:rtp-hdrext:ssrc-audio-level", "urn:ietf:params:rtp-hdrext:ssrc-audio-level",
"urn:ietf:params:rtp-hdrext:sdes:mid", "urn:ietf:params:rtp-hdrext:sdes:mid",
"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",
@ -1304,10 +1304,10 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
case TrackVideo: { case TrackVideo: {
//此处调整偏好的编码格式优先级 //此处调整偏好的编码格式优先级
preferred_codec = {CodecH264, CodecH265}; 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 = { extmap = {
kTWCCExtMap, SdpConst::kTWCCExtMap,
kRembExtMap, SdpConst::kRembExtMap,
"urn:ietf:params:rtp-hdrext:toffset", "urn:ietf:params:rtp-hdrext:toffset",
"urn:3gpp:video-orientation", "urn:3gpp:video-orientation",
"http://www.webrtc.org/experiments/rtp-hdrext/playout-delay", "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay",

View File

@ -730,5 +730,17 @@ private:
RtcCodecPlan::Ptr _rtsp_audio_plan; 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 #endif //ZLMEDIAKIT_SDP_H

View File

@ -623,7 +623,7 @@ void WebRtcTransportImp::onSortedRtp(const RtpPayloadInfo &info, RtpPacket::Ptr
//开启remb则发送remb包调节比特率 //开启remb则发送remb包调节比特率
GET_CONFIG(size_t, remb_bit_rate, RTC::kRembBitRate); 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); sendRtcpRemb(_recv_video_ssrc, remb_bit_rate);
} }
} }