statistics - WebRTC getStat() API Set UP -
I am trying to use getStat () from the webRTC API to see if it has any useful information The solution provides latency and other video streaming data. The problem is that there is not much information about how to use it. Even old current examples are very rare but the API has changed since then.
For example, my set up:
coworker .getStats (function (statistics) {console.log (statistics);}));
This gives an RTCstats response object with 2 functions
RTCStatsResponse {Result: function, nameItem: function}
Trying to call that result () returns an array of RTCStats functions. For the object type type 'googLibjingleSession' with the report object and for the second object type 'googtrack' Trying to call the other name item function When doing this it is not undefined
[RTCStatsReport, RTCSta TsReport]
Any information that is available (from), I would have found a lot more RTCStatObjects with more useful information I am currently receiving
What Does anyone have experience using VBRC's GetStats? I believe I can not do it correctly
The following solution works for me .
Creating Peer Connection
PC = New RTCP Connection (PCC Config, PCC);
Adding onaddstream handler
pc.onaddstream = onRemoteStreamAdded;
Handler itself
var paramstream add = function (event) {attachMediaStream (remote video, event.stream); Remote stream = event.stream; GetStats (pc); };
Focus on the gatestats function called handler, the function is
function getStats (peer) {myGetStats (peer, function (result) {For Var i = 0; i & lt; results.length; ++ i) {var res = results [i]; Console.log (res);} setTimeout (function () {getStats (peer);}, 1000);}); }
The myGetStats function is a cover to make possible universal in different browsers;
function myGetStats (peer, callback) {if (!! Navigator .mozGetUserMedia) {peer.getStats (function) {var items = []; res.for each (jobs (results ) {Items.push (results);}); callback (item);}, callback); } Else {peer.getStats (function (res) {var items = []; res.result () .forEach (function) {var item = {}; result.names (). ForEach (function (name) { Item [name] = results. Stat (name);}); item.id = result.id; item.type = result.type; item.timestamp = result.timestamp; item.push (item);}); callback (item);}); }};
Every second will get this data and print the raw object in the console log. You can parse the log and then change the code, you can get the required object's field.
Comments
Post a Comment