Skip to content

Commit 35e0fa2

Browse files
author
Igor Khomenko
committed
fixed an issues with webrtc stats: 'error is not defined'
1 parent eff85b2 commit 35e0fa2

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

js/modules/webrtc/qbRTCPeerConnection.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ RTCPeerConnection.prototype.onAddRemoteStreamCallback = function(event) {
182182
this.delegate._onRemoteStreamListener(this.userID, event.stream);
183183
}
184184

185-
186185
self._getStatsWrap();
187186
};
188187

@@ -234,8 +233,6 @@ RTCPeerConnection.prototype.onIceConnectionStateCallback = function() {
234233
*/
235234
RTCPeerConnection.prototype._clearStatsReportTimer = function(){
236235
if(this.statsReportTimer){
237-
Helpers.trace('_clearStatsReportTimer');
238-
239236
clearInterval(this.statsReportTimer);
240237
this.statsReportTimer = null;
241238
}
@@ -244,7 +241,7 @@ RTCPeerConnection.prototype.onIceConnectionStateCallback = function() {
244241
RTCPeerConnection.prototype._getStatsWrap = function() {
245242
var self = this,
246243
selector = self.delegate.callType == 1 ? self.getLocalStreams()[0].getVideoTracks()[0] : self.getLocalStreams()[0].getAudioTracks()[0],
247-
statsReportInterval = 0;
244+
statsReportInterval;
248245

249246
if (!config.webrtc && !config.webrtc.statsReportTimeInterval) {
250247
return;
@@ -258,16 +255,18 @@ RTCPeerConnection.prototype._getStatsWrap = function() {
258255
statsReportInterval = config.webrtc.statsReportTimeInterval * 1000;
259256

260257
var _statsReportCallback = function() {
261-
_getStats(self, function (results) {
258+
_getStats(self, selector,
259+
function (results) {
262260
self.delegate._onCallStatsReport(self.userID, results);
263261
},
264-
selector,
265262
function errorLog(err) {
266-
Helpers.traceError(error.name + ": " + error.message);
263+
Helpers.traceError("_getStats error. " + err.name + ": " + err.message);
267264
}
268265
);
269266
};
270267

268+
Helpers.trace('Stats tracker has been started.');
269+
271270
self.statsReportTimer = setInterval(_statsReportCallback, statsReportInterval);
272271
};
273272

@@ -340,15 +339,18 @@ RTCPeerConnection.prototype._startDialingTimer = function(extension, withOnNotAn
340339
/**
341340
* PRIVATE
342341
*/
343-
function _getStats(peer, cb, selector, errorCallback) {
342+
function _getStats(peer, selector, successCallback, errorCallback) {
343+
344+
// http://stackoverflow.com/questions/25069419/webrtc-getstat-api-set-up
345+
//
344346
if (!!navigator.mozGetUserMedia) {
345347
peer.getStats(selector,
346348
function (res) {
347349
var items = [];
348350
res.forEach(function (result) {
349351
items.push(result);
350352
});
351-
cb(items);
353+
successCallback(items);
352354
},
353355
errorCallback
354356
);
@@ -365,7 +367,7 @@ RTCPeerConnection.prototype._startDialingTimer = function(extension, withOnNotAn
365367
item.timestamp = result.timestamp;
366368
items.push(item);
367369
});
368-
cb(items);
370+
successCallback(items);
369371
});
370372
}
371373
}

0 commit comments

Comments
 (0)