How to determine Audio/Video and Local/Remote Stat among multiple 'ssrc' Stats

381 views
Skip to first unread message

Islay

unread,
Mar 23, 2015, 1:50:56 PM3/23/15
to discuss...@googlegroups.com
Hello, 

Is there any recommended/right way to determine audio/video and local/remote stat among multiple 'ssrc' stats? PeerConnection.getStats() returns multiple 'ssrc' objects, and I am wondering if there is any recommended way (or right way) to determine which one is for local and which one is for audio specific stat. Currently, I am using following criterions, 
 - If there is 'bytesreceived' item in the 'ssrc' object, assume it is for local. Otherwise, remote.
 - If 'codec' value is 'opus', assume it is for audio. Otherwise, video. 

Any comment would be greatly appreciated. 

Regards, 
Islay

Philipp Hancke

unread,
Mar 23, 2015, 1:55:55 PM3/23/15
to discuss...@googlegroups.com
Correlating the googTrackId to your local/remote tracks is probably the better way, as this will still work (with minor changes) when the spec-compliant stats arrive: http://w3c.github.io/webrtc-stats/#dictionary-rtcmediastreamstats-members 

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Islay

unread,
Mar 23, 2015, 2:19:44 PM3/23/15
to discuss...@googlegroups.com
Hi Phillipp, 

Thank you for your response, but I am not fully understanding what you meant.  How does 'correlating the googTrackId to my local/remote tracks' help to determine local/remote stat among multiple 'ssrc' stats? Could you elaborate? 

Philipp Hancke

unread,
Mar 23, 2015, 2:48:07 PM3/23/15
to discuss...@googlegroups.com
You'd basically do something like this to get the local track ids and their type:
var tracks = {}
localPeerConnection.getLocalStreams()[0].getAudioTracks().concat(localPeerConnection.getLocalStreams()[0].getVideoTracks()).forEach(function (track) { tracks[track.id] = track.kind; })

That gives you a pretty static mapping of local tracks and their kind (audio/video).
You can also obtain that from the stream you got via getUserMedia. For remotestreams, this can also be done in the onaddStream callback.
With that information, you can look at the track id in the ssrc stat and determine whether it's local/remote and what kind.

Arguably, the criteria way is easier (-:
Message has been deleted

Islay

unread,
Mar 24, 2015, 6:40:25 PM3/24/15
to discuss...@googlegroups.com
It works! Thank you for your help Philipp!

Regards, 
Islay

anil kumar d

unread,
May 19, 2015, 3:24:11 AM5/19/15
to discuss...@googlegroups.com
Hi  Phillipp, 

even i am having same problem in identifying local and remote stats.

on my peerConn i will call getstats API which will return me an array of stats.Now i want to get info like "PacketSent","codec","PacketsRecieved","bytesSent", "bytesRecieved" "packetlost", "Jitter" on that peerConn.

This is what i did..

_peerConn.getStats(function(stats){   
                       
                        var results = stats.result();
                                
                            for(var i=0; i < results.length; i++) {                        
                                var res = results[i];        
                                if (!res.local || res.local === res) {
                                  
                                   showStats( res);
                                }

//obj is the returned stats array
function showStats(){
         if(obj.names) {                 
                    var names = obj.names();
                        for(var i=0; i<names.length; i++) {
                        var name = names[i];
                        var value = obj.stat(name);
                          //here i check for name like "packetsent" "codec" and other required info and will take its respective value from "value" i.e obj.stat(name).
                   }
          }
}

so what ever values i get it here should be same  as that in chrome://webrtc-internals.
In-case of webrtc-internals on a particular peerConn is see ssrc_6556101_send which seems to be local stats. Then in Conn-audio-1-0 c also i see some data w.r.t bytesrecieved , packetsSent etc.... what excatly is that ??

thanks in Advance
Anil

anil kumar d

unread,
May 19, 2015, 6:23:32 AM5/19/15
to discuss...@googlegroups.com
Hi  Phillipp, 

so based on your previous comment, i tried to get stats based on the local StreamID both audio and video.
once i get stats object, i will check if "trackId" is present in the object .. if its present i will check its "value" with the "StreamId" and i will get the stats info based on that. I guess ,what ever if i am getting is same as that in "ssrc_1232138323_send" . Because of which i am not able to get "bytesrecieved" info from that.
so how do we get that ???

Thanks 
Anil
Reply all
Reply to author
Forward
0 new messages