@@ -52,6 +52,52 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
5252 }
5353 } , 100 , true ) ) ;
5454
55+ // Helper to test WebRTC stats api.
56+ $window . showCiphers = function ( ) {
57+
58+ var prettyPrint = function ( obj ) {
59+ return JSON . stringify ( obj , null , 2 )
60+ } ;
61+
62+ var processStatsReport = function ( report ) {
63+ var channels = { } ;
64+ for ( var i in report ) {
65+ if ( report . hasOwnProperty ( i ) ) {
66+ var entry = report [ i ] ;
67+ var channel = null ;
68+ if ( entry . type === "googCandidatePair" ) {
69+ // Chrome candidate pair.
70+ if ( ! entry . googActiveConnection ) {
71+ continue
72+ }
73+ channel = report [ entry . googChannelId ] ;
74+ } else {
75+ continue ;
76+ }
77+ if ( channel && ! channels [ channel . id ] ) {
78+ channels [ channel . id ] = true ;
79+ console . info ( "Connected channel" , prettyPrint ( channel ) ) ;
80+ var localCertificate = report [ channel . localCertificateId ] ;
81+ var remoteCertificate = report [ channel . remoteCertificateId ] ;
82+ console . info ( "Local certificate" , prettyPrint ( localCertificate ) ) ;
83+ console . info ( "Remote certificate" , prettyPrint ( remoteCertificate ) ) ;
84+ }
85+ }
86+ }
87+ } ;
88+
89+ mediaStream . webrtc . callForEachCall ( function ( c ) {
90+ if ( c . peerconnection && c . peerconnection . pc ) {
91+ c . peerconnection . pc . getStats ( null , function ( report ) {
92+ processStatsReport ( report ) ;
93+ } , function ( error ) {
94+ console . log ( "Failed to retrieve stats report" , error ) ;
95+ } ) ;
96+ }
97+ } ) ;
98+
99+ } ;
100+
55101 // Load default sounds.
56102 playSound . initialize ( {
57103 urls : [ 'sounds/sprite1.ogg' , 'sounds/sprite1.mp3' ] ,
@@ -631,7 +677,7 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
631677 } ) ;
632678
633679 mediaStream . webrtc . e . on ( "bye" , function ( event , reason , from ) {
634- console . log ( "received bye" , pickupTimeout , reason ) ;
680+ // console.log("received bye", pickupTimeout, reason);
635681 switch ( reason ) {
636682 case "busy" :
637683 console . log ( "User is busy" , reason , from ) ;
0 commit comments