|
@@ -20,7 +20,7 @@ var wrtcFuncNames = {
|
20
|
20
|
getUserMedia: "getUserMedia",
|
21
|
21
|
iceConnectionFailure: "iceConnectionFailure",
|
22
|
22
|
signalingError: "signalingError",
|
23
|
|
- applicationError: "applicationError"
|
|
23
|
+ applicationLog: "applicationLog"
|
24
|
24
|
};
|
25
|
25
|
|
26
|
26
|
/**
|
|
@@ -41,7 +41,8 @@ var fabricEvent = {
|
41
|
41
|
fabricTerminated:"fabricTerminated",
|
42
|
42
|
screenShareStart:"screenShareStart",
|
43
|
43
|
screenShareStop:"screenShareStop",
|
44
|
|
- dominantSpeaker:"dominantSpeaker"
|
|
44
|
+ dominantSpeaker:"dominantSpeaker",
|
|
45
|
+ activeDeviceList:"activeDeviceList"
|
45
|
46
|
};
|
46
|
47
|
|
47
|
48
|
var callStats = null;
|
|
@@ -53,20 +54,47 @@ function initCallback (err, msg) {
|
53
|
54
|
if (err !== 'success')
|
54
|
55
|
return;
|
55
|
56
|
|
|
57
|
+ CallStats.initialized = true;
|
|
58
|
+
|
|
59
|
+ var ret = callStats.addNewFabric(this.peerconnection,
|
|
60
|
+ Strophe.getResourceFromJid(this.session.peerjid),
|
|
61
|
+ callStats.fabricUsage.multiplex,
|
|
62
|
+ this.confID,
|
|
63
|
+ this.pcCallback.bind(this));
|
|
64
|
+
|
|
65
|
+ var fabricInitialized = (ret.status === 'success');
|
|
66
|
+
|
|
67
|
+ if(!fabricInitialized)
|
|
68
|
+ console.log("callstats fabric not initilized", ret.message);
|
|
69
|
+
|
56
|
70
|
// notify callstats about failures if there were any
|
57
|
71
|
if (CallStats.reportsQueue.length) {
|
58
|
72
|
CallStats.reportsQueue.forEach(function (report) {
|
59
|
|
- if (report.type === reportType.ERROR)
|
60
|
|
- {
|
|
73
|
+ if (report.type === reportType.ERROR) {
|
61
|
74
|
var error = report.data;
|
62
|
75
|
CallStats._reportError.call(this, error.type, error.error,
|
63
|
76
|
error.pc);
|
64
|
77
|
}
|
65
|
|
- else if (report.type === reportType.EVENT)
|
66
|
|
- {
|
67
|
|
- var data = report.data;
|
|
78
|
+ // if we have and event to report and we failed to add fabric
|
|
79
|
+ // this event will not be reported anyway, returning an error
|
|
80
|
+ else if (report.type === reportType.EVENT
|
|
81
|
+ && fabricInitialized) {
|
|
82
|
+ var eventData = report.data;
|
68
|
83
|
callStats.sendFabricEvent(
|
69
|
|
- this.peerconnection, data.event, this.confID);
|
|
84
|
+ this.peerconnection,
|
|
85
|
+ eventData.event,
|
|
86
|
+ this.confID,
|
|
87
|
+ eventData.eventData);
|
|
88
|
+ } else if (report.type === reportType.MST_WITH_USERID) {
|
|
89
|
+ var data = report.data;
|
|
90
|
+ callStats.associateMstWithUserID(
|
|
91
|
+ this.peerconnection,
|
|
92
|
+ data.callStatsId,
|
|
93
|
+ this.confID,
|
|
94
|
+ data.ssrc,
|
|
95
|
+ data.usageLabel,
|
|
96
|
+ data.containerId
|
|
97
|
+ );
|
70
|
98
|
}
|
71
|
99
|
}, this);
|
72
|
100
|
CallStats.reportsQueue.length = 0;
|
|
@@ -123,11 +151,6 @@ var CallStats = _try_catch(function(jingleSession, Settings, options) {
|
123
|
151
|
this.userID,
|
124
|
152
|
initCallback.bind(this));
|
125
|
153
|
|
126
|
|
- callStats.addNewFabric(this.peerconnection,
|
127
|
|
- Strophe.getResourceFromJid(jingleSession.peerjid),
|
128
|
|
- callStats.fabricUsage.multiplex,
|
129
|
|
- this.confID,
|
130
|
|
- this.pcCallback.bind(this));
|
131
|
154
|
} catch (e) {
|
132
|
155
|
// The callstats.io API failed to initialize (e.g. because its
|
133
|
156
|
// download failed to succeed in general or on time). Further
|
|
@@ -143,13 +166,21 @@ var CallStats = _try_catch(function(jingleSession, Settings, options) {
|
143
|
166
|
// and send them to callstats on init
|
144
|
167
|
CallStats.reportsQueue = [];
|
145
|
168
|
|
|
169
|
+/**
|
|
170
|
+ * Whether the library was successfully initialized using its initialize method.
|
|
171
|
+ * And whether we had successfully called addNewFabric.
|
|
172
|
+ * @type {boolean}
|
|
173
|
+ */
|
|
174
|
+CallStats.initialized = false;
|
|
175
|
+
|
146
|
176
|
/**
|
147
|
177
|
* Type of pending reports, can be event or an error.
|
148
|
178
|
* @type {{ERROR: string, EVENT: string}}
|
149
|
179
|
*/
|
150
|
180
|
var reportType = {
|
151
|
181
|
ERROR: "error",
|
152
|
|
- EVENT: "event"
|
|
182
|
+ EVENT: "event",
|
|
183
|
+ MST_WITH_USERID: "mstWithUserID"
|
153
|
184
|
};
|
154
|
185
|
|
155
|
186
|
CallStats.prototype.pcCallback = _try_catch(function (err, msg) {
|
|
@@ -162,6 +193,7 @@ CallStats.prototype.pcCallback = _try_catch(function (err, msg) {
|
162
|
193
|
/**
|
163
|
194
|
* Lets CallStats module know where is given SSRC rendered by providing renderer
|
164
|
195
|
* tag ID.
|
|
196
|
+ * If the lib is not initialized yet queue the call for later, when its ready.
|
165
|
197
|
* @param ssrc {number} the SSRC of the stream
|
166
|
198
|
* @param isLocal {boolean} <tt>true<tt> if this stream is local or
|
167
|
199
|
* <tt>false</tt> otherwise.
|
|
@@ -191,14 +223,27 @@ function (ssrc, isLocal, usageLabel, containerId) {
|
191
|
223
|
usageLabel,
|
192
|
224
|
containerId
|
193
|
225
|
);
|
194
|
|
- callStats.associateMstWithUserID(
|
195
|
|
- this.peerconnection,
|
196
|
|
- callStatsId,
|
197
|
|
- this.confID,
|
198
|
|
- ssrc,
|
199
|
|
- usageLabel,
|
200
|
|
- containerId
|
201
|
|
- );
|
|
226
|
+ if(CallStats.initialized) {
|
|
227
|
+ callStats.associateMstWithUserID(
|
|
228
|
+ this.peerconnection,
|
|
229
|
+ callStatsId,
|
|
230
|
+ this.confID,
|
|
231
|
+ ssrc,
|
|
232
|
+ usageLabel,
|
|
233
|
+ containerId
|
|
234
|
+ );
|
|
235
|
+ }
|
|
236
|
+ else {
|
|
237
|
+ CallStats.reportsQueue.push({
|
|
238
|
+ type: reportType.MST_WITH_USERID,
|
|
239
|
+ data: {
|
|
240
|
+ callStatsId: callStatsId,
|
|
241
|
+ ssrc: ssrc,
|
|
242
|
+ usageLabel: usageLabel,
|
|
243
|
+ containerId: containerId
|
|
244
|
+ }
|
|
245
|
+ });
|
|
246
|
+ }
|
202
|
247
|
}).bind(this)();
|
203
|
248
|
};
|
204
|
249
|
|
|
@@ -206,6 +251,7 @@ function (ssrc, isLocal, usageLabel, containerId) {
|
206
|
251
|
* Notifies CallStats for mute events
|
207
|
252
|
* @param mute {boolean} true for muted and false for not muted
|
208
|
253
|
* @param type {String} "audio"/"video"
|
|
254
|
+ * @param {CallStats} cs callstats instance related to the event
|
209
|
255
|
*/
|
210
|
256
|
CallStats.sendMuteEvent = _try_catch(function (mute, type, cs) {
|
211
|
257
|
|
|
@@ -224,6 +270,7 @@ CallStats.sendMuteEvent = _try_catch(function (mute, type, cs) {
|
224
|
270
|
* Notifies CallStats for screen sharing events
|
225
|
271
|
* @param start {boolean} true for starting screen sharing and
|
226
|
272
|
* false for not stopping
|
|
273
|
+ * @param {CallStats} cs callstats instance related to the event
|
227
|
274
|
*/
|
228
|
275
|
CallStats.sendScreenSharingEvent = _try_catch(function (start, cs) {
|
229
|
276
|
|
|
@@ -233,6 +280,7 @@ CallStats.sendScreenSharingEvent = _try_catch(function (start, cs) {
|
233
|
280
|
|
234
|
281
|
/**
|
235
|
282
|
* Notifies CallStats that we are the new dominant speaker in the conference.
|
|
283
|
+ * @param {CallStats} cs callstats instance related to the event
|
236
|
284
|
*/
|
237
|
285
|
CallStats.sendDominantSpeakerEvent = _try_catch(function (cs) {
|
238
|
286
|
|
|
@@ -240,21 +288,33 @@ CallStats.sendDominantSpeakerEvent = _try_catch(function (cs) {
|
240
|
288
|
fabricEvent.dominantSpeaker);
|
241
|
289
|
});
|
242
|
290
|
|
|
291
|
+/**
|
|
292
|
+ * Notifies CallStats about active device.
|
|
293
|
+ * @param {{deviceList: {String:String}}} list of devices with their data
|
|
294
|
+ * @param {CallStats} cs callstats instance related to the event
|
|
295
|
+ */
|
|
296
|
+CallStats.sendАctiveDeviceListEvent = _try_catch(function (devicesData, cs) {
|
|
297
|
+
|
|
298
|
+ CallStats._reportEvent.call(cs, fabricEvent.activeDeviceList, devicesData);
|
|
299
|
+});
|
|
300
|
+
|
243
|
301
|
/**
|
244
|
302
|
* Reports an error to callstats.
|
245
|
303
|
*
|
246
|
304
|
* @param type the type of the error, which will be one of the wrtcFuncNames
|
247
|
305
|
* @param e the error
|
248
|
306
|
* @param pc the peerconnection
|
|
307
|
+ * @param eventData additional data to pass to event
|
249
|
308
|
* @private
|
250
|
309
|
*/
|
251
|
|
-CallStats._reportEvent = function (event) {
|
252
|
|
- if (callStats) {
|
253
|
|
- callStats.sendFabricEvent(this.peerconnection, event, this.confID);
|
|
310
|
+CallStats._reportEvent = function (event, eventData) {
|
|
311
|
+ if (CallStats.initialized) {
|
|
312
|
+ callStats.sendFabricEvent(
|
|
313
|
+ this.peerconnection, event, this.confID, eventData);
|
254
|
314
|
} else {
|
255
|
315
|
CallStats.reportsQueue.push({
|
256
|
316
|
type: reportType.EVENT,
|
257
|
|
- data: {event: event}
|
|
317
|
+ data: {event: event, eventData: eventData}
|
258
|
318
|
});
|
259
|
319
|
}
|
260
|
320
|
};
|
|
@@ -263,7 +323,7 @@ CallStats._reportEvent = function (event) {
|
263
|
323
|
* Notifies CallStats for connection setup errors
|
264
|
324
|
*/
|
265
|
325
|
CallStats.prototype.sendTerminateEvent = _try_catch(function () {
|
266
|
|
- if(!callStats) {
|
|
326
|
+ if(!CallStats.initialized) {
|
267
|
327
|
return;
|
268
|
328
|
}
|
269
|
329
|
callStats.sendFabricEvent(this.peerconnection,
|
|
@@ -289,7 +349,7 @@ CallStats.prototype.sendIceConnectionFailedEvent = _try_catch(function (pc, cs){
|
289
|
349
|
*/
|
290
|
350
|
CallStats.prototype.sendFeedback = _try_catch(
|
291
|
351
|
function(overallFeedback, detailedFeedback) {
|
292
|
|
- if(!callStats) {
|
|
352
|
+ if(!CallStats.initialized) {
|
293
|
353
|
return;
|
294
|
354
|
}
|
295
|
355
|
var feedbackString = '{"userID":"' + this.userID + '"' +
|
|
@@ -314,7 +374,7 @@ CallStats._reportError = function (type, e, pc) {
|
314
|
374
|
logger.warn("No error is passed!");
|
315
|
375
|
e = new Error("Unknown error");
|
316
|
376
|
}
|
317
|
|
- if (callStats) {
|
|
377
|
+ if (CallStats.initialized) {
|
318
|
378
|
callStats.reportError(pc, this.confID, type, e);
|
319
|
379
|
} else {
|
320
|
380
|
CallStats.reportsQueue.push({
|
|
@@ -391,15 +451,14 @@ CallStats.sendAddIceCandidateFailed = _try_catch(function (e, pc, cs) {
|
391
|
451
|
});
|
392
|
452
|
|
393
|
453
|
/**
|
394
|
|
- * Notifies CallStats that there is an unhandled error on the page.
|
|
454
|
+ * Notifies CallStats that there is a log we want to report.
|
395
|
455
|
*
|
396
|
|
- * @param {Error} e error to send
|
397
|
|
- * @param {RTCPeerConnection} pc connection on which failure occured.
|
|
456
|
+ * @param {Error} e error to send or {String} message
|
398
|
457
|
* @param {CallStats} cs callstats instance related to the error (optional)
|
399
|
458
|
*/
|
400
|
|
-CallStats.sendUnhandledError = _try_catch(function (e, cs) {
|
|
459
|
+CallStats.sendApplicationLog = _try_catch(function (e, cs) {
|
401
|
460
|
CallStats._reportError
|
402
|
|
- .call(cs, wrtcFuncNames.applicationError, e, null);
|
|
461
|
+ .call(cs, wrtcFuncNames.applicationLog, e, null);
|
403
|
462
|
});
|
404
|
463
|
|
405
|
464
|
module.exports = CallStats;
|