@flashphoner/websdk 2.0.265 → 2.0.267
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docTemplate/README.md +1 -1
- package/examples/demo/streaming/media_devices_manager/manager.js +1 -1
- package/examples/demo/streaming/screen-camera-mixer/screen-camera-mixer.js +1 -1
- package/flashphoner-no-flash.js +316 -84
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +316 -84
- package/flashphoner-no-webrtc.min.js +2 -2
- package/flashphoner-no-wsplayer.js +316 -84
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-room-api-webrtc-only.js +314 -82
- package/flashphoner-room-api-webrtc-only.min.js +1 -1
- package/flashphoner-room-api.js +168 -26
- package/flashphoner-room-api.min.js +4 -4
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +316 -84
- package/flashphoner-temasys-flash-websocket.js +316 -84
- package/flashphoner-temasys-flash-websocket.min.js +1 -1
- package/flashphoner-webrtc-only.js +314 -82
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +316 -84
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/media-source-media-provider.js +4 -4
- package/src/stats-collector.js +164 -22
|
@@ -11024,6 +11024,10 @@ module.exports = {
|
|
|
11024
11024
|
'use strict';
|
|
11025
11025
|
|
|
11026
11026
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11027
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
11028
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11029
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11030
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11027
11031
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
11028
11032
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11029
11033
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -11033,14 +11037,25 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.
|
|
|
11033
11037
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
11034
11038
|
var util = require('./util');
|
|
11035
11039
|
var LOG_PREFIX = "stats-collector";
|
|
11040
|
+
var CONNECTION_TYPE = {
|
|
11041
|
+
WEBSOCKET: "ws",
|
|
11042
|
+
HTTP: "http"
|
|
11043
|
+
};
|
|
11044
|
+
var MAX_SEND_ERRORS = 3;
|
|
11045
|
+
var CONNECTION_STATUS = {
|
|
11046
|
+
INIT: 0,
|
|
11047
|
+
OK: 200,
|
|
11048
|
+
BAD_REQUEST: 400,
|
|
11049
|
+
INTERNAL_SERVER_ERROR: 500
|
|
11050
|
+
};
|
|
11036
11051
|
|
|
11037
11052
|
// Collect and send WebRTC statistics periodically
|
|
11038
|
-
var StreamStatsCollector = function StreamStatsCollector(description, id, mediaConnection, wsConnection, logger) {
|
|
11053
|
+
var StreamStatsCollector = function StreamStatsCollector(description, id, mediaConnection, wsConnection, logger, maxErrors) {
|
|
11039
11054
|
var statCollector = {
|
|
11040
11055
|
description: description,
|
|
11041
11056
|
id: id,
|
|
11042
11057
|
mediaConnection: mediaConnection,
|
|
11043
|
-
|
|
11058
|
+
connection: Connection(wsConnection, maxErrors),
|
|
11044
11059
|
logger: getLogger(logger),
|
|
11045
11060
|
headers: "",
|
|
11046
11061
|
compression: "none",
|
|
@@ -11050,7 +11065,7 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11050
11065
|
timerBusy: false,
|
|
11051
11066
|
start: function () {
|
|
11052
11067
|
var _start = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
11053
|
-
var error;
|
|
11068
|
+
var error, authHeader;
|
|
11054
11069
|
return _regenerator().w(function (_context) {
|
|
11055
11070
|
while (1) switch (_context.n) {
|
|
11056
11071
|
case 0:
|
|
@@ -11079,19 +11094,25 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11079
11094
|
}
|
|
11080
11095
|
throw new Error(error + "no media connection available");
|
|
11081
11096
|
case 4:
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11097
|
+
statCollector.logger.debug(LOG_PREFIX, "RTCMetricsServerDescription: " + JSON.stringify(statCollector.description));
|
|
11098
|
+
if (statCollector.description.ingestPoint) {
|
|
11099
|
+
authHeader = null;
|
|
11100
|
+
if (statCollector.description.authorization) {
|
|
11101
|
+
authHeader = {
|
|
11102
|
+
Authorization: statCollector.description.authorization
|
|
11103
|
+
};
|
|
11104
|
+
}
|
|
11105
|
+
statCollector.connection.setUp(statCollector.description.ingestPoint, authHeader);
|
|
11085
11106
|
}
|
|
11086
|
-
|
|
11107
|
+
_context.n = 5;
|
|
11108
|
+
return statCollector.updateHeaders();
|
|
11087
11109
|
case 5:
|
|
11088
11110
|
_context.n = 6;
|
|
11089
|
-
return statCollector.
|
|
11111
|
+
return statCollector.updateCompression();
|
|
11090
11112
|
case 6:
|
|
11091
11113
|
_context.n = 7;
|
|
11092
|
-
return statCollector.
|
|
11114
|
+
return statCollector.sendHeaders();
|
|
11093
11115
|
case 7:
|
|
11094
|
-
statCollector.sendHeaders();
|
|
11095
11116
|
if (statCollector.description.collect === "on") {
|
|
11096
11117
|
statCollector.collect(true);
|
|
11097
11118
|
}
|
|
@@ -11106,7 +11127,7 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11106
11127
|
return start;
|
|
11107
11128
|
}(),
|
|
11108
11129
|
collect: function collect(enable) {
|
|
11109
|
-
if (enable) {
|
|
11130
|
+
if (enable && statCollector.connection.status === CONNECTION_STATUS.OK) {
|
|
11110
11131
|
statCollector.startTimer();
|
|
11111
11132
|
} else {
|
|
11112
11133
|
statCollector.stopTimer();
|
|
@@ -11126,15 +11147,12 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11126
11147
|
_context2.n = 1;
|
|
11127
11148
|
break;
|
|
11128
11149
|
}
|
|
11129
|
-
if (!statCollector.logger) {
|
|
11130
|
-
_context2.n = 1;
|
|
11131
|
-
break;
|
|
11132
|
-
}
|
|
11133
11150
|
statCollector.logger.error(LOG_PREFIX + "-" + statCollector.id, "Can't update WebRTC metrics sending: no parameters passed");
|
|
11134
11151
|
return _context2.a(2);
|
|
11135
11152
|
case 1:
|
|
11153
|
+
statCollector.logger.debug(LOG_PREFIX, "New RTCMetricsServerDescription: " + JSON.stringify(description));
|
|
11136
11154
|
if (!(description.types || description.compression)) {
|
|
11137
|
-
_context2.n =
|
|
11155
|
+
_context2.n = 6;
|
|
11138
11156
|
break;
|
|
11139
11157
|
}
|
|
11140
11158
|
statCollector.stop();
|
|
@@ -11154,12 +11172,20 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11154
11172
|
_context2.n = 3;
|
|
11155
11173
|
return statCollector.updateCompression();
|
|
11156
11174
|
case 3:
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
break;
|
|
11175
|
+
_context2.n = 4;
|
|
11176
|
+
return statCollector.sendHeaders();
|
|
11160
11177
|
case 4:
|
|
11161
|
-
statCollector.
|
|
11178
|
+
if (!(statCollector.connection.status !== CONNECTION_STATUS.OK)) {
|
|
11179
|
+
_context2.n = 5;
|
|
11180
|
+
break;
|
|
11181
|
+
}
|
|
11182
|
+
return _context2.a(2);
|
|
11162
11183
|
case 5:
|
|
11184
|
+
_context2.n = 7;
|
|
11185
|
+
break;
|
|
11186
|
+
case 6:
|
|
11187
|
+
statCollector.collect(false);
|
|
11188
|
+
case 7:
|
|
11163
11189
|
if (description.batchSize) {
|
|
11164
11190
|
statCollector.description.batchSize = description.batchSize;
|
|
11165
11191
|
}
|
|
@@ -11170,15 +11196,15 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11170
11196
|
statCollector.description.collect = description.collect;
|
|
11171
11197
|
}
|
|
11172
11198
|
_t = statCollector.description.collect;
|
|
11173
|
-
_context2.n = _t === "on" ?
|
|
11199
|
+
_context2.n = _t === "on" ? 8 : _t === "off" ? 9 : 10;
|
|
11174
11200
|
break;
|
|
11175
|
-
case
|
|
11201
|
+
case 8:
|
|
11176
11202
|
statCollector.collect(true);
|
|
11177
|
-
return _context2.a(3,
|
|
11178
|
-
case
|
|
11203
|
+
return _context2.a(3, 10);
|
|
11204
|
+
case 9:
|
|
11179
11205
|
statCollector.collect(false);
|
|
11180
|
-
return _context2.a(3,
|
|
11181
|
-
case
|
|
11206
|
+
return _context2.a(3, 10);
|
|
11207
|
+
case 10:
|
|
11182
11208
|
return _context2.a(2);
|
|
11183
11209
|
}
|
|
11184
11210
|
}, _callee2);
|
|
@@ -11362,23 +11388,56 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11362
11388
|
}
|
|
11363
11389
|
return checkForCompression;
|
|
11364
11390
|
}(),
|
|
11365
|
-
sendHeaders: function
|
|
11366
|
-
var
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11391
|
+
sendHeaders: function () {
|
|
11392
|
+
var _sendHeaders = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
11393
|
+
var data;
|
|
11394
|
+
return _regenerator().w(function (_context6) {
|
|
11395
|
+
while (1) switch (_context6.n) {
|
|
11396
|
+
case 0:
|
|
11397
|
+
data = {
|
|
11398
|
+
mediaSessionId: statCollector.id,
|
|
11399
|
+
compression: statCollector.compression,
|
|
11400
|
+
headers: statCollector.headers
|
|
11401
|
+
};
|
|
11402
|
+
_context6.n = 1;
|
|
11403
|
+
return statCollector.send("webRTCMetricsClientDescription", data);
|
|
11404
|
+
case 1:
|
|
11405
|
+
return _context6.a(2);
|
|
11406
|
+
}
|
|
11407
|
+
}, _callee6);
|
|
11408
|
+
}));
|
|
11409
|
+
function sendHeaders() {
|
|
11410
|
+
return _sendHeaders.apply(this, arguments);
|
|
11380
11411
|
}
|
|
11381
|
-
|
|
11412
|
+
return sendHeaders;
|
|
11413
|
+
}(),
|
|
11414
|
+
send: function () {
|
|
11415
|
+
var _send = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(message, data) {
|
|
11416
|
+
return _regenerator().w(function (_context7) {
|
|
11417
|
+
while (1) switch (_context7.n) {
|
|
11418
|
+
case 0:
|
|
11419
|
+
if (!(statCollector.connection.status === CONNECTION_STATUS.INIT || statCollector.connection.status === CONNECTION_STATUS.OK)) {
|
|
11420
|
+
_context7.n = 2;
|
|
11421
|
+
break;
|
|
11422
|
+
}
|
|
11423
|
+
statCollector.logger.debug(LOG_PREFIX + "-" + statCollector.id, data);
|
|
11424
|
+
_context7.n = 1;
|
|
11425
|
+
return statCollector.connection.send(message, data);
|
|
11426
|
+
case 1:
|
|
11427
|
+
if (statCollector.connection.status !== CONNECTION_STATUS.OK) {
|
|
11428
|
+
statCollector.logger.error(LOG_PREFIX + "-" + statCollector.id, "Error " + statCollector.connection.status + " sending RTC metrics to the server, stop sending");
|
|
11429
|
+
statCollector.stop();
|
|
11430
|
+
}
|
|
11431
|
+
case 2:
|
|
11432
|
+
return _context7.a(2);
|
|
11433
|
+
}
|
|
11434
|
+
}, _callee7);
|
|
11435
|
+
}));
|
|
11436
|
+
function send(_x3, _x4) {
|
|
11437
|
+
return _send.apply(this, arguments);
|
|
11438
|
+
}
|
|
11439
|
+
return send;
|
|
11440
|
+
}(),
|
|
11382
11441
|
startTimer: function startTimer() {
|
|
11383
11442
|
if (!statCollector.timer && statCollector.headers) {
|
|
11384
11443
|
statCollector.batchCount = statCollector.description.batchSize;
|
|
@@ -11393,22 +11452,22 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11393
11452
|
}
|
|
11394
11453
|
},
|
|
11395
11454
|
collectMetrics: function () {
|
|
11396
|
-
var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
11455
|
+
var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
11397
11456
|
var stats, metrics, lostMetrics, headersUpdated;
|
|
11398
|
-
return _regenerator().w(function (
|
|
11399
|
-
while (1) switch (
|
|
11457
|
+
return _regenerator().w(function (_context8) {
|
|
11458
|
+
while (1) switch (_context8.n) {
|
|
11400
11459
|
case 0:
|
|
11401
11460
|
if (!(statCollector.timer && !statCollector.timerBusy)) {
|
|
11402
|
-
|
|
11461
|
+
_context8.n = 7;
|
|
11403
11462
|
break;
|
|
11404
11463
|
}
|
|
11405
11464
|
// Unfortunately there are no real atomics in JS unless SharedArrayBuffer is used
|
|
11406
11465
|
// So we guard the timer callback with a dumb boolean
|
|
11407
11466
|
statCollector.timerBusy = true;
|
|
11408
|
-
|
|
11467
|
+
_context8.n = 1;
|
|
11409
11468
|
return statCollector.mediaConnection.getWebRTCStats();
|
|
11410
11469
|
case 1:
|
|
11411
|
-
stats =
|
|
11470
|
+
stats = _context8.v;
|
|
11412
11471
|
statCollector.startNewBatch();
|
|
11413
11472
|
metrics = [];
|
|
11414
11473
|
lostMetrics = [];
|
|
@@ -11444,42 +11503,45 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11444
11503
|
}
|
|
11445
11504
|
});
|
|
11446
11505
|
// Metrics list may change if some metrics are added or some metrics are lost #WCS-4627
|
|
11447
|
-
|
|
11506
|
+
_context8.n = 2;
|
|
11448
11507
|
return statCollector.updateHeaders(stats);
|
|
11449
11508
|
case 2:
|
|
11450
|
-
headersUpdated =
|
|
11509
|
+
headersUpdated = _context8.v;
|
|
11451
11510
|
if (!lostMetrics.length) {
|
|
11452
|
-
|
|
11511
|
+
_context8.n = 4;
|
|
11453
11512
|
break;
|
|
11454
11513
|
}
|
|
11455
11514
|
statCollector.logger.info(LOG_PREFIX + "-" + statCollector.id, "Missing metrics: " + JSON.stringify(lostMetrics));
|
|
11456
11515
|
// Send metrics already collected and start a new batch with current metrics array to send them later #WCS-4627
|
|
11457
|
-
|
|
11516
|
+
_context8.n = 3;
|
|
11458
11517
|
return statCollector.sendMetrics();
|
|
11459
11518
|
case 3:
|
|
11460
11519
|
statCollector.startNewBatch(metrics);
|
|
11461
|
-
|
|
11520
|
+
_context8.n = 5;
|
|
11462
11521
|
break;
|
|
11463
11522
|
case 4:
|
|
11464
11523
|
statCollector.metricsBatch.push(metrics);
|
|
11465
11524
|
statCollector.batchCount--;
|
|
11466
11525
|
if (!(statCollector.batchCount === 0 || headersUpdated)) {
|
|
11467
|
-
|
|
11526
|
+
_context8.n = 5;
|
|
11468
11527
|
break;
|
|
11469
11528
|
}
|
|
11470
|
-
|
|
11529
|
+
_context8.n = 5;
|
|
11471
11530
|
return statCollector.sendMetrics();
|
|
11472
11531
|
case 5:
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
statCollector.sendHeaders();
|
|
11532
|
+
if (!headersUpdated) {
|
|
11533
|
+
_context8.n = 6;
|
|
11534
|
+
break;
|
|
11477
11535
|
}
|
|
11478
|
-
statCollector.
|
|
11536
|
+
statCollector.logger.info(LOG_PREFIX + "-" + statCollector.id, "RTC metrics list has changed, sending a new metrics description");
|
|
11537
|
+
_context8.n = 6;
|
|
11538
|
+
return statCollector.sendHeaders();
|
|
11479
11539
|
case 6:
|
|
11480
|
-
|
|
11540
|
+
statCollector.timerBusy = false;
|
|
11541
|
+
case 7:
|
|
11542
|
+
return _context8.a(2);
|
|
11481
11543
|
}
|
|
11482
|
-
},
|
|
11544
|
+
}, _callee8);
|
|
11483
11545
|
}));
|
|
11484
11546
|
function collectMetrics() {
|
|
11485
11547
|
return _collectMetrics.apply(this, arguments);
|
|
@@ -11487,10 +11549,10 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11487
11549
|
return collectMetrics;
|
|
11488
11550
|
}(),
|
|
11489
11551
|
sendMetrics: function () {
|
|
11490
|
-
var _sendMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
11552
|
+
var _sendMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
11491
11553
|
var previous, metricsToSend, metricsData, i, metricsString, j, valueString, previousString, delimiter, data, _t3;
|
|
11492
|
-
return _regenerator().w(function (
|
|
11493
|
-
while (1) switch (
|
|
11554
|
+
return _regenerator().w(function (_context9) {
|
|
11555
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
11494
11556
|
case 0:
|
|
11495
11557
|
metricsToSend = [];
|
|
11496
11558
|
for (i = 0; statCollector.metricsBatch && i < statCollector.metricsBatch.length; i++) {
|
|
@@ -11514,39 +11576,43 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11514
11576
|
metricsToSend.push(metricsString);
|
|
11515
11577
|
}
|
|
11516
11578
|
if (!(statCollector.compression !== "none")) {
|
|
11517
|
-
|
|
11579
|
+
_context9.n = 5;
|
|
11518
11580
|
break;
|
|
11519
11581
|
}
|
|
11520
|
-
|
|
11521
|
-
|
|
11582
|
+
_context9.p = 1;
|
|
11583
|
+
_context9.n = 2;
|
|
11522
11584
|
return util.compress(statCollector.compression, JSON.stringify(metricsToSend), true);
|
|
11523
11585
|
case 2:
|
|
11524
|
-
metricsData =
|
|
11525
|
-
|
|
11586
|
+
metricsData = _context9.v;
|
|
11587
|
+
_context9.n = 4;
|
|
11526
11588
|
break;
|
|
11527
11589
|
case 3:
|
|
11528
|
-
|
|
11529
|
-
_t3 =
|
|
11590
|
+
_context9.p = 3;
|
|
11591
|
+
_t3 = _context9.v;
|
|
11530
11592
|
statCollector.logger.warn(LOG_PREFIX + "-" + statCollector.id, "Can't send metrics data using" + statCollector.compression + ": " + _t3);
|
|
11531
11593
|
metricsData = null;
|
|
11532
11594
|
case 4:
|
|
11533
|
-
|
|
11595
|
+
_context9.n = 6;
|
|
11534
11596
|
break;
|
|
11535
11597
|
case 5:
|
|
11536
11598
|
metricsData = metricsToSend;
|
|
11537
11599
|
case 6:
|
|
11538
|
-
if (metricsData) {
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
metrics: metricsData
|
|
11542
|
-
};
|
|
11543
|
-
statCollector.send("webRTCMetricsBatch", data);
|
|
11600
|
+
if (!metricsData) {
|
|
11601
|
+
_context9.n = 7;
|
|
11602
|
+
break;
|
|
11544
11603
|
}
|
|
11545
|
-
|
|
11604
|
+
data = {
|
|
11605
|
+
mediaSessionId: statCollector.id,
|
|
11606
|
+
metrics: metricsData
|
|
11607
|
+
};
|
|
11608
|
+
_context9.n = 7;
|
|
11609
|
+
return statCollector.send("webRTCMetricsBatch", data);
|
|
11546
11610
|
case 7:
|
|
11547
|
-
|
|
11611
|
+
statCollector.cleanBatch();
|
|
11612
|
+
case 8:
|
|
11613
|
+
return _context9.a(2);
|
|
11548
11614
|
}
|
|
11549
|
-
},
|
|
11615
|
+
}, _callee9, null, [[1, 3]]);
|
|
11550
11616
|
}));
|
|
11551
11617
|
function sendMetrics() {
|
|
11552
11618
|
return _sendMetrics.apply(this, arguments);
|
|
@@ -11571,6 +11637,163 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11571
11637
|
return statCollector;
|
|
11572
11638
|
};
|
|
11573
11639
|
|
|
11640
|
+
// Wrapper to send metrics via Websocket or HTTP POST
|
|
11641
|
+
var Connection = function Connection() {
|
|
11642
|
+
var existingConnection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
11643
|
+
var maxErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MAX_SEND_ERRORS;
|
|
11644
|
+
var connection = {
|
|
11645
|
+
type: "",
|
|
11646
|
+
websocket: null,
|
|
11647
|
+
http: null,
|
|
11648
|
+
maxErrors: maxErrors,
|
|
11649
|
+
errorsCount: 0,
|
|
11650
|
+
status: CONNECTION_STATUS.INIT,
|
|
11651
|
+
setUp: function setUp(url) {
|
|
11652
|
+
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
11653
|
+
var existingConnection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
11654
|
+
if (url.startsWith(CONNECTION_TYPE.WEBSOCKET)) {
|
|
11655
|
+
connection.type = CONNECTION_TYPE.WEBSOCKET;
|
|
11656
|
+
// ToDo: create a new Websocket connection
|
|
11657
|
+
} else if (url.startsWith(CONNECTION_TYPE.HTTP)) {
|
|
11658
|
+
connection.type = CONNECTION_TYPE.HTTP;
|
|
11659
|
+
connection.http = HttpConnection(url, headers);
|
|
11660
|
+
} else if (existingConnection) {
|
|
11661
|
+
connection.type = CONNECTION_TYPE.WEBSOCKET;
|
|
11662
|
+
connection.websocket = WebsocketConnection(existingConnection);
|
|
11663
|
+
}
|
|
11664
|
+
connection.errorsCount = 0;
|
|
11665
|
+
connection.status = CONNECTION_STATUS.INIT;
|
|
11666
|
+
},
|
|
11667
|
+
send: function () {
|
|
11668
|
+
var _send2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(message, data) {
|
|
11669
|
+
var code, _t4;
|
|
11670
|
+
return _regenerator().w(function (_context0) {
|
|
11671
|
+
while (1) switch (_context0.n) {
|
|
11672
|
+
case 0:
|
|
11673
|
+
code = CONNECTION_STATUS.BAD_REQUEST;
|
|
11674
|
+
_t4 = connection.type;
|
|
11675
|
+
_context0.n = _t4 === CONNECTION_TYPE.WEBSOCKET ? 1 : _t4 === CONNECTION_TYPE.HTTP ? 2 : 5;
|
|
11676
|
+
break;
|
|
11677
|
+
case 1:
|
|
11678
|
+
if (connection.websocket) {
|
|
11679
|
+
code = connection.websocket.send(message, data);
|
|
11680
|
+
}
|
|
11681
|
+
return _context0.a(3, 5);
|
|
11682
|
+
case 2:
|
|
11683
|
+
if (!connection.http) {
|
|
11684
|
+
_context0.n = 4;
|
|
11685
|
+
break;
|
|
11686
|
+
}
|
|
11687
|
+
_context0.n = 3;
|
|
11688
|
+
return connection.http.send(message, data);
|
|
11689
|
+
case 3:
|
|
11690
|
+
code = _context0.v;
|
|
11691
|
+
case 4:
|
|
11692
|
+
return _context0.a(3, 5);
|
|
11693
|
+
case 5:
|
|
11694
|
+
connection.status = code;
|
|
11695
|
+
if (connection.status === CONNECTION_STATUS.OK) {
|
|
11696
|
+
connection.errorsCount = 0;
|
|
11697
|
+
} else {
|
|
11698
|
+
if (message === "webRTCMetricsBatch") {
|
|
11699
|
+
connection.errorsCount++;
|
|
11700
|
+
if (connection.errorsCount < connection.maxErrors) {
|
|
11701
|
+
connection.status = CONNECTION_STATUS.OK;
|
|
11702
|
+
}
|
|
11703
|
+
}
|
|
11704
|
+
}
|
|
11705
|
+
case 6:
|
|
11706
|
+
return _context0.a(2);
|
|
11707
|
+
}
|
|
11708
|
+
}, _callee0);
|
|
11709
|
+
}));
|
|
11710
|
+
function send(_x5, _x6) {
|
|
11711
|
+
return _send2.apply(this, arguments);
|
|
11712
|
+
}
|
|
11713
|
+
return send;
|
|
11714
|
+
}()
|
|
11715
|
+
};
|
|
11716
|
+
connection.setUp("", null, existingConnection);
|
|
11717
|
+
return connection;
|
|
11718
|
+
};
|
|
11719
|
+
|
|
11720
|
+
// Websocket connection (using existing one)
|
|
11721
|
+
var WebsocketConnection = function WebsocketConnection(wsConnection) {
|
|
11722
|
+
var connection = {
|
|
11723
|
+
websocket: wsConnection,
|
|
11724
|
+
send: function send(message, data) {
|
|
11725
|
+
var code = CONNECTION_STATUS.BAD_REQUEST;
|
|
11726
|
+
if (connection.websocket) {
|
|
11727
|
+
console.log(connection.websocket);
|
|
11728
|
+
if (connection.websocket.readyState === WebSocket.OPEN) {
|
|
11729
|
+
connection.websocket.send(JSON.stringify({
|
|
11730
|
+
message: message,
|
|
11731
|
+
data: [data]
|
|
11732
|
+
}));
|
|
11733
|
+
}
|
|
11734
|
+
code = CONNECTION_STATUS.OK;
|
|
11735
|
+
}
|
|
11736
|
+
return code;
|
|
11737
|
+
}
|
|
11738
|
+
};
|
|
11739
|
+
return connection;
|
|
11740
|
+
};
|
|
11741
|
+
|
|
11742
|
+
// HTTP connection using Fetch API
|
|
11743
|
+
var HttpConnection = function HttpConnection(url, headers) {
|
|
11744
|
+
var connection = {
|
|
11745
|
+
url: addSlash(url),
|
|
11746
|
+
headers: headers,
|
|
11747
|
+
send: function () {
|
|
11748
|
+
var _send3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(message, data) {
|
|
11749
|
+
var code, httpHeaders, _i2, _Object$entries, _Object$entries$_i, header, value, response, _t5;
|
|
11750
|
+
return _regenerator().w(function (_context1) {
|
|
11751
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
11752
|
+
case 0:
|
|
11753
|
+
code = CONNECTION_STATUS.BAD_REQUEST;
|
|
11754
|
+
if (!connection.url) {
|
|
11755
|
+
_context1.n = 4;
|
|
11756
|
+
break;
|
|
11757
|
+
}
|
|
11758
|
+
_context1.p = 1;
|
|
11759
|
+
httpHeaders = new Headers();
|
|
11760
|
+
httpHeaders.append("Content-Type", "application/json");
|
|
11761
|
+
if (connection.headers) {
|
|
11762
|
+
for (_i2 = 0, _Object$entries = Object.entries(connection.headers); _i2 < _Object$entries.length; _i2++) {
|
|
11763
|
+
_Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2), header = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
11764
|
+
httpHeaders.append(header, value);
|
|
11765
|
+
}
|
|
11766
|
+
}
|
|
11767
|
+
_context1.n = 2;
|
|
11768
|
+
return fetch(connection.url + message, {
|
|
11769
|
+
method: "POST",
|
|
11770
|
+
headers: httpHeaders,
|
|
11771
|
+
mode: "cors",
|
|
11772
|
+
body: JSON.stringify(data)
|
|
11773
|
+
});
|
|
11774
|
+
case 2:
|
|
11775
|
+
response = _context1.v;
|
|
11776
|
+
code = response.status;
|
|
11777
|
+
_context1.n = 4;
|
|
11778
|
+
break;
|
|
11779
|
+
case 3:
|
|
11780
|
+
_context1.p = 3;
|
|
11781
|
+
_t5 = _context1.v;
|
|
11782
|
+
code = CONNECTION_STATUS.INTERNAL_SERVER_ERROR;
|
|
11783
|
+
case 4:
|
|
11784
|
+
return _context1.a(2, code);
|
|
11785
|
+
}
|
|
11786
|
+
}, _callee1, null, [[1, 3]]);
|
|
11787
|
+
}));
|
|
11788
|
+
function send(_x7, _x8) {
|
|
11789
|
+
return _send3.apply(this, arguments);
|
|
11790
|
+
}
|
|
11791
|
+
return send;
|
|
11792
|
+
}()
|
|
11793
|
+
};
|
|
11794
|
+
return connection;
|
|
11795
|
+
};
|
|
11796
|
+
|
|
11574
11797
|
// Helper function to stringify a value
|
|
11575
11798
|
var valueToString = function valueToString(value) {
|
|
11576
11799
|
var valueString = "undefined";
|
|
@@ -11596,6 +11819,15 @@ var getLogger = function getLogger(logger) {
|
|
|
11596
11819
|
debug: function debug() {}
|
|
11597
11820
|
};
|
|
11598
11821
|
};
|
|
11822
|
+
|
|
11823
|
+
// Helper function to add slash to endpoint
|
|
11824
|
+
var addSlash = function addSlash(value) {
|
|
11825
|
+
var endpoint = value;
|
|
11826
|
+
if (endpoint && !endpoint.endsWith("/")) {
|
|
11827
|
+
endpoint = endpoint + "/";
|
|
11828
|
+
}
|
|
11829
|
+
return endpoint;
|
|
11830
|
+
};
|
|
11599
11831
|
module.exports = {
|
|
11600
11832
|
StreamStatsCollector: StreamStatsCollector
|
|
11601
11833
|
};
|