mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-26 11:52:22 +08:00
!17 【功能请求】 /index/api/getMediaList接口 增加LOSS字段用于统计每个轨道丢包率反馈
* update webrtc/WebRtcPusher.h. * update webrtc/WebRtcPusher.cpp. * update webrtc/WebRtcTransport.h. * update webrtc/WebRtcTransport.cpp. * update src/Common/MediaSource.h. * update src/Common/MediaSource.cpp. * update server/WebApi.cpp.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
@@ -612,6 +612,10 @@ public:
|
||||
}
|
||||
|
||||
int getLossRate() {
|
||||
if (!_rtcp_context.getExpectedPacketsInterval()) //_rtcp_context.getExpectedPacketsInterval()取值总为零?
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _rtcp_context.geLostInterval() * 100 / _rtcp_context.getExpectedPacketsInterval();
|
||||
}
|
||||
|
||||
@@ -655,6 +659,21 @@ std::shared_ptr<RtpChannel> MediaTrack::getRtpChannel(uint32_t ssrc) const{
|
||||
return it_chn->second;
|
||||
}
|
||||
|
||||
int WebRtcTransportImp::getLossRate(mediakit::TrackType type){
|
||||
for(auto it : _ssrc_to_track){
|
||||
auto ssrc = it.first;
|
||||
auto track = it.second;
|
||||
auto rtp_chn = track->getRtpChannel(ssrc);
|
||||
if(rtp_chn){
|
||||
InfoL << "-----------接收丢包率,ssrc------------- :" << ssrc << ",loss rate(%):" << rtp_chn->getLossRate() ;
|
||||
if (track->media && type==track->media->type){
|
||||
return rtp_chn->getLossRate();
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
|
||||
_bytes_usage += len;
|
||||
auto rtcps = RtcpHeader::loadFromBytes((char *) buf, len);
|
||||
|
||||
Reference in New Issue
Block a user