Add network traffic statistics (#4239)

Co-authored-by: xiongguangjie <xiong_panda@163.com>
Co-authored-by: xia-chu <771730766@qq.com>
This commit is contained in:
PioLing
2025-05-02 16:23:25 +08:00
committed by GitHub
parent ab14adb94d
commit 7b1f8fedac
35 changed files with 325 additions and 19 deletions

View File

@@ -800,7 +800,7 @@ void RtspPlayer::onPlayResult_l(const SockException &ex, bool handshake_done) {
};
// 创建rtp数据接收超时检测定时器 [AUTO-TRANSLATED:edbffc19]
// Create RTP data receive timeout detection timer
_rtp_check_timer = std::make_shared<Timer>(timeoutMS / 2000.0f, lam, getPoller());
_rtp_check_timer = std::make_shared<Timer>(timeoutMS / 2000.0f, std::move(lam), getPoller());
} else {
sendTeardown();
}
@@ -844,6 +844,36 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType track_type) const {
throw SockException(Err_other, StrPrinter << "no such track with type:" << getTrackString(track_type));
}
size_t RtspPlayer::getRecvSpeed() {
size_t ret = TcpClient::getRecvSpeed();
for (auto &rtp : _rtp_sock) {
if (rtp) {
ret += rtp->getRecvSpeed();
}
}
for (auto &rtcp : _rtcp_sock) {
if (rtcp) {
ret += rtcp->getRecvSpeed();
}
}
return ret;
}
size_t RtspPlayer::getRecvTotalBytes() {
size_t ret = TcpClient::getRecvTotalBytes();
for (auto &rtp : _rtp_sock) {
if (rtp) {
ret += rtp->getRecvTotalBytes();
}
}
for (auto &rtcp : _rtcp_sock) {
if (rtcp) {
ret += rtcp->getRecvTotalBytes();
}
}
return ret;
}
///////////////////////////////////////////////////
// RtspPlayerImp
float RtspPlayerImp::getDuration() const {