调整 RtcpContext 成员函数

This commit is contained in:
Johnny 2021-10-13 17:57:52 +08:00
parent f64129177e
commit 22c68a297e
2 changed files with 10 additions and 3 deletions

View File

@ -120,8 +120,10 @@ size_t RtcpContext::getExpectedPackets() const {
size_t RtcpContextForRecv::getExpectedPackets() const { size_t RtcpContextForRecv::getExpectedPackets() const {
return (_seq_cycles << 16) + _seq_max - _seq_base + 1; return (_seq_cycles << 16) + _seq_max - _seq_base + 1;
} }
size_t RtcpContext::getExpectedPacketsInterval() { size_t RtcpContext::getExpectedPacketsInterval() {
throw std::runtime_error("没有实现, rtp发送者无法统计应收包数");
}
size_t RtcpContextForRecv::getExpectedPacketsInterval() {
auto expected = getExpectedPackets(); auto expected = getExpectedPackets();
auto ret = expected - _last_expected; auto ret = expected - _last_expected;
_last_expected = expected; _last_expected = expected;
@ -137,6 +139,9 @@ size_t RtcpContextForRecv::getLost() {
} }
size_t RtcpContext::geLostInterval() { size_t RtcpContext::geLostInterval() {
throw std::runtime_error("没有实现, rtp发送者无法统计丢包率");
}
size_t RtcpContextForRecv::geLostInterval() {
auto lost = getLost(); auto lost = getLost();
auto ret = lost - _last_lost; auto ret = lost - _last_lost;
_last_lost = lost; _last_lost = lost;

View File

@ -73,12 +73,12 @@ public:
/** /**
* *
*/ */
size_t getExpectedPacketsInterval(); virtual size_t getExpectedPacketsInterval();
/** /**
* *
*/ */
size_t geLostInterval(); virtual size_t geLostInterval();
protected: protected:
//收到或发送的rtp的字节数 //收到或发送的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; 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; Buffer::Ptr createRtcpRR(uint32_t rtcp_ssrc, uint32_t rtp_ssrc) override;
size_t getExpectedPackets() const override; size_t getExpectedPackets() const override;
size_t getExpectedPacketsInterval() override;
size_t getLost() override; size_t getLost() override;
size_t geLostInterval() override;
}; };
}//namespace mediakit }//namespace mediakit
#endif //ZLMEDIAKIT_RTCPCONTEXT_H #endif //ZLMEDIAKIT_RTCPCONTEXT_H