@@ -81,7 +81,7 @@ WebRTCSession.prototype.getUserMedia = function(params, callback) {
8181 /**
8282 * Additional parameters for Media Constraints
8383 * http://tools.ietf.org/html/draft-alvestrand-constraints-resolution-00
84- *
84+ *
8585 * googEchoCancellation: true
8686 * googAutoGainControl: true
8787 * googNoiseSuppression: true
@@ -125,14 +125,14 @@ WebRTCSession.prototype.attachMediaStream = function(id, stream, options) {
125125 if ( elem ) {
126126 var URL = window . URL || window . webkitURL ;
127127 elem . src = URL . createObjectURL ( stream ) ;
128-
128+
129129 if ( options && options . muted ) elem . muted = true ;
130-
130+
131131 if ( options && options . mirror ) {
132132 elem . style . webkitTransform = 'scaleX(-1)' ;
133133 elem . style . transform = 'scaleX(-1)' ;
134134 }
135-
135+
136136 elem . play ( ) ;
137137 } else {
138138 throw new Error ( 'Unable to attach media stream, element ' + id + ' is undefined' ) ;
@@ -169,7 +169,7 @@ WebRTCSession.prototype.detachMediaStream = function(id){
169169/**
170170 * [Initiate a call]
171171 * @param {object } extension [custom parametrs]
172- * @param {Function } callback
172+ * @param {Function } callback
173173 */
174174WebRTCSession . prototype . call = function ( extension , callback ) {
175175 var self = this ,
@@ -251,7 +251,7 @@ WebRTCSession.prototype.accept = function(extension) {
251251 var offerTime = ( self . acceptCallTime - self . startCallTime ) / 1000 ;
252252 self . _startWaitingOfferOrAnswerTimer ( offerTime ) ;
253253
254- /**
254+ /**
255255 * here we have to decide to which users the user should call.
256256 * We have a rule: If a userID1 > userID2 then a userID1 should call to userID2.
257257 */
@@ -452,7 +452,7 @@ WebRTCSession.prototype.processOnCall = function(callerID, extension) {
452452
453453 oppIDs . forEach ( function ( opID , i , arr ) {
454454 var pConn = self . peerConnections [ opID ] ;
455-
455+
456456 if ( pConn ) {
457457 if ( opID == callerID ) {
458458 pConn . updateRemoteSDP ( extension . sdp ) ;
@@ -509,7 +509,7 @@ WebRTCSession.prototype.processOnReject = function(userID, extension) {
509509 } else {
510510 Helpers . traceError ( "Ignore 'OnReject', there is no information about peer connection by some reason." ) ;
511511 }
512-
512+
513513 this . _closeSessionIfAllConnectionsClosed ( ) ;
514514} ;
515515
@@ -579,7 +579,7 @@ WebRTCSession.prototype.processOnNotAnswer = function(peerConnection) {
579579 peerConnection . release ( ) ;
580580
581581 if ( typeof this . onUserNotAnswerListener === 'function' ) {
582- this . onUserNotAnswerListener ( this , peerConnection . userID ) ;
582+ Utils . safeCallbackCall ( this . onUserNotAnswerListener , this , peerConnection . userID ) ;
583583 }
584584
585585 this . _closeSessionIfAllConnectionsClosed ( ) ;
@@ -590,15 +590,15 @@ WebRTCSession.prototype.processOnNotAnswer = function(peerConnection) {
590590 */
591591WebRTCSession . prototype . _onRemoteStreamListener = function ( userID , stream ) {
592592 if ( typeof this . onRemoteStreamListener === 'function' ) {
593- this . onRemoteStreamListener ( this , userID , stream ) ;
593+ Utils . safeCallbackCall ( this . onRemoteStreamListener , this , userID , stream ) ;
594594 }
595595} ;
596596
597597WebRTCSession . prototype . _onSessionConnectionStateChangedListener = function ( userID , connectionState ) {
598598 var self = this ;
599599
600600 if ( typeof self . onSessionConnectionStateChangedListener === 'function' ) {
601- self . onSessionConnectionStateChangedListener ( self , userID , connectionState ) ;
601+ Utils . safeCallbackCall ( self . onSessionConnectionStateChangedListener , self , userID , connectionState ) ;
602602 }
603603} ;
604604
@@ -613,7 +613,7 @@ WebRTCSession.prototype._createPeer = function(userID, peerConnectionType) {
613613 /**
614614 * Additional parameters for RTCPeerConnection options
615615 * new RTCPeerConnection(pcConfig, options)
616- *
616+ *
617617 * DtlsSrtpKeyAgreement: true
618618 * RtpDataChannels: true
619619 */
@@ -643,7 +643,7 @@ WebRTCSession.prototype._close = function() {
643643 this . state = WebRTCSession . State . CLOSED ;
644644
645645 if ( typeof this . onSessionCloseListener === 'function' ) {
646- this . onSessionCloseListener ( this ) ;
646+ Utils . safeCallbackCall ( this . onSessionCloseListener , this ) ;
647647 }
648648} ;
649649
@@ -775,7 +775,7 @@ WebRTCSession.prototype._uniqueOpponentsIDs = function(){
775775 opponents . push ( parseInt ( userID ) ) ;
776776 }
777777 } ) ;
778-
778+
779779 return opponents ;
780780} ;
781781
@@ -788,7 +788,7 @@ WebRTCSession.prototype._uniqueOpponentsIDsWithoutInitiator = function(){
788788 opponents . push ( parseInt ( userID ) ) ;
789789 }
790790 } ) ;
791-
791+
792792 return opponents ;
793793} ;
794794
@@ -832,4 +832,4 @@ function _prepareIceServers(iceServers) {
832832 return iceServersCopy ;
833833}
834834
835- module . exports = WebRTCSession ;
835+ module . exports = WebRTCSession ;
0 commit comments