Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC: use of getStats()

I'm trying to get stats of a webRTC app to measure audio/video streaming bandwidth. I checked this question and I found it very useful; however, when I try to use it I get

TypeError: Not enough arguments to RTCPeerConnection.getStats.

I think that is because of in 2016 something in webRTC is changed and now there are mediaStreamTracks; however I built the project without mediaStreamTracks and I don't know how to change this function to get it to work.

Do you have any ideas? Thanks for your support!

UPDATE:

My call is

peer.pc.onaddstream = function(event) {
      peer.remoteVideoEl.setAttribute("id", event.stream.id);
      attachMediaStream(peer.remoteVideoEl, event.stream);
      remoteVideosContainer.appendChild(peer.remoteVideoEl);
      getStats(peer.pc);
};

and getStats() is identical to this link at chapter n.7.

like image 625
Don Diego Avatar asked Jul 08 '16 09:07

Don Diego


1 Answers

been sometime since I used WebRTC, problem then was, chrome and firefox implemented it differently( believe they still do it differently)

Firefox:

webrtc stats tab is about:webrtc

peerConnection.getStats(null).then(function(stats){...  // returns a promise

Chrome:

webrtc stats tab is chrome://webrtc-internals/

peerConnection.getStats(function(stats){ // pass a callback function

one way to circumvent these cross browser issues is using adapter.js

like image 138
mido Avatar answered Sep 22 '22 14:09

mido