From 2d8ef45e4d1ac44333bfd64c525485e9fb526363 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Mon, 26 Apr 2021 21:03:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84fci=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtcp/Rtcp.cpp | 66 ++++++++++++++++++++++++++++++++------ src/Rtcp/Rtcp.h | 2 +- src/Rtcp/RtcpFCI.cpp | 2 +- webrtc/Sdp.cpp | 23 +++++++++---- webrtc/WebRtcTransport.cpp | 2 +- webrtc/readme.md | 48 +++++++-------------------- 6 files changed, 88 insertions(+), 55 deletions(-) diff --git a/src/Rtcp/Rtcp.cpp b/src/Rtcp/Rtcp.cpp index c2c2d920..0e541053 100644 --- a/src/Rtcp/Rtcp.cpp +++ b/src/Rtcp/Rtcp.cpp @@ -12,6 +12,7 @@ #include #include "Rtcp.h" #include "Util/logger.h" +#include "RtcpFCI.h" namespace mediakit { @@ -493,18 +494,65 @@ string RtcpFB::dumpString() const { printer << RtcpHeader::dumpHeader(); printer << "ssrc:" << ssrc << "\r\n"; printer << "ssrc_media:" << ssrc_media << "\r\n"; - auto fci = (uint8_t *)&ssrc_media + sizeof(ssrc_media); + auto fci_data = (uint8_t *)&ssrc_media + sizeof(ssrc_media); auto fci_len = getSize() - sizeof(RtcpFB); - if (fci_len) { - switch ((RtcpType) pt) { - case RtcpType::RTCP_PSFB : { - break; - } - case RtcpType::RTCP_RTPFB : { - break; + switch ((RtcpType) pt) { + case RtcpType::RTCP_PSFB : { + switch ((PSFBType) report_count) { + case PSFBType::RTCP_PSFB_SLI : { + FCI_SLI *fci = (FCI_SLI *) fci_data; + fci->check(fci_len); + printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci->dumpString(); + break; + } + case PSFBType::RTCP_PSFB_PLI : { + CHECK(fci_len == 0); + printer << "fci:" << psfbTypeToStr((PSFBType) report_count); + break; + } + + case PSFBType::RTCP_PSFB_FIR : { + FCI_FIR *fci = (FCI_FIR *) fci_data; + fci->check(fci_len); + printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci->dumpString(); + break; + } + + case PSFBType::RTCP_PSFB_REMB : { + FCI_REMB *fci = (FCI_REMB *) fci_data; + fci->check(fci_len); + printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << fci->dumpString(); + break; + } + default:{ + printer << "fci:" << psfbTypeToStr((PSFBType) report_count) << " " << hexdump(fci_data, fci_len); + break; + } } + break; } - printer << "fci:" << hexdump(fci, fci_len); + case RtcpType::RTCP_RTPFB : { + switch ((RTPFBType) report_count) { + case RTPFBType::RTCP_RTPFB_NACK : { + FCI_NACK *fci = (FCI_NACK *) fci_data; + fci->check(fci_len); + printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << fci->dumpString(); + break; + } + case RTPFBType::RTCP_RTPFB_TWCC : { + FCI_TWCC *fci = (FCI_TWCC *) fci_data; + fci->check(fci_len); + printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << fci->dumpString(fci_len); + break; + } + default: { + printer << "fci:" << rtpfbTypeToStr((RTPFBType) report_count) << " " << hexdump(fci_data, fci_len); + break; + } + } + break; + } + default: /*不可达*/ assert(0); break; } return std::move(printer); } diff --git a/src/Rtcp/Rtcp.h b/src/Rtcp/Rtcp.h index ddc5ae71..5637e4ee 100644 --- a/src/Rtcp/Rtcp.h +++ b/src/Rtcp/Rtcp.h @@ -85,7 +85,7 @@ namespace mediakit { XX(RTCP_PSFB_TSTR, 5)\ XX(RTCP_PSFB_TSTN, 6)\ XX(RTCP_PSFB_VBCM, 7) \ - XX(RTCP_PSFB_AFB, 15) + XX(RTCP_PSFB_REMB, 15) //https://tools.ietf.org/html/rfc4585#section-6.2 //6.2. Transport Layer Feedback Messages diff --git a/src/Rtcp/RtcpFCI.cpp b/src/Rtcp/RtcpFCI.cpp index 28ed2945..e9627abc 100644 --- a/src/Rtcp/RtcpFCI.cpp +++ b/src/Rtcp/RtcpFCI.cpp @@ -453,7 +453,7 @@ map > FCI_TWCC::getPacketCh string FCI_TWCC::dumpString(size_t total_size) const { _StrPrinter printer; auto map = getPacketChunkList(total_size); - printer << "twcc fci, base_seq:" << getBaseSeq() << ",pkt_status_count:" << getPacketCount() << ", ref time:" << getReferenceTime() << ", fb count:" << (int)fb_pkt_count << "\n"; + printer << "twcc fci, base_seq:" << getBaseSeq() << ", pkt_status_count:" << getPacketCount() << ", ref time:" << getReferenceTime() << ", fb count:" << (int)fb_pkt_count << "\n"; for (auto &pr : map) { printer << "rtp seq:" << pr.first <<", packet status:" << (int)(pr.second.first) << ", delta:" << pr.second.second << "\n"; } diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 69feb7de..f6fbc4f8 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1257,18 +1257,29 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){ //此处调整偏好的编码格式优先级 preferred_codec = {CodecAAC, CodecG711U, CodecG711A, CodecOpus}; rtcp_fb = {"transport-cc"}; - extmap = {"1 urn:ietf:params:rtp-hdrext:ssrc-audio-level"}; + extmap = {"1 urn:ietf:params:rtp-hdrext:ssrc-audio-level", + "2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", + "3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", + "4 urn:ietf:params:rtp-hdrext:sdes:mid", + "5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", + "6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"}; break; } case TrackVideo: { //此处调整偏好的编码格式优先级 preferred_codec = {CodecH264, CodecH265}; rtcp_fb = {"nack", "ccm fir", "nack pli", "goog-remb", "transport-cc"}; - extmap = {"2 urn:ietf:params:rtp-hdrext:toffset", - "3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", - "4 urn:3gpp:video-orientation", - "5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", - "6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"}; + extmap = {"14 urn:ietf:params:rtp-hdrext:toffset", + "2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", + "13 urn:3gpp:video-orientation", + "3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", + "12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay", + "11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type", + "7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing", + "8 http://www.webrtc.org/experiments/rtp-hdrext/color-space", + "4 urn:ietf:params:rtp-hdrext:sdes:mid", + "5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", + "6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"}; break; } case TrackApplication: { diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index d4392385..1a13c656 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -544,7 +544,7 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) { } case RtcpType::RTCP_PSFB: case RtcpType::RTCP_RTPFB: { - InfoL << rtcp->dumpString(); + InfoL << "\n" << rtcp->dumpString(); break; } default: break; diff --git a/webrtc/readme.md b/webrtc/readme.md index ff832278..2884df14 100644 --- a/webrtc/readme.md +++ b/webrtc/readme.md @@ -1,37 +1,11 @@ -# 致谢与声明 -本文件夹下部分文件提取自[MediaSoup](https://github.com/versatica/mediasoup) ,分别为: - -- ice相关功能: - - IceServer.cpp - - IceServer.hpp - - StunPacket.cpp - - StunPacket.hpp - - Utils.hpp - -- dtls相关功能: - - DtlsTransport.cpp - - DtlsTransport.hpp - -- srtp相关功能: - - SrtpSession.cpp - - SrtpSession.hpp - - -以上源码有一定的修改和裁剪,感谢MediaSoup开源项目及作者, -用户在使用本项目的同时,应该同时遵循MediaSoup的开源协议。 - -同时,在此也感谢开源项目[easy_webrtc_server](https://github.com/Mihawk086/easy_webrtc_server) 及作者, -在集成MediaSoup相关代码前期,主要参考这个项目。 - -另外,感谢[big panda](<2381267071@qq.com>) 开发并贡献的webrtc js测试客户端(www/webrtc目录下文件), -其开源项目地址为:https://gitee.com/xiongguangjie/zlmrtcclient.js - -# 现状与规划 -ZLMediaKit的WebRTC相关功能目前仅供测试与开发,现在还不成熟,后续主要工作有: - -- 1、完善webrtc rtcp相关功能,包括丢包重传、带宽检测等功能。 -- 2、实现rtp重传等相关功能。 -- 3、实现simulecast相关功能。 -- 4、fec、rtp扩展等其他功能。 -- 5、如果精力允许,逐步替换MediaSoup相关代码,改用自有版权代码。 - +14 urn:ietf:params:rtp-hdrext:toffset +2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time +13 urn:3gpp:video-orientation +3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 +12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay +11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type +7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing +8 http://www.webrtc.org/experiments/rtp-hdrext/color-space +4 urn:ietf:params:rtp-hdrext:sdes:mid +5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id +6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id \ No newline at end of file