mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
防止多个track时获取rtp推流丢包率失败
This commit is contained in:
parent
5825f8b469
commit
00c9749b5d
@ -341,6 +341,7 @@ Value makeMediaSourceJson(MediaSource &media){
|
|||||||
|
|
||||||
//getLossRate有线程安全问题;使用getMediaInfo接口才能获取丢包率;getMediaList接口将忽略丢包率
|
//getLossRate有线程安全问题;使用getMediaInfo接口才能获取丢包率;getMediaList接口将忽略丢包率
|
||||||
auto current_thread = media.getOwnerPoller()->isCurrentThread();
|
auto current_thread = media.getOwnerPoller()->isCurrentThread();
|
||||||
|
float last_loss = -1;
|
||||||
for(auto &track : media.getTracks(false)){
|
for(auto &track : media.getTracks(false)){
|
||||||
Value obj;
|
Value obj;
|
||||||
auto codec_type = track->getTrackType();
|
auto codec_type = track->getTrackType();
|
||||||
@ -349,7 +350,14 @@ Value makeMediaSourceJson(MediaSource &media){
|
|||||||
obj["ready"] = track->ready();
|
obj["ready"] = track->ready();
|
||||||
obj["codec_type"] = codec_type;
|
obj["codec_type"] = codec_type;
|
||||||
if (current_thread) {
|
if (current_thread) {
|
||||||
obj["loss"] = media.getLossRate(codec_type);
|
//rtp推流只有一个统计器,但是可能有多个track,如果短时间多次获取间隔丢包率,第二次会获取为-1
|
||||||
|
auto loss = media.getLossRate(codec_type);
|
||||||
|
if (loss == -1) {
|
||||||
|
loss = last_loss;
|
||||||
|
} else {
|
||||||
|
last_loss = loss;
|
||||||
|
}
|
||||||
|
obj["loss"] = loss;
|
||||||
}
|
}
|
||||||
switch(codec_type){
|
switch(codec_type){
|
||||||
case TrackAudio : {
|
case TrackAudio : {
|
||||||
|
Loading…
Reference in New Issue
Block a user