javascript中有chrome:// webrtc-internals/variables的API吗?

Mar*_*kov 11 javascript google-chrome webrtc google-chrome-app peerjs

我想访问一些已记录的变量chrome://webrtc-internals/,但我没有在谷歌上找到任何东西 - 甚至没有我能看到的图表的描述.
我特别感兴趣packetsLost,googCurrentDelayMs并且googNacksSent.

为什么我要访问webrtc-internals
我正在编写一个共享视频流的谷歌浏览器应用程序(p2p).它使用peerjs与其他对等体共享流,后者又使用googles webrtc实现.为了使我的应用程序完美,我需要知道何时发生大的延迟.由于我可以看到记录的延迟,chrome://webrtc-internals/我想知道我是否可以通过javascript访问它.

我的猜测是chrome://webrtc-internals/-menu 没有API .

Mar*_*kov 20

我发现它-必须通过几个谷歌社区线程(的抓取线程1,线程2):

var peerjs = new Peer(...);  // initialize peerJS
var connections = peerjs.connections;
Run Code Online (Sandbox Code Playgroud)

Connections是一个对象:

Object {2e1c5694-e6ef-e1b2-22d5-84a3807961d4: Array[3]}
    2e1c5694-e6ef-e1b2-22d5-84a3807961d4: Array[3]
        0: DataConnection
        1: MediaConnection
        2: MediaConnection
        length: 3
    __proto__: Array[0]
__proto__: Object
Run Code Online (Sandbox Code Playgroud)

看看这些连接对象中的任何一个:

var rtcPeerConn = connectionObject.pc; // RTCPeerConnection

rtcPeerConn.getStats(function callback(connStats){
    var rtcStatsReports = connStats.result() // array of available status-reports
    // each status-report object has many status variables, such as
    // googCurrentDelayMs. You need to iterate over all object and check 
    // their names to find the one status report you want
    rtcStatsReports[7].names() // returns all available variables for that report

    var googCurrentDelayMs = rtcStatsReports[7].stat('googCurrentDelayMs')
    console.log(googCurrentDelayMs) // finally - googCurrentDelayMs :-)
})
Run Code Online (Sandbox Code Playgroud)