|
|
@@ -5519,10 +5519,50 @@ var wrtcFuncNames = {
|
|
5519
|
5519
|
getUserMedia: "getUserMedia"
|
|
5520
|
5520
|
};
|
|
5521
|
5521
|
|
|
|
5522
|
+/**
|
|
|
5523
|
+ * @const
|
|
|
5524
|
+ * @see http://www.callstats.io/api/#enumeration-of-fabricevent
|
|
|
5525
|
+ */
|
|
|
5526
|
+var fabricEvent = {
|
|
|
5527
|
+ fabricSetupFailed:"fabricSetupFailed",
|
|
|
5528
|
+ fabricHold:"fabricHold",
|
|
|
5529
|
+ fabricResume:"fabricResume",
|
|
|
5530
|
+ audioMute:"audioMute",
|
|
|
5531
|
+ audioUnmute:"audioUnmute",
|
|
|
5532
|
+ videoPause:"videoPause",
|
|
|
5533
|
+ videoResume:"videoResume",
|
|
|
5534
|
+ fabricUsageEvent:"fabricUsageEvent",
|
|
|
5535
|
+ fabricStats:"fabricStats",
|
|
|
5536
|
+ fabricTerminated:"fabricTerminated"
|
|
|
5537
|
+};
|
|
|
5538
|
+
|
|
5522
|
5539
|
var callStats = null;
|
|
5523
|
5540
|
|
|
5524
|
5541
|
function initCallback (err, msg) {
|
|
5525
|
5542
|
logger.log("CallStats Status: err=" + err + " msg=" + msg);
|
|
|
5543
|
+
|
|
|
5544
|
+ // there is no lib, nothing to report to
|
|
|
5545
|
+ if (err !== 'success')
|
|
|
5546
|
+ return;
|
|
|
5547
|
+
|
|
|
5548
|
+ // notify callstats about failures if there were any
|
|
|
5549
|
+ if (CallStats.reportsQueue.length) {
|
|
|
5550
|
+ CallStats.reportsQueue.forEach(function (report) {
|
|
|
5551
|
+ if (report.type === reportType.ERROR)
|
|
|
5552
|
+ {
|
|
|
5553
|
+ var error = report.data;
|
|
|
5554
|
+ CallStats._reportError.call(this, error.type, error.error,
|
|
|
5555
|
+ error.pc);
|
|
|
5556
|
+ }
|
|
|
5557
|
+ else if (report.type === reportType.EVENT)
|
|
|
5558
|
+ {
|
|
|
5559
|
+ var data = report.data;
|
|
|
5560
|
+ callStats.sendFabricEvent(
|
|
|
5561
|
+ this.peerconnection, data.event, this.confID);
|
|
|
5562
|
+ }
|
|
|
5563
|
+ }, this);
|
|
|
5564
|
+ CallStats.reportsQueue.length = 0;
|
|
|
5565
|
+ }
|
|
5526
|
5566
|
}
|
|
5527
|
5567
|
|
|
5528
|
5568
|
/**
|
|
|
@@ -5572,7 +5612,7 @@ var CallStats = _try_catch(function(jingleSession, Settings, options) {
|
|
5572
|
5612
|
callStats.initialize(options.callStatsID,
|
|
5573
|
5613
|
options.callStatsSecret,
|
|
5574
|
5614
|
this.userID,
|
|
5575
|
|
- initCallback);
|
|
|
5615
|
+ initCallback.bind(this));
|
|
5576
|
5616
|
|
|
5577
|
5617
|
callStats.addNewFabric(this.peerconnection,
|
|
5578
|
5618
|
Strophe.getResourceFromJid(jingleSession.peerjid),
|
|
|
@@ -5586,28 +5626,27 @@ var CallStats = _try_catch(function(jingleSession, Settings, options) {
|
|
5586
|
5626
|
callStats = null;
|
|
5587
|
5627
|
logger.error(e);
|
|
5588
|
5628
|
}
|
|
5589
|
|
- // notify callstats about failures if there were any
|
|
5590
|
|
- if (CallStats.pendingErrors.length) {
|
|
5591
|
|
- CallStats.pendingErrors.forEach(function (error) {
|
|
5592
|
|
- CallStats._reportError.call(this, error.type, error.error,
|
|
5593
|
|
- error.pc);
|
|
5594
|
|
- }, this);
|
|
5595
|
|
- CallStats.pendingErrors.length = 0;
|
|
5596
|
|
- }
|
|
5597
|
5629
|
});
|
|
5598
|
5630
|
|
|
5599
|
|
-// some errors may happen before CallStats init
|
|
|
5631
|
+// some errors/events may happen before CallStats init
|
|
5600
|
5632
|
// in this case we accumulate them in this array
|
|
5601
|
5633
|
// and send them to callstats on init
|
|
5602
|
|
-CallStats.pendingErrors = [];
|
|
|
5634
|
+CallStats.reportsQueue = [];
|
|
|
5635
|
+
|
|
|
5636
|
+/**
|
|
|
5637
|
+ * Type of pending reports, can be event or an error.
|
|
|
5638
|
+ * @type {{ERROR: string, EVENT: string}}
|
|
|
5639
|
+ */
|
|
|
5640
|
+var reportType = {
|
|
|
5641
|
+ ERROR: "error",
|
|
|
5642
|
+ EVENT: "event"
|
|
|
5643
|
+};
|
|
5603
|
5644
|
|
|
5604
|
5645
|
CallStats.prototype.pcCallback = _try_catch(function (err, msg) {
|
|
5605
|
5646
|
if (!callStats) {
|
|
5606
|
5647
|
return;
|
|
5607
|
5648
|
}
|
|
5608
|
5649
|
logger.log("Monitoring status: "+ err + " msg: " + msg);
|
|
5609
|
|
- callStats.sendFabricEvent(this.peerconnection,
|
|
5610
|
|
- callStats.fabricEvent.fabricSetup, this.confID);
|
|
5611
|
5650
|
});
|
|
5612
|
5651
|
|
|
5613
|
5652
|
/**
|
|
|
@@ -5615,22 +5654,38 @@ CallStats.prototype.pcCallback = _try_catch(function (err, msg) {
|
|
5615
|
5654
|
* @param mute {boolean} true for muted and false for not muted
|
|
5616
|
5655
|
* @param type {String} "audio"/"video"
|
|
5617
|
5656
|
*/
|
|
5618
|
|
-CallStats.prototype.sendMuteEvent = _try_catch(function (mute, type) {
|
|
5619
|
|
- if (!callStats) {
|
|
5620
|
|
- return;
|
|
5621
|
|
- }
|
|
|
5657
|
+CallStats.sendMuteEvent = _try_catch(function (mute, type, cs) {
|
|
|
5658
|
+
|
|
5622
|
5659
|
var event = null;
|
|
5623
|
5660
|
if (type === "video") {
|
|
5624
|
|
- event = (mute? callStats.fabricEvent.videoPause :
|
|
5625
|
|
- callStats.fabricEvent.videoResume);
|
|
|
5661
|
+ event = (mute? fabricEvent.videoPause : fabricEvent.videoResume);
|
|
5626
|
5662
|
}
|
|
5627
|
5663
|
else {
|
|
5628
|
|
- event = (mute? callStats.fabricEvent.audioMute :
|
|
5629
|
|
- callStats.fabricEvent.audioUnmute);
|
|
|
5664
|
+ event = (mute? fabricEvent.audioMute : fabricEvent.audioUnmute);
|
|
5630
|
5665
|
}
|
|
5631
|
|
- callStats.sendFabricEvent(this.peerconnection, event, this.confID);
|
|
|
5666
|
+
|
|
|
5667
|
+ CallStats._reportEvent.call(cs, event);
|
|
5632
|
5668
|
});
|
|
5633
|
5669
|
|
|
|
5670
|
+/**
|
|
|
5671
|
+ * Reports an error to callstats.
|
|
|
5672
|
+ *
|
|
|
5673
|
+ * @param type the type of the error, which will be one of the wrtcFuncNames
|
|
|
5674
|
+ * @param e the error
|
|
|
5675
|
+ * @param pc the peerconnection
|
|
|
5676
|
+ * @private
|
|
|
5677
|
+ */
|
|
|
5678
|
+CallStats._reportEvent = function (event) {
|
|
|
5679
|
+ if (callStats) {
|
|
|
5680
|
+ callStats.sendFabricEvent(this.peerconnection, event, this.confID);
|
|
|
5681
|
+ } else {
|
|
|
5682
|
+ CallStats.reportsQueue.push({
|
|
|
5683
|
+ type: reportType.EVENT,
|
|
|
5684
|
+ data: {event: event}
|
|
|
5685
|
+ });
|
|
|
5686
|
+ }
|
|
|
5687
|
+};
|
|
|
5688
|
+
|
|
5634
|
5689
|
/**
|
|
5635
|
5690
|
* Notifies CallStats for connection setup errors
|
|
5636
|
5691
|
*/
|
|
|
@@ -5686,7 +5741,10 @@ CallStats._reportError = function (type, e, pc) {
|
|
5686
|
5741
|
if (callStats) {
|
|
5687
|
5742
|
callStats.reportError(pc, this.confID, type, e);
|
|
5688
|
5743
|
} else {
|
|
5689
|
|
- CallStats.pendingErrors.push({ type: type, error: e, pc: pc});
|
|
|
5744
|
+ CallStats.reportsQueue.push({
|
|
|
5745
|
+ type: reportType.ERROR,
|
|
|
5746
|
+ data: { type: type, error: e, pc: pc}
|
|
|
5747
|
+ });
|
|
5690
|
5748
|
}
|
|
5691
|
5749
|
// else just ignore it
|
|
5692
|
5750
|
};
|
|
|
@@ -6801,8 +6859,8 @@ Statistics.prototype.sendSetupFailedEvent = function () {
|
|
6801
|
6859
|
* @param type {String} "audio"/"video"
|
|
6802
|
6860
|
*/
|
|
6803
|
6861
|
Statistics.prototype.sendMuteEvent = function (muted, type) {
|
|
6804
|
|
- if(this.callStatsIntegrationEnabled && this.callstats)
|
|
6805
|
|
- this.callstats.sendMuteEvent(muted, type);
|
|
|
6862
|
+ if(this.callStatsIntegrationEnabled)
|
|
|
6863
|
+ CallStats.sendMuteEvent(muted, type, this.callstats);
|
|
6806
|
6864
|
}
|
|
6807
|
6865
|
|
|
6808
|
6866
|
/**
|