From a176cb83a87607f0da1c5e1caecc301830119dc0 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 2 Apr 2021 23:12:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=95=99rtcp=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 --- webrtc/WebRtcTransport.cpp | 20 ++++++++++++++++++-- webrtc/WebRtcTransport.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 46ff8477..4eccfa2f 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -186,6 +186,17 @@ void WebRtcTransport::sendRtpPacket(char *buf, size_t len, bool flush) { } } +void WebRtcTransport::sendRtcpPacket(char *buf, size_t len, bool flush){ + const uint8_t *p = (uint8_t *) buf; + bool ret = false; + if (_srtp_session_send) { + ret = _srtp_session_send->EncryptRtcp(&p, &len); + } + if (ret) { + onSendSockData((char *) p, len, flush); + } +} + /////////////////////////////////////////////////////////////////////////////////// WebRtcTransportImp::Ptr WebRtcTransportImp::create(const EventPoller::Ptr &poller){ WebRtcTransportImp::Ptr ret(new WebRtcTransportImp(poller), [](WebRtcTransportImp *ptr){ @@ -389,17 +400,22 @@ void WebRtcTransportImp::onRtp(const char *buf, size_t len) { void WebRtcTransportImp::onRtcp(const char *buf, size_t len) { RtcpHeader *rtcp = (RtcpHeader *) buf; + //todo rtcp相关 } void WebRtcTransportImp::onSortedRtp(const RtpPayloadInfo &info, RtpPacket::Ptr rtp) { if(!info.is_common_rtp){ WarnL; } - _push_src->onWrite(std::move(rtp), true); + if (_pli_ticker.elapsedTime() > 2000) { + //todo 发送pli + _pli_ticker.resetTime(); + } + _push_src->onWrite(std::move(rtp), false); } void WebRtcTransportImp::onBeforeSortedRtp(const RtpPayloadInfo &info, const RtpPacket::Ptr &rtp) { - + //todo rtcp相关 } /////////////////////////////////////////////////////////////////// diff --git a/webrtc/WebRtcTransport.h b/webrtc/WebRtcTransport.h index d754f2ca..11960872 100644 --- a/webrtc/WebRtcTransport.h +++ b/webrtc/WebRtcTransport.h @@ -45,6 +45,7 @@ public: * @param len rtcp长度 */ void sendRtpPacket(char *buf, size_t len, bool flush); + void sendRtcpPacket(char *buf, size_t len, bool flush); protected: //// dtls相关的回调 //// @@ -152,6 +153,7 @@ private: mutable uint8_t _send_rtp_pt[2] = {0, 0}; RtspMediaSourceImp::Ptr _push_src; unordered_map _rtp_receiver; + Ticker _pli_ticker; };