mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: Added rtt and remb stats
parent
3569d49df6
commit
deb01720f3
|
@ -88,6 +88,11 @@ interface IWebrtcStats {
|
||||||
frameWidth?: number, // Chrome
|
frameWidth?: number, // Chrome
|
||||||
framesSent?: number // Chrome
|
framesSent?: number // Chrome
|
||||||
} | {}
|
} | {}
|
||||||
|
},
|
||||||
|
candidatepair?: {
|
||||||
|
currentRoundTripTime?: number // Chrome
|
||||||
|
availableOutgoingBitrate?: number //Chrome
|
||||||
|
// availableIncomingBitrate?: number // No support for any browsers (https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidatePairStats/availableIncomingBitrate)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -349,8 +354,9 @@ export class WebRtcStats {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
|
|
||||||
const statsReport: any = await this.stream.getRTCPeerConnection().getStats();
|
const statsReport: any = await this.stream.getRTCPeerConnection().getStats();
|
||||||
const response = this.getWebRtcStatsResponseOutline();
|
const response: IWebrtcStats = this.getWebRtcStatsResponseOutline();
|
||||||
const videoTrackStats = ['framesReceived', 'framesDropped', 'framesSent', 'frameHeight', 'frameWidth'];
|
const videoTrackStats = ['framesReceived', 'framesDropped', 'framesSent', 'frameHeight', 'frameWidth'];
|
||||||
|
const candidatePairStats = ['availableOutgoingBitrate', 'currentRoundTripTime'];
|
||||||
|
|
||||||
statsReport.forEach((stat: any) => {
|
statsReport.forEach((stat: any) => {
|
||||||
|
|
||||||
|
@ -360,8 +366,11 @@ export class WebRtcStats {
|
||||||
if (!mediaType && (videoTrackStats.indexOf(key) > -1)) {
|
if (!mediaType && (videoTrackStats.indexOf(key) > -1)) {
|
||||||
mediaType = 'video';
|
mediaType = 'video';
|
||||||
}
|
}
|
||||||
if (direction != null && mediaType != null && key != null && response[direction] != null && response[direction][mediaType] != null) {
|
if (direction != null && mediaType != null && key != null && response[direction][mediaType] != null) {
|
||||||
response[direction][mediaType][key] = Number(stat[key]);
|
response[direction][mediaType][key] = Number(stat[key]);
|
||||||
|
} else if(direction != null && key != null && candidatePairStats.includes(key)) {
|
||||||
|
// candidate-pair-stats
|
||||||
|
response[direction][key] = Number(stat[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,8 +403,18 @@ export class WebRtcStats {
|
||||||
addStat(this.stream.isLocal() ? 'outbound' : 'inbound', 'frameHeight');
|
addStat(this.stream.isLocal() ? 'outbound' : 'inbound', 'frameHeight');
|
||||||
addStat(this.stream.isLocal() ? 'outbound' : 'inbound', 'frameWidth');
|
addStat(this.stream.isLocal() ? 'outbound' : 'inbound', 'frameWidth');
|
||||||
break;
|
break;
|
||||||
|
case 'candidate-pair':
|
||||||
|
addStat('candidatepair', 'currentRoundTripTime');
|
||||||
|
addStat('candidatepair', 'availableOutgoingBitrate');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Delete candidatepair from response if null
|
||||||
|
if(!response?.candidatepair || Object.keys(<Object>response.candidatepair).length === 0){
|
||||||
|
delete response.candidatepair;
|
||||||
|
}
|
||||||
|
|
||||||
return resolve(response);
|
return resolve(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -418,7 +437,8 @@ export class WebRtcStats {
|
||||||
outbound: {
|
outbound: {
|
||||||
audio: {},
|
audio: {},
|
||||||
video: {}
|
video: {}
|
||||||
}
|
},
|
||||||
|
candidatepair: {}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue