Search code examples
apiwebrtcdumpbitrate

Which element in webrtc API stat refer to incoming bit rate


I am trying to find any element refer to IncomingBitrate in webrtc dump file .

Where I can find the incoming bitrate in webrtc-internals?

Also, How I can calculate incoming bitrate from webrtc stats?


Solution

  • In webrtc-internals check the active connection -- it's printed in bold. Usually it is Conn-Audio-1-0. There are two fields bytesSent and bytesReceived which will allow you to calculate the bitrate. Also check the constraints + stats demo for an actual example: https://webrtc.github.io/samples/src/content/peerconnection/constraints/

    In getStats, iterate the reports until you find one of kind googCandidatePair with .stat('googActiveConnection') === 'true'. That is giving you the same information as webrtc-internals. If you want per-track/stream values, reports of type ssrc have bytesSent or bytesReceived, depending on whether they are sent or received.

    Then calculate the bitrate by dividing the bytes sent/received by the time difference between the getStats calls.