最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - WebRTC: use of getStats() - Stack Overflow

programmeradmin0浏览0评论

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.

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.

Share Improve this question edited May 23, 2017 at 12:00 CommunityBot 11 silver badge asked Jul 8, 2016 at 9:19 Don DiegoDon Diego 1,5083 gold badges26 silver badges55 bronze badges 6
  • Post some code. Especially your call of getStats() – KRONWALLED Commented Jul 8, 2016 at 9:53
  • 2 getStats() needs a mediaStreamTrack as parameter, if i recall. – Samuel Méndez Commented Jul 8, 2016 at 9:59
  • Updated question! P.s: what if I call peer.getStats(null, function(...) ) ? – Don Diego Commented Jul 8, 2016 at 10:16
  • 1 That should. The track is only a filter, and can be left out with null. – jib Commented Jul 8, 2016 at 13:18
  • I would close this as a duplicate of this question, except you seem to want it to work in Chrome specifically, is that right? – jib Commented Jul 8, 2016 at 13:19
 |  Show 1 more ment

1 Answer 1

Reset to default 6

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

发布评论

评论列表(0)

  1. 暂无评论