7

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.

4

1 回答 1

6

自从我使用 WebRTC 以来,问题是,chrome 和 firefox 以不同的方式实现它(相信他们仍然以不同的方式实现它)

火狐:

webrtc 统计选项卡是about:webrtc

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

铬合金:

webrtc 统计选项卡是chrome://webrtc-internals/

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

规避这些跨浏览器问题的一种方法是使用adapter.js

于 2016-07-08T12:57:12.140 回答