From 22c68a297ee299bc9ec30c64881255ff83369805 Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 13 Oct 2021 17:57:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=20RtcpContext=20=E6=88=90?= =?UTF-8?q?=E5=91=98=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtcp/RtcpContext.cpp | 7 ++++++- src/Rtcp/RtcpContext.h | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Rtcp/RtcpContext.cpp b/src/Rtcp/RtcpContext.cpp index d2afbc95..681c9d17 100644 --- a/src/Rtcp/RtcpContext.cpp +++ b/src/Rtcp/RtcpContext.cpp @@ -120,8 +120,10 @@ size_t RtcpContext::getExpectedPackets() const { size_t RtcpContextForRecv::getExpectedPackets() const { return (_seq_cycles << 16) + _seq_max - _seq_base + 1; } - size_t RtcpContext::getExpectedPacketsInterval() { + throw std::runtime_error("没有实现, rtp发送者无法统计应收包数"); +} +size_t RtcpContextForRecv::getExpectedPacketsInterval() { auto expected = getExpectedPackets(); auto ret = expected - _last_expected; _last_expected = expected; @@ -137,6 +139,9 @@ size_t RtcpContextForRecv::getLost() { } size_t RtcpContext::geLostInterval() { + throw std::runtime_error("没有实现, rtp发送者无法统计丢包率"); +} +size_t RtcpContextForRecv::geLostInterval() { auto lost = getLost(); auto ret = lost - _last_lost; _last_lost = lost; diff --git a/src/Rtcp/RtcpContext.h b/src/Rtcp/RtcpContext.h index b25a4ed3..c476219f 100644 --- a/src/Rtcp/RtcpContext.h +++ b/src/Rtcp/RtcpContext.h @@ -73,12 +73,12 @@ public: /** * 上次结果与本次结果间应收包数 */ - size_t getExpectedPacketsInterval(); + virtual size_t getExpectedPacketsInterval(); /** * 上次结果与本次结果间丢包个数 */ - size_t geLostInterval(); + virtual size_t geLostInterval(); protected: //收到或发送的rtp的字节数 @@ -124,7 +124,9 @@ public: void onRtp(uint16_t seq, uint32_t stamp, uint64_t ntp_stamp_ms, uint32_t sample_rate, size_t bytes) override; Buffer::Ptr createRtcpRR(uint32_t rtcp_ssrc, uint32_t rtp_ssrc) override; size_t getExpectedPackets() const override; + size_t getExpectedPacketsInterval() override; size_t getLost() override; + size_t geLostInterval() override; }; }//namespace mediakit #endif //ZLMEDIAKIT_RTCPCONTEXT_H