Skip to content

Commit

Permalink
Merge pull request #399 from isymchych/callstats-error-reporting
Browse files Browse the repository at this point in the history
Callstats error reporting. Ivan is going to publish another PR about earlier failures that would apply on top of this one.
  • Loading branch information
yanas committed Nov 10, 2015
2 parents 819f141 + 05b3df0 commit 071fbfb
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 11 deletions.
4 changes: 2 additions & 2 deletions modules/RTC/RTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ var RTC = {
null, null, getMediaStreamUsage());
};

this.rtcUtils = new RTCUtils(this, onReady);
this.rtcUtils = new RTCUtils(this, eventEmitter, onReady);

// Call onReady() if Temasys plugin is not used
if (!RTCBrowserType.isTemasysPluginUsed()) {
Expand Down Expand Up @@ -210,7 +210,7 @@ var RTC = {
APP.xmpp.setVideoMute(false, function(mute) {
eventEmitter.emit(RTCEvents.VIDEO_MUTE, mute);
});

callback();
};
}
Expand Down
6 changes: 5 additions & 1 deletion modules/RTC/RTCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
var RTCBrowserType = require("./RTCBrowserType");
var Resolutions = require("../../service/RTC/Resolutions");
var RTCEvents = require("../../service/RTC/RTCEvents");
var AdapterJS = require("./adapter.screenshare");

var currentResolution = null;
Expand Down Expand Up @@ -153,10 +154,11 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream) {
}


function RTCUtils(RTCService, onTemasysPluginReady)
function RTCUtils(RTCService, eventEmitter, onTemasysPluginReady)
{
var self = this;
this.service = RTCService;
this.eventEmitter = eventEmitter;
if (RTCBrowserType.isFirefox()) {
var FFversion = RTCBrowserType.getFirefoxVersion();
if (FFversion >= 40) {
Expand Down Expand Up @@ -322,12 +324,14 @@ RTCUtils.prototype.getUserMediaWithConstraints = function(
self.setAvailableDevices(um, false);
console.warn('Failed to get access to local media. Error ',
error, constraints);
self.eventEmitter.emit(RTCEvents.GET_USER_MEDIA_FAILED, error);
if (failure_callback) {
failure_callback(error);
}
});
} catch (e) {
console.error('GUM failed: ', e);
self.eventEmitter.emit(RTCEvents.GET_USER_MEDIA_FAILED, e);
if(failure_callback) {
failure_callback(e);
}
Expand Down
102 changes: 98 additions & 4 deletions modules/statistics/CallStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ var jsSHA = require('jssha');
var io = require('socket.io-client');
var callStats = null;

// getUserMedia calls happen before CallStats init
// so if there are any getUserMedia errors, we store them in this array
// and send them to callstats on init
var pendingUserMediaErrors = [];

function initCallback (err, msg) {
console.log("Initializing Status: err="+err+" msg="+msg);
}
Expand Down Expand Up @@ -38,17 +43,25 @@ var CallStats = {
usage,
this.confID,
this.pcCallback.bind(this));

// notify callstats about getUserMedia failures if there were any
if (pendingUserMediaErrors.length) {
pendingUserMediaErrors.forEach(this.sendGetUserMediaFailed, this);
pendingUserMediaErrors.length = 0;
}
},
pcCallback: function (err, msg) {
if (!callStats)
if (!callStats) {
return;
}
console.log("Monitoring status: "+ err + " msg: " + msg);
callStats.sendFabricEvent(this.peerconnection,
callStats.fabricEvent.fabricSetup, this.confID);
},
sendMuteEvent: function (mute, type) {
if (!callStats)
if (!callStats) {
return;
}
var event = null;
if (type === "video") {
event = (mute? callStats.fabricEvent.videoPause :
Expand All @@ -74,7 +87,8 @@ var CallStats = {
callStats.sendFabricEvent(this.peerconnection,
callStats.fabricEvent.fabricSetupFailed, this.confID);
},
/**

/**
* Sends the given feedback through CallStats.
*
* @param overallFeedback an integer between 1 and 5 indicating the
Expand All @@ -93,6 +107,86 @@ var CallStats = {

callStats.sendUserFeedback(
this.confID, feedbackJSON);
},

/**
* Notifies CallStats that getUserMedia failed.
*
* @param {Error} e error to send
*/
sendGetUserMediaFailed: function (e) {
if(!callStats) {
pendingUserMediaErrors.push(e);
return;
}
callStats.reportError(this.peerconnection, this.confID,
callStats.webRTCFunctions.getUserMedia, e);
},

/**
* Notifies CallStats that peer connection failed to create offer.
*
* @param {Error} e error to send
*/
sendCreateOfferFailed: function (e) {
if(!callStats) {
return;
}
callStats.reportError(this.peerconnection, this.confID,
callStats.webRTCFunctions.createOffer, e);
},

/**
* Notifies CallStats that peer connection failed to create answer.
*
* @param {Error} e error to send
*/
sendCreateAnswerFailed: function (e) {
if(!callStats) {
return;
}
callStats.reportError(this.peerconnection, this.confID,
callStats.webRTCFunctions.createAnswer, e);
},

/**
* Notifies CallStats that peer connection failed to set local description.
*
* @param {Error} e error to send
*/
sendSetLocalDescFailed: function (e) {
if(!callStats) {
return;
}
callStats.reportError(this.peerconnection, this.confID,
callStats.webRTCFunctions.setLocalDescription, e);
},

/**
* Notifies CallStats that peer connection failed to set remote description.
*
* @param {Error} e error to send
*/
sendSetRemoteDescFailed: function (e) {
if(!callStats) {
return;
}
callStats.reportError(
this.peerconnection, this.confID,
callStats.webRTCFunctions.setRemoteDescription, e);
},

/**
* Notifies CallStats that peer connection failed to add ICE candidate.
*
* @param {Error} e error to send
*/
sendAddIceCandidateFailed: function (e) {
if(!callStats) {
return;
}
callStats.reportError(this.peerconnection, this.confID,
callStats.webRTCFunctions.addIceCandidate, e);
}
};
module.exports = CallStats;
module.exports = CallStats;
19 changes: 19 additions & 0 deletions modules/statistics/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ var statistics = {
APP.RTC.addListener(RTCEvents.VIDEO_MUTE, function (mute) {
CallStats.sendMuteEvent(mute, "video");
});

APP.RTC.addListener(RTCEvents.GET_USER_MEDIA_FAILED, function (e) {
CallStats.sendGetUserMediaFailed(e);
});
APP.xmpp.addListener(RTCEvents.CREATE_OFFER_FAILED, function (e) {
CallStats.sendCreateOfferFailed(e);
});
APP.xmpp.addListener(RTCEvents.CREATE_ANSWER_FAILED, function (e) {
CallStats.sendCreateAnswerFailed(e);
});
APP.xmpp.addListener(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED, function (e) {
CallStats.sendSetLocalDescFailed(e);
});
APP.xmpp.addListener(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED, function (e) {
CallStats.sendSetRemoteDescFailed(e);
});
APP.xmpp.addListener(RTCEvents.ADD_ICE_CANDIDATE_FAILED, function (e) {
CallStats.sendAddIceCandidateFailed(e);
});
}
};

Expand Down
2 changes: 2 additions & 0 deletions modules/xmpp/JingleSessionPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var SDP = require("./SDP");
var async = require("async");
var transform = require("sdp-transform");
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var RTCEvents = require("../../service/RTC/RTCEvents");
var RTCBrowserType = require("../RTC/RTCBrowserType");
var SSRCReplacement = require("./LocalSSRCReplacement");

Expand Down Expand Up @@ -719,6 +720,7 @@ JingleSessionPC.prototype.addIceCandidate = function (elem) {
self.peerconnection.addIceCandidate(candidate);
} catch (e) {
console.error('addIceCandidate failed', e.toString(), line);
self.eventEmitter.emit(RTCEvents.ADD_ICE_CANDIDATE_FAILED, err);
}
});
});
Expand Down
12 changes: 8 additions & 4 deletions modules/xmpp/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
webkitRTCPeerConnection, RTCSessionDescription */
/* jshint -W101 */
var RTC = require('../RTC/RTC');
var RTCBrowserType = require("../RTC/RTCBrowserType.js");
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var RTCBrowserType = require("../RTC/RTCBrowserType");
var RTCEvents = require("../../service/RTC/RTCEvents");
var SSRCReplacement = require("./LocalSSRCReplacement");

function TraceablePeerConnection(ice_config, constraints, session) {
Expand All @@ -16,6 +16,7 @@ function TraceablePeerConnection(ice_config, constraints, session) {
} else {
RTCPeerConnectionType = webkitRTCPeerConnection;
}
self.eventEmitter = session.eventEmitter;
this.peerconnection = new RTCPeerConnectionType(ice_config, constraints);
this.updateLog = [];
this.stats = {};
Expand Down Expand Up @@ -218,7 +219,7 @@ if (TraceablePeerConnection.prototype.__defineGetter__ !== undefined) {
var desc = this.peerconnection.localDescription;

desc = SSRCReplacement.mungeLocalVideoSSRC(desc);

this.trace('getLocalDescription::preTransform', dumpSDP(desc));

// if we're running on FF, transform to Plan B first.
Expand Down Expand Up @@ -292,6 +293,7 @@ TraceablePeerConnection.prototype.setLocalDescription
},
function (err) {
self.trace('setLocalDescriptionOnFailure', err);
self.eventEmitter.emit(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED, err);
failureCallback(err);
}
);
Expand Down Expand Up @@ -327,6 +329,7 @@ TraceablePeerConnection.prototype.setRemoteDescription
},
function (err) {
self.trace('setRemoteDescriptionOnFailure', err);
self.eventEmitter.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED, err);
failureCallback(err);
}
);
Expand Down Expand Up @@ -372,6 +375,7 @@ TraceablePeerConnection.prototype.createOffer
},
function(err) {
self.trace('createOfferOnFailure', err);
self.eventEmitter.emit(RTCEvents.CREATE_OFFER_FAILED, err);
failureCallback(err);
},
constraints
Expand Down Expand Up @@ -402,6 +406,7 @@ TraceablePeerConnection.prototype.createAnswer
},
function(err) {
self.trace('createAnswerOnFailure', err);
self.eventEmitter.emit(RTCEvents.CREATE_ANSWER_FAILED, err);
failureCallback(err);
},
constraints
Expand Down Expand Up @@ -440,4 +445,3 @@ TraceablePeerConnection.prototype.getStats = function(callback, errback) {
};

module.exports = TraceablePeerConnection;

6 changes: 6 additions & 0 deletions service/RTC/RTCEvents.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
var RTCEvents = {
RTC_READY: "rtc.ready",
DATA_CHANNEL_OPEN: "rtc.data_channel_open",
CREATE_OFFER_FAILED: "rtc.create_offer_failed",
CREATE_ANSWER_FAILED: "rtc.create_answer_failed",
SET_LOCAL_DESCRIPTION_FAILED: "rtc.set_local_description_failed",
SET_REMOTE_DESCRIPTION_FAILED: "rtc.set_remote_description_failed",
ADD_ICE_CANDIDATE_FAILED: "rtc.add_ice_candidate_failed",
GET_USER_MEDIA_FAILED: "rtc.get_user_media_failed",
LASTN_CHANGED: "rtc.lastn_changed",
DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
Expand Down

0 comments on commit 071fbfb

Please sign in to comment.