WebRTC: how to calculate user bandwidth / network latency RTC Peer Connection

So, I'm working on an application that uses WebRTC to provide video / audio communication between peers.

I would like to provide some feedback to users regarding their network connection / bandwidth / delay, etc., in order to suggest possible solutions if bandwidth, etc. terrible.

WebRTC has a getStats() API that provides several key pieces of information. When the peer connection is active, getStats() gives me the following object ...

 { "googLibjingleSession_5531731670954573009":{ "id":"googLibjingleSession_5531731670954573009", "timestamp":"2016-02-02T11:14:43.467Z", "type":"googLibjingleSession", "googInitiator":"true" }, "googTrack_SCEHhCOl":{ "id":"googTrack_SCEHhCOl", "timestamp":"2016-02-02T11:14:43.467Z", "type":"googTrack", "googTrackId":"SCEHhCOl" }, "ssrc_360347109_recv":{ "id":"ssrc_360347109_recv", "timestamp":"2016-02-02T11:14:43.467Z", "type":"ssrc", "googDecodingCTN":"757", "packetsLost":"0", "googSecondaryDecodedRate":"0", "googDecodingPLC":"3", "packetsReceived":"373", "googExpandRate":"0.00579834", "googJitterReceived":"0", "googDecodingCNG":"0", "ssrc":"360347109", "googPreferredJitterBufferMs":"20", "googSpeechExpandRate":"0.00140381", "googTrackId":"SCEHhCOl", "transportId":"Channel-audio-1", "googDecodingPLCCNG":"10", "googCodecName":"opus", "googDecodingNormal":"744", "audioOutputLevel":"6271", "googAccelerateRate":"0", "bytesReceived":"21796", "googCurrentDelayMs":"64", "googDecodingCTSG":"0", "googCaptureStartNtpTimeMs":"-1", "googPreemptiveExpandRate":"0.00292969", "googJitterBufferMs":"42" } } 

It is with this information that I hope to count users ...

a) Bandwidth (ideally audio and video are separate, but straight-line bandwidth will be sufficient)

b) Network delay

Thanks in advance...

NB : I already saw this shell , but I would like it to be valid (with a little help, of course: D), since the code for this shell uses the "bytesSent" property, which does not seem to return from getStats() ?

I also know about the WebRTC test available on GitHub, but again, I should be able to achieve what I want without relying on third-party third-party plugins, etc.

+5
source share
1 answer

As far as I remember, the properties for these RTCStatReports are very different. For example, the bytesSent property you mentioned is not always available, you might need:

 // chrome if (res.googCodecName == 'VP8' && res.bytesSent) { // res.bytesSent - bytes sent so far (video) } // firefox if (res.mediaType == 'video' && res.bytesSent) ... 

Check out the source for the wrapper you posted to find out more. You can also take a look at my plug (if the shell no longer works, that was the last time I looked).

+3
source

Source: https://habr.com/ru/post/1242087/


All Articles