@stormstreaming/stormstreamer 0.9.1-beta.2 → 0.9.2-beta.0
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/dist/amd/index.js +544 -121
- package/dist/cjs/index.js +8 -8
- package/dist/esm/index.js +12 -12
- package/dist/iife/index.js +8 -8
- package/dist/types/StormStreamer.d.ts +22 -9
- package/dist/types/config/DebugData.d.ts +4 -0
- package/dist/types/graph/BitrateGraph.d.ts +11 -0
- package/dist/types/graph/FPSGraph.d.ts +11 -0
- package/dist/types/graph/GraphDrawer.d.ts +27 -0
- package/dist/types/graph/IGraph.d.ts +4 -0
- package/dist/types/logger/Logger.d.ts +1 -0
- package/dist/types/playback/{PlaybackController.d.ts → StreamerController.d.ts} +7 -1
- package/dist/types/playback/enum/DeviceState.d.ts +2 -1
- package/dist/types/playback/enum/StreamerState.d.ts +2 -1
- package/dist/types/playback/model/StreamStatusInfo.d.ts +15 -6
- package/dist/types/playback/player/AbstractPlayer.d.ts +2 -2
- package/dist/types/stage/StageController.d.ts +1 -0
- package/dist/types/statistics/StatsController.d.ts +25 -0
- package/dist/types/types/DebugConfig.d.ts +3 -0
- package/dist/umd/index.js +8 -8
- package/package.json +1 -1
package/dist/amd/index.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* contact@stormstreaming.com
|
|
5
5
|
* https://stormstreaming.com
|
|
6
6
|
*
|
|
7
|
-
* Version: 0.9.
|
|
8
|
-
* Version:
|
|
7
|
+
* Version: 0.9.2-beta.0
|
|
8
|
+
* Version: 3/6/2025, 12:46:46 PM
|
|
9
9
|
*
|
|
10
10
|
* LEGAL NOTICE:
|
|
11
11
|
* This software is subject to the terms and conditions defined in
|
|
@@ -13,6 +13,38 @@
|
|
|
13
13
|
*
|
|
14
14
|
*/define(['exports'], (function (exports) { 'use strict';
|
|
15
15
|
|
|
16
|
+
/******************************************************************************
|
|
17
|
+
Copyright (c) Microsoft Corporation.
|
|
18
|
+
|
|
19
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
20
|
+
purpose with or without fee is hereby granted.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
24
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
27
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
29
|
+
***************************************************************************** */
|
|
30
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
34
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
36
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
37
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
38
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
39
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
44
|
+
var e = new Error(message);
|
|
45
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
46
|
+
};
|
|
47
|
+
|
|
16
48
|
class StormServerItem {
|
|
17
49
|
constructor(host, application, port = 443, isSSL = true) {
|
|
18
50
|
this.host = host;
|
|
@@ -340,10 +372,12 @@
|
|
|
340
372
|
this._containerLogEnabled = false;
|
|
341
373
|
this._enabledContainerTypes = [LogType.INFO, LogType.ERROR, LogType.SUCCESS, LogType.TRACE, LogType.WARNING];
|
|
342
374
|
this._containerLogMonoColor = false;
|
|
375
|
+
this._stageController = true;
|
|
376
|
+
this._streamerController = true;
|
|
343
377
|
this.parse(debugConfig);
|
|
344
378
|
}
|
|
345
379
|
parse(debugConfig) {
|
|
346
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
380
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
347
381
|
this._debugConfig = debugConfig;
|
|
348
382
|
if (this._debugConfig) {
|
|
349
383
|
this._consoleLogEnabled = (_c = (_b = (_a = this._debugConfig) === null || _a === void 0 ? void 0 : _a.console) === null || _b === void 0 ? void 0 : _b.enabled) !== null && _c !== void 0 ? _c : this._consoleLogEnabled;
|
|
@@ -353,6 +387,8 @@
|
|
|
353
387
|
this._containerLogMonoColor = (_q = (_p = (_o = this._debugConfig) === null || _o === void 0 ? void 0 : _o.container) === null || _p === void 0 ? void 0 : _p.monoColor) !== null && _q !== void 0 ? _q : this._containerLogMonoColor;
|
|
354
388
|
this._enabledContainerTypes = (_t = this.parseLogTypes((_s = (_r = this._debugConfig) === null || _r === void 0 ? void 0 : _r.container) === null || _s === void 0 ? void 0 : _s.logTypes)) !== null && _t !== void 0 ? _t : this._enabledContainerTypes;
|
|
355
389
|
this._containerID = (_w = (_v = (_u = this._debugConfig) === null || _u === void 0 ? void 0 : _u.container) === null || _v === void 0 ? void 0 : _v.containerID) !== null && _w !== void 0 ? _w : this._containerID;
|
|
390
|
+
this._streamerController = (_y = (_x = this._debugConfig) === null || _x === void 0 ? void 0 : _x.streamerController) !== null && _y !== void 0 ? _y : this._streamerController;
|
|
391
|
+
this._stageController = (_0 = (_z = this._debugConfig) === null || _z === void 0 ? void 0 : _z.stageController) !== null && _0 !== void 0 ? _0 : this._stageController;
|
|
356
392
|
}
|
|
357
393
|
}
|
|
358
394
|
parseLogTypes(logTypes) {
|
|
@@ -453,6 +489,12 @@
|
|
|
453
489
|
set containerLogMonoColor(newValue) {
|
|
454
490
|
this._containerLogMonoColor = newValue;
|
|
455
491
|
}
|
|
492
|
+
get stageControllerDebug() {
|
|
493
|
+
return this._stageController;
|
|
494
|
+
}
|
|
495
|
+
get streamerControllerDebug() {
|
|
496
|
+
return this._streamerController;
|
|
497
|
+
}
|
|
456
498
|
print(logger, force = false) {
|
|
457
499
|
if (DebugData.PRINT_ON_STARTUP || force) {
|
|
458
500
|
let consoleLogTypes = "";
|
|
@@ -844,6 +886,23 @@
|
|
|
844
886
|
}
|
|
845
887
|
}
|
|
846
888
|
}
|
|
889
|
+
decoratedLog(text, scheme) {
|
|
890
|
+
const EMOJI_MAP = ["0️⃣", "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"];
|
|
891
|
+
const COLOR_SCHEMES = {
|
|
892
|
+
'dark-blue': '#4c9fee',
|
|
893
|
+
'dark-green': '#4bcb64',
|
|
894
|
+
'dark-orange': '#daa33a',
|
|
895
|
+
'dark-red': '#f86464',
|
|
896
|
+
'dark-pink': '#f864e8',
|
|
897
|
+
'dark-yellow': '#e1f864'
|
|
898
|
+
};
|
|
899
|
+
const id = this._stormStreamer.getStreamerID();
|
|
900
|
+
const keyCaps = id >= 0 && id < EMOJI_MAP.length ? EMOJI_MAP[id] : `[${id}]`;
|
|
901
|
+
const color = COLOR_SCHEMES[scheme];
|
|
902
|
+
if (!color) return;
|
|
903
|
+
const style = `background: black; color: ${color}; border: 1px solid ${color}; padding: 5px 5px 5px 0px`;
|
|
904
|
+
console.log(`%c 🎦️${keyCaps} ${text}`, style);
|
|
905
|
+
}
|
|
847
906
|
error(objectName, message) {
|
|
848
907
|
let output = this.logData(objectName, message);
|
|
849
908
|
if (this._debugConfig.consoleLogEnabled) {
|
|
@@ -923,18 +982,6 @@
|
|
|
923
982
|
Logger.SUCCESS_COLOR = "green";
|
|
924
983
|
Logger.TRACE_COLOR = "black";
|
|
925
984
|
|
|
926
|
-
class ClientUser {
|
|
927
|
-
constructor() {
|
|
928
|
-
this.bandwidthCapabilities = 0;
|
|
929
|
-
}
|
|
930
|
-
setBandwidthCapabilities(newCapabilities) {
|
|
931
|
-
this.bandwidthCapabilities = newCapabilities;
|
|
932
|
-
}
|
|
933
|
-
getBandwidthCapabilities() {
|
|
934
|
-
return this.bandwidthCapabilities;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
|
|
938
985
|
class UserCapabilities {
|
|
939
986
|
static hasWebSocketsSupport() {
|
|
940
987
|
return window.WebSocket != null;
|
|
@@ -1729,6 +1776,7 @@
|
|
|
1729
1776
|
this._isResizing = false;
|
|
1730
1777
|
this._autoResizeEnabled = true;
|
|
1731
1778
|
this._parentOriginalOverflow = '';
|
|
1779
|
+
this._debug = false;
|
|
1732
1780
|
this.onFullScreenChange = () => {
|
|
1733
1781
|
if (document.fullscreenElement == null) {
|
|
1734
1782
|
this.isInFullScreenMode = false;
|
|
@@ -1750,9 +1798,10 @@
|
|
|
1750
1798
|
this.initialize();
|
|
1751
1799
|
}
|
|
1752
1800
|
initialize() {
|
|
1753
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1801
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1754
1802
|
const containerID = (_d = (_c = (_b = (_a = this._main.getConfigManager()) === null || _a === void 0 ? void 0 : _a.getSettingsData()) === null || _b === void 0 ? void 0 : _b.getVideoData()) === null || _c === void 0 ? void 0 : _c.containerID) !== null && _d !== void 0 ? _d : null;
|
|
1755
1803
|
this._scalingMode = (_f = (_e = this._main.getConfigManager()) === null || _e === void 0 ? void 0 : _e.getSettingsData().getVideoData().scalingMode) !== null && _f !== void 0 ? _f : ScalingType.FILL;
|
|
1804
|
+
this._debug = (_h = (_g = this._main.getConfigManager()) === null || _g === void 0 ? void 0 : _g.getSettingsData().getDebugData().stageControllerDebug) !== null && _h !== void 0 ? _h : this._debug;
|
|
1756
1805
|
this._videoContainer = document.createElement('div');
|
|
1757
1806
|
this._videoContainer.setAttribute("id", "stormStreamer_" + this._main.getStreamerID());
|
|
1758
1807
|
this._videoContainer.style.overflow = "hidden";
|
|
@@ -1798,10 +1847,12 @@
|
|
|
1798
1847
|
tempParentElement = container;
|
|
1799
1848
|
}
|
|
1800
1849
|
if (tempParentElement === this._parentElement) {
|
|
1850
|
+
if (this._debug) this._logger.decoratedLog("Attaching Failed (container is the same)", "dark-pink");
|
|
1801
1851
|
this._logger.warning(this, "attachToParent :: container is the same");
|
|
1802
1852
|
return false;
|
|
1803
1853
|
}
|
|
1804
1854
|
if (tempParentElement && this._videoContainer) {
|
|
1855
|
+
if (this._debug) this._logger.decoratedLog("Attach To Parent: " + container + " (success)", "dark-pink");
|
|
1805
1856
|
this._parentElement = tempParentElement;
|
|
1806
1857
|
this._parentElement.appendChild(this._videoContainer);
|
|
1807
1858
|
this._resizeObserver.observe(this._parentElement);
|
|
@@ -1815,13 +1866,13 @@
|
|
|
1815
1866
|
this.handleResize();
|
|
1816
1867
|
result = true;
|
|
1817
1868
|
} else {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
this._logger.warning(this, "attachToParent :: container was not found");
|
|
1869
|
+
if (this._debug) this._logger.decoratedLog("Attach To Parent: " + container + " (failure - container not found)", "dark-pink");
|
|
1870
|
+
this._logger.warning(this, "attachToParent :: container \"" + container + "\"+ was not found");
|
|
1821
1871
|
}
|
|
1822
1872
|
return result;
|
|
1823
1873
|
}
|
|
1824
1874
|
detachFromParent() {
|
|
1875
|
+
if (this._debug) this._logger.decoratedLog("Detach From Parent", "dark-pink");
|
|
1825
1876
|
let result = false;
|
|
1826
1877
|
if (this._parentElement != null && this._videoContainer != null) {
|
|
1827
1878
|
this._logger.info(this, "Detaching from parent: " + this._videoContainer);
|
|
@@ -2093,38 +2144,6 @@
|
|
|
2093
2144
|
}
|
|
2094
2145
|
StageController.LOG_ACTIVITY = true;
|
|
2095
2146
|
|
|
2096
|
-
/******************************************************************************
|
|
2097
|
-
Copyright (c) Microsoft Corporation.
|
|
2098
|
-
|
|
2099
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
2100
|
-
purpose with or without fee is hereby granted.
|
|
2101
|
-
|
|
2102
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2103
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2104
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2105
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2106
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2107
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2108
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2109
|
-
***************************************************************************** */
|
|
2110
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
2114
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2115
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2116
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2117
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2118
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2119
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2120
|
-
});
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2124
|
-
var e = new Error(message);
|
|
2125
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2126
|
-
};
|
|
2127
|
-
|
|
2128
2147
|
class MungeSDP {
|
|
2129
2148
|
constructor() {}
|
|
2130
2149
|
addAudio(sdpStr, audioLine) {
|
|
@@ -2490,7 +2509,6 @@
|
|
|
2490
2509
|
this._analyser.smoothingTimeConstant = 0.3;
|
|
2491
2510
|
this._microphone.connect(this._analyser);
|
|
2492
2511
|
this.startMonitoring();
|
|
2493
|
-
console.log('SoundMeter: Successfully attached to new audio stream');
|
|
2494
2512
|
} catch (error) {
|
|
2495
2513
|
console.error('SoundMeter: Error during attach:', error);
|
|
2496
2514
|
this.detach();
|
|
@@ -2524,7 +2542,6 @@
|
|
|
2524
2542
|
}
|
|
2525
2543
|
this._audioContext = null;
|
|
2526
2544
|
this.clear();
|
|
2527
|
-
console.log('SoundMeter: Successfully detached');
|
|
2528
2545
|
}
|
|
2529
2546
|
clear() {
|
|
2530
2547
|
this._instant = 0;
|
|
@@ -2578,6 +2595,7 @@
|
|
|
2578
2595
|
StreamerState["UPDATING"] = "UPDATING";
|
|
2579
2596
|
StreamerState["INVALID"] = "INVALID";
|
|
2580
2597
|
StreamerState["UNKNOWN"] = "UNKNOWN";
|
|
2598
|
+
StreamerState["STOPPED"] = "STOPPED";
|
|
2581
2599
|
})(exports.StreamerState || (exports.StreamerState = {}));
|
|
2582
2600
|
|
|
2583
2601
|
exports.DeviceState = void 0;
|
|
@@ -2586,6 +2604,7 @@
|
|
|
2586
2604
|
DeviceState["ENABLED"] = "ENABLED";
|
|
2587
2605
|
DeviceState["ACCESS_DENIED"] = "ACCESS_DENIED";
|
|
2588
2606
|
DeviceState["NOT_FOUND"] = "NOT_FOUND";
|
|
2607
|
+
DeviceState["STOPPED"] = "STOPPED";
|
|
2589
2608
|
})(exports.DeviceState || (exports.DeviceState = {}));
|
|
2590
2609
|
|
|
2591
2610
|
var ConnectionState;
|
|
@@ -2706,11 +2725,14 @@
|
|
|
2706
2725
|
class StreamStatusInfo {
|
|
2707
2726
|
constructor() {
|
|
2708
2727
|
this._publishState = exports.PublishState.NOT_INITIALIZED;
|
|
2709
|
-
this.
|
|
2710
|
-
this.
|
|
2728
|
+
this._videoPublishBitrate = 0;
|
|
2729
|
+
this._audioPublishBitrate = 0;
|
|
2730
|
+
this._currentBitrate = 0;
|
|
2711
2731
|
this._audioFrameCount = 0;
|
|
2712
2732
|
this._videoFrameCount = 0;
|
|
2713
2733
|
this._frameRate = 0;
|
|
2734
|
+
this._videoWidth = 0;
|
|
2735
|
+
this._videoHeight = 0;
|
|
2714
2736
|
}
|
|
2715
2737
|
get publishState() {
|
|
2716
2738
|
return this._publishState;
|
|
@@ -2718,17 +2740,23 @@
|
|
|
2718
2740
|
set publishState(value) {
|
|
2719
2741
|
this._publishState = value === "published" ? exports.PublishState.PUBLISHED : exports.PublishState.CONNECTED;
|
|
2720
2742
|
}
|
|
2721
|
-
get
|
|
2722
|
-
return this.
|
|
2743
|
+
get videoPublishBitrate() {
|
|
2744
|
+
return this._videoPublishBitrate;
|
|
2723
2745
|
}
|
|
2724
|
-
set
|
|
2725
|
-
this.
|
|
2746
|
+
set videoPublishBitrate(value) {
|
|
2747
|
+
this._videoPublishBitrate = value;
|
|
2726
2748
|
}
|
|
2727
|
-
get
|
|
2728
|
-
return this.
|
|
2749
|
+
get audioPublishBitrate() {
|
|
2750
|
+
return this._audioPublishBitrate;
|
|
2729
2751
|
}
|
|
2730
|
-
set
|
|
2731
|
-
this.
|
|
2752
|
+
set audioPublishBitrate(value) {
|
|
2753
|
+
this._audioPublishBitrate = value;
|
|
2754
|
+
}
|
|
2755
|
+
set currentBitrate(value) {
|
|
2756
|
+
this._currentBitrate = value;
|
|
2757
|
+
}
|
|
2758
|
+
get currentBitrate() {
|
|
2759
|
+
return this._currentBitrate;
|
|
2732
2760
|
}
|
|
2733
2761
|
get audioFrameCount() {
|
|
2734
2762
|
return this._audioFrameCount;
|
|
@@ -2748,6 +2776,18 @@
|
|
|
2748
2776
|
set frameRate(value) {
|
|
2749
2777
|
this._frameRate = value;
|
|
2750
2778
|
}
|
|
2779
|
+
set videoWidth(value) {
|
|
2780
|
+
this._videoWidth = value;
|
|
2781
|
+
}
|
|
2782
|
+
get videoWidth() {
|
|
2783
|
+
return this._videoWidth;
|
|
2784
|
+
}
|
|
2785
|
+
set videoHeight(value) {
|
|
2786
|
+
this._videoHeight = value;
|
|
2787
|
+
}
|
|
2788
|
+
get videoHeight() {
|
|
2789
|
+
return this._videoHeight;
|
|
2790
|
+
}
|
|
2751
2791
|
}
|
|
2752
2792
|
|
|
2753
2793
|
class WowzaStatusConnection extends AbstractSocket {
|
|
@@ -2807,11 +2847,15 @@
|
|
|
2807
2847
|
case "STREAM_STATUS_RESPONSE":
|
|
2808
2848
|
const streamStatusInfo = new StreamStatusInfo();
|
|
2809
2849
|
streamStatusInfo.publishState = msgJSON.streamStatus;
|
|
2810
|
-
streamStatusInfo.
|
|
2811
|
-
streamStatusInfo.
|
|
2850
|
+
streamStatusInfo.videoPublishBitrate = msgJSON.publishVideoBitrate;
|
|
2851
|
+
streamStatusInfo.audioPublishBitrate = msgJSON.publishAudioBitrate;
|
|
2812
2852
|
streamStatusInfo.videoFrameCount = msgJSON.videoFrameCount;
|
|
2813
2853
|
streamStatusInfo.audioFrameCount = msgJSON.audioFrameCount;
|
|
2814
2854
|
streamStatusInfo.frameRate = msgJSON.frameRate;
|
|
2855
|
+
streamStatusInfo.videoWidth = msgJSON.videoWidth;
|
|
2856
|
+
streamStatusInfo.videoHeight = msgJSON.videoHeight;
|
|
2857
|
+
streamStatusInfo.currentBitrate = msgJSON.realBitrate;
|
|
2858
|
+
console.log(streamStatusInfo);
|
|
2815
2859
|
this._main.dispatchEvent("streamStatusUpdate", {
|
|
2816
2860
|
ref: this._main,
|
|
2817
2861
|
streamStatus: streamStatusInfo
|
|
@@ -2899,9 +2943,9 @@
|
|
|
2899
2943
|
}
|
|
2900
2944
|
}
|
|
2901
2945
|
|
|
2902
|
-
class
|
|
2946
|
+
class StreamerController {
|
|
2903
2947
|
constructor(main) {
|
|
2904
|
-
var _a;
|
|
2948
|
+
var _a, _b, _c;
|
|
2905
2949
|
this._isWindowActive = true;
|
|
2906
2950
|
this._peerConnectionConfig = {
|
|
2907
2951
|
'iceServers': []
|
|
@@ -2932,12 +2976,14 @@
|
|
|
2932
2976
|
this._restartTimerCount = 0;
|
|
2933
2977
|
this._restartTimerMaxCount = 5;
|
|
2934
2978
|
this._publishState = exports.PublishState.NOT_INITIALIZED;
|
|
2979
|
+
this._publishTime = 0;
|
|
2935
2980
|
this._inputDeviceState = exports.StreamerState.NOT_INITIALIZED;
|
|
2936
2981
|
this._cameraState = exports.DeviceState.NOT_INITIALIZED;
|
|
2937
2982
|
this._microphoneState = exports.DeviceState.NOT_INITIALIZED;
|
|
2938
2983
|
this._publishTimer = 0;
|
|
2939
2984
|
this._currentOrientation = ((_a = window.screen.orientation) === null || _a === void 0 ? void 0 : _a.type) || '';
|
|
2940
2985
|
this._statusTimer = null;
|
|
2986
|
+
this._debug = false;
|
|
2941
2987
|
this.onDeviceStateChange = event => {
|
|
2942
2988
|
var _a;
|
|
2943
2989
|
const usedStreamKey = (_a = this._main.getConfigManager()) === null || _a === void 0 ? void 0 : _a.getStreamData().streamKey;
|
|
@@ -2946,13 +2992,13 @@
|
|
|
2946
2992
|
}
|
|
2947
2993
|
};
|
|
2948
2994
|
this.handleOrientationChange = () => __awaiter(this, void 0, void 0, function* () {
|
|
2949
|
-
var
|
|
2995
|
+
var _d, _e;
|
|
2950
2996
|
yield new Promise(resolve => setTimeout(resolve, 500));
|
|
2951
|
-
const newOrientation = ((
|
|
2997
|
+
const newOrientation = ((_d = window.screen.orientation) === null || _d === void 0 ? void 0 : _d.type) || '';
|
|
2952
2998
|
if (this._currentOrientation !== newOrientation) {
|
|
2953
2999
|
this._logger.info(this, `Orientation changed from ${this._currentOrientation} to ${newOrientation}`);
|
|
2954
3000
|
this._currentOrientation = newOrientation;
|
|
2955
|
-
const streamKey = (
|
|
3001
|
+
const streamKey = (_e = this._main.getConfigManager()) === null || _e === void 0 ? void 0 : _e.getStreamData().streamKey;
|
|
2956
3002
|
this._publishState === exports.PublishState.PUBLISHED;
|
|
2957
3003
|
this.closeWebRTCConnection();
|
|
2958
3004
|
if (this._stream) {
|
|
@@ -3042,12 +3088,16 @@
|
|
|
3042
3088
|
if (this._statusTimer == null) {
|
|
3043
3089
|
if (this._statusConnection != null && usedStreamKey != null) {
|
|
3044
3090
|
this._statusTimer = setInterval(() => {
|
|
3045
|
-
|
|
3046
|
-
(_a = this._statusConnection) === null || _a === void 0 ? void 0 : _a.sendData('{"packetID":"STREAM_STATUS", "streamKey": "' + usedStreamKey + '"}');
|
|
3091
|
+
this.requestStatusData();
|
|
3047
3092
|
}, 1000);
|
|
3048
3093
|
}
|
|
3049
3094
|
}
|
|
3050
3095
|
};
|
|
3096
|
+
this.requestStatusData = () => {
|
|
3097
|
+
var _a;
|
|
3098
|
+
const usedStreamKey = this._main.getConfigManager().getStreamData().streamKey;
|
|
3099
|
+
(_a = this._statusConnection) === null || _a === void 0 ? void 0 : _a.sendData('{"packetID":"STREAM_STATUS", "streamKey": "' + usedStreamKey + '"}');
|
|
3100
|
+
};
|
|
3051
3101
|
this.onStatusServerDisconnect = () => {
|
|
3052
3102
|
if (this._statusTimer != null) clearInterval(this._statusTimer);
|
|
3053
3103
|
this._statusTimer = null;
|
|
@@ -3056,7 +3106,6 @@
|
|
|
3056
3106
|
const update = event.streamStatus;
|
|
3057
3107
|
if (this._publishState == exports.PublishState.PUBLISHED && update.publishState != exports.PublishState.PUBLISHED) this.setPublishState(exports.PublishState.UNPUBLISHED);
|
|
3058
3108
|
if (this._publishState == exports.PublishState.CONNECTED && update.publishState == exports.PublishState.PUBLISHED) this.setPublishState(exports.PublishState.PUBLISHED);
|
|
3059
|
-
this._logger.info(this, "Stream Status Update :: VideoBitrate " + update.videoBitrate + " | AudioBitrate : " + update.audioBitrate + " | Video Frames: " + update.videoFrameCount + " | Audio Frames: " + update.audioFrameCount + " | FPS: " + update.frameRate);
|
|
3060
3109
|
};
|
|
3061
3110
|
this.onDescriptionSuccess = description => {
|
|
3062
3111
|
var _a, _b, _c;
|
|
@@ -3104,6 +3153,7 @@
|
|
|
3104
3153
|
this._logger = main.getLogger();
|
|
3105
3154
|
this._mungeSDP = new MungeSDP();
|
|
3106
3155
|
this._soundMeter = new SoundMeter(this._main);
|
|
3156
|
+
this._debug = (_c = (_b = this._main.getConfigManager()) === null || _b === void 0 ? void 0 : _b.getSettingsData().getDebugData().streamerControllerDebug) !== null && _c !== void 0 ? _c : this._debug;
|
|
3107
3157
|
this.initialize();
|
|
3108
3158
|
}
|
|
3109
3159
|
initialize() {
|
|
@@ -3269,16 +3319,18 @@
|
|
|
3269
3319
|
}
|
|
3270
3320
|
}
|
|
3271
3321
|
publish(streamKey) {
|
|
3272
|
-
this.
|
|
3322
|
+
if (this._statusTimer != null) clearInterval(this._statusTimer);
|
|
3273
3323
|
if (this._main.getConfigManager().getStreamData().streamKey == streamKey && this._publishState == exports.PublishState.CONNECTED) {
|
|
3274
3324
|
this._logger.warning(this, "Already published!");
|
|
3275
3325
|
return false;
|
|
3276
3326
|
}
|
|
3327
|
+
if (this._main.getConfigManager().getStreamData().streamKey != null) this.unpublish();
|
|
3277
3328
|
this._main.getConfigManager().getStreamData().streamKey = streamKey;
|
|
3278
3329
|
if (!this.isStreamReady(true, true)) {
|
|
3279
3330
|
this._logger.warning(this, "Cannot publish - stream not ready (missing video or audio track)");
|
|
3280
3331
|
return false;
|
|
3281
3332
|
}
|
|
3333
|
+
if (this._debug) this._logger.decoratedLog("Publishing: " + streamKey, "dark-red");
|
|
3282
3334
|
this._logger.info(this, "Publish: " + streamKey);
|
|
3283
3335
|
this.closeWebRTCConnection();
|
|
3284
3336
|
this._main.dispatchEvent("publish", {
|
|
@@ -3289,10 +3341,13 @@
|
|
|
3289
3341
|
return true;
|
|
3290
3342
|
}
|
|
3291
3343
|
unpublish() {
|
|
3344
|
+
if (this._debug) this._logger.decoratedLog("Unpublish", "dark-red");
|
|
3292
3345
|
if (this._statusConnection != null) {
|
|
3293
3346
|
this._statusConnection.destroy();
|
|
3294
3347
|
this._statusConnection = null;
|
|
3295
|
-
|
|
3348
|
+
}
|
|
3349
|
+
if (this._statusTimer != null) {
|
|
3350
|
+
clearInterval(this._statusTimer);
|
|
3296
3351
|
this._statusTimer = null;
|
|
3297
3352
|
}
|
|
3298
3353
|
clearTimeout(this._publishTimer);
|
|
@@ -3855,13 +3910,18 @@
|
|
|
3855
3910
|
}
|
|
3856
3911
|
setPublishState(newState) {
|
|
3857
3912
|
if (this._publishState == newState) return;
|
|
3913
|
+
if (this._debug) this._logger.decoratedLog("Publish State: " + newState, "dark-blue");
|
|
3858
3914
|
this._logger.info(this, "Publish State: " + newState);
|
|
3915
|
+
if (newState == exports.PublishState.PUBLISHED) this._publishTime = new Date().getTime();
|
|
3859
3916
|
this._publishState = newState;
|
|
3860
3917
|
this._main.dispatchEvent("publishStateChange", {
|
|
3861
3918
|
ref: this._main,
|
|
3862
3919
|
state: this._publishState
|
|
3863
3920
|
});
|
|
3864
3921
|
}
|
|
3922
|
+
getPublishTime() {
|
|
3923
|
+
return this._publishState == exports.PublishState.PUBLISHED ? this._publishTime : 0;
|
|
3924
|
+
}
|
|
3865
3925
|
setInputDeviceState(newState) {
|
|
3866
3926
|
if (this._inputDeviceState == newState) return;
|
|
3867
3927
|
this._inputDeviceState = newState;
|
|
@@ -3979,6 +4039,52 @@
|
|
|
3979
4039
|
}
|
|
3980
4040
|
}
|
|
3981
4041
|
}
|
|
4042
|
+
stop() {
|
|
4043
|
+
if (this._statusConnection) {
|
|
4044
|
+
this._statusConnection.destroy();
|
|
4045
|
+
this._statusConnection = null;
|
|
4046
|
+
}
|
|
4047
|
+
if (this._statusTimer) {
|
|
4048
|
+
clearInterval(this._statusTimer);
|
|
4049
|
+
this._statusTimer = null;
|
|
4050
|
+
}
|
|
4051
|
+
this._main.getConfigManager().getStreamData().streamKey = null;
|
|
4052
|
+
this.closeWebRTCConnection();
|
|
4053
|
+
this.stopCameraStream();
|
|
4054
|
+
this.setPublishState(exports.PublishState.STOPPED);
|
|
4055
|
+
this.setInputDeviceState(exports.StreamerState.STOPPED);
|
|
4056
|
+
this.setCameraState(exports.DeviceState.STOPPED);
|
|
4057
|
+
this.setMicrophoneState(exports.DeviceState.STOPPED);
|
|
4058
|
+
if (this._restartTimer) {
|
|
4059
|
+
clearInterval(this._restartTimer);
|
|
4060
|
+
this._restartTimer = null;
|
|
4061
|
+
}
|
|
4062
|
+
this._restartTimerCount = 0;
|
|
4063
|
+
clearTimeout(this._publishTimer);
|
|
4064
|
+
}
|
|
4065
|
+
start() {
|
|
4066
|
+
var _a, _b, _c;
|
|
4067
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4068
|
+
try {
|
|
4069
|
+
this._publishState = exports.PublishState.NOT_INITIALIZED;
|
|
4070
|
+
this._inputDeviceState = exports.StreamerState.NOT_INITIALIZED;
|
|
4071
|
+
this._cameraState = exports.DeviceState.NOT_INITIALIZED;
|
|
4072
|
+
this._microphoneState = exports.DeviceState.NOT_INITIALIZED;
|
|
4073
|
+
yield this.initializeDevices();
|
|
4074
|
+
yield this.startCamera();
|
|
4075
|
+
if ((_a = this._main.getConfigManager()) === null || _a === void 0 ? void 0 : _a.getSettingsData().autoConnect) {
|
|
4076
|
+
(_b = this._main.getNetworkController()) === null || _b === void 0 ? void 0 : _b.initialize();
|
|
4077
|
+
}
|
|
4078
|
+
if ((_c = this._main.getConfigManager()) === null || _c === void 0 ? void 0 : _c.getStreamData().streamKey) {
|
|
4079
|
+
this.createStatusConnection();
|
|
4080
|
+
}
|
|
4081
|
+
} catch (error) {
|
|
4082
|
+
this._logger.error(this, "Start failed: " + JSON.stringify(error));
|
|
4083
|
+
this.setInputDeviceState(exports.StreamerState.INVALID);
|
|
4084
|
+
throw error;
|
|
4085
|
+
}
|
|
4086
|
+
});
|
|
4087
|
+
}
|
|
3982
4088
|
destroy() {
|
|
3983
4089
|
if (window.screen && window.screen.orientation) {
|
|
3984
4090
|
window.screen.orientation.removeEventListener('change', this.handleOrientationChange);
|
|
@@ -4152,7 +4258,7 @@
|
|
|
4152
4258
|
};
|
|
4153
4259
|
this.onMessage = event => {
|
|
4154
4260
|
var _a;
|
|
4155
|
-
(_a = this._main.
|
|
4261
|
+
(_a = this._main.getStreamerController()) === null || _a === void 0 ? void 0 : _a.onSocketMessage(event.data);
|
|
4156
4262
|
};
|
|
4157
4263
|
this._main = main;
|
|
4158
4264
|
this._logger = main.getLogger();
|
|
@@ -4189,17 +4295,297 @@
|
|
|
4189
4295
|
}
|
|
4190
4296
|
}
|
|
4191
4297
|
|
|
4298
|
+
class StatsController {
|
|
4299
|
+
constructor(main) {
|
|
4300
|
+
this._publishVideoWidth = 0;
|
|
4301
|
+
this._publishVideoHeight = 0;
|
|
4302
|
+
this._publishVideoBitrate = 0;
|
|
4303
|
+
this._publishAudioBitrate = 0;
|
|
4304
|
+
this._currentBitrate = 0;
|
|
4305
|
+
this._currentFPS = 0;
|
|
4306
|
+
this._deliveredVideoFrames = 0;
|
|
4307
|
+
this._deliveredAudioFrames = 0;
|
|
4308
|
+
this.onStreamStatsUpdate = event => {
|
|
4309
|
+
this._publishVideoWidth = event.streamStatus.videoWidth;
|
|
4310
|
+
this._publishVideoHeight = event.streamStatus.videoHeight;
|
|
4311
|
+
this._currentBitrate = event.streamStatus.currentBitrate;
|
|
4312
|
+
this._publishVideoBitrate = event.streamStatus.videoPublishBitrate;
|
|
4313
|
+
this._publishAudioBitrate = event.streamStatus.audioPublishBitrate;
|
|
4314
|
+
this._currentFPS = event.streamStatus.frameRate;
|
|
4315
|
+
this._deliveredVideoFrames = event.streamStatus.videoFrameCount;
|
|
4316
|
+
this._deliveredAudioFrames = event.streamStatus.audioFrameCount;
|
|
4317
|
+
};
|
|
4318
|
+
this._main = main;
|
|
4319
|
+
this._logger = main.getLogger();
|
|
4320
|
+
this._logger.info(this, "Creating new StatsController");
|
|
4321
|
+
this.initialize();
|
|
4322
|
+
}
|
|
4323
|
+
initialize() {
|
|
4324
|
+
this._main.addEventListener("streamStatusUpdate", this.onStreamStatsUpdate, false);
|
|
4325
|
+
}
|
|
4326
|
+
get deliveredVideoFrames() {
|
|
4327
|
+
return this._deliveredVideoFrames;
|
|
4328
|
+
}
|
|
4329
|
+
get deliveredAudioFrames() {
|
|
4330
|
+
return this._deliveredAudioFrames;
|
|
4331
|
+
}
|
|
4332
|
+
get currentFPS() {
|
|
4333
|
+
return this._currentFPS;
|
|
4334
|
+
}
|
|
4335
|
+
get publishVideoWidth() {
|
|
4336
|
+
return this._publishVideoWidth;
|
|
4337
|
+
}
|
|
4338
|
+
get publishVideoHeight() {
|
|
4339
|
+
return this._publishVideoHeight;
|
|
4340
|
+
}
|
|
4341
|
+
get currentBitrate() {
|
|
4342
|
+
return this._currentBitrate;
|
|
4343
|
+
}
|
|
4344
|
+
get publishVideoBitrate() {
|
|
4345
|
+
return this._publishVideoBitrate;
|
|
4346
|
+
}
|
|
4347
|
+
get publishAudioBitrate() {
|
|
4348
|
+
return this._publishAudioBitrate;
|
|
4349
|
+
}
|
|
4350
|
+
}
|
|
4351
|
+
|
|
4352
|
+
class GraphDrawer {
|
|
4353
|
+
constructor(containerIdOrElement, valueRanges, colors, lineWidth = 1) {
|
|
4354
|
+
this._currentX = 0;
|
|
4355
|
+
this._isFullyDrawn = false;
|
|
4356
|
+
this._lastTimestamp = null;
|
|
4357
|
+
this._isTimemarkLine = false;
|
|
4358
|
+
this._borderWidth = 1;
|
|
4359
|
+
if (colors.length !== valueRanges.length + 1) {
|
|
4360
|
+
throw new Error(`Colors array must have exactly ${valueRanges.length + 1} elements (one more than valueRanges)`);
|
|
4361
|
+
}
|
|
4362
|
+
for (let i = 1; i < valueRanges.length; i++) {
|
|
4363
|
+
if (valueRanges[i] <= valueRanges[i - 1]) {
|
|
4364
|
+
throw new Error('ValueRanges must be in ascending order');
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
const hexColorRegex = /^#[0-9A-Fa-f]{6}$/;
|
|
4368
|
+
if (!colors.every(color => hexColorRegex.test(color))) {
|
|
4369
|
+
throw new Error('All colors must be in valid hex format (e.g., #FF0000)');
|
|
4370
|
+
}
|
|
4371
|
+
let container;
|
|
4372
|
+
if (typeof containerIdOrElement === 'string') {
|
|
4373
|
+
const foundElement = document.getElementById(containerIdOrElement);
|
|
4374
|
+
if (!foundElement) {
|
|
4375
|
+
throw new Error(`Container element with id ${containerIdOrElement} not found`);
|
|
4376
|
+
}
|
|
4377
|
+
container = foundElement;
|
|
4378
|
+
} else {
|
|
4379
|
+
container = containerIdOrElement;
|
|
4380
|
+
}
|
|
4381
|
+
const containerRect = container.getBoundingClientRect();
|
|
4382
|
+
this._width = Math.floor(containerRect.width);
|
|
4383
|
+
this._height = Math.floor(containerRect.height);
|
|
4384
|
+
this._effectiveWidth = this._width - this._borderWidth * 2;
|
|
4385
|
+
this._effectiveHeight = this._height - this._borderWidth * 2;
|
|
4386
|
+
this._canvas = document.createElement('canvas');
|
|
4387
|
+
container.appendChild(this._canvas);
|
|
4388
|
+
const context = this._canvas.getContext('2d', {
|
|
4389
|
+
willReadFrequently: true
|
|
4390
|
+
});
|
|
4391
|
+
if (!context) {
|
|
4392
|
+
throw new Error('Failed to get canvas context');
|
|
4393
|
+
}
|
|
4394
|
+
this._ctx = context;
|
|
4395
|
+
this._valueRanges = [0, ...valueRanges];
|
|
4396
|
+
this._colors = colors;
|
|
4397
|
+
this._lineWidth = lineWidth;
|
|
4398
|
+
this._canvas.width = this._width;
|
|
4399
|
+
this._canvas.height = this._height;
|
|
4400
|
+
this._canvas.style.width = `${this._width}px`;
|
|
4401
|
+
this._canvas.style.height = `${this._height}px`;
|
|
4402
|
+
this.clear();
|
|
4403
|
+
}
|
|
4404
|
+
drawBorder() {
|
|
4405
|
+
this._ctx.strokeStyle = '#000000';
|
|
4406
|
+
this._ctx.lineWidth = this._borderWidth;
|
|
4407
|
+
this._ctx.strokeRect(this._borderWidth / 2, this._borderWidth / 2, this._width - this._borderWidth, this._height - this._borderWidth);
|
|
4408
|
+
}
|
|
4409
|
+
clear() {
|
|
4410
|
+
this._ctx.clearRect(0, 0, this._width, this._height);
|
|
4411
|
+
this._ctx.fillStyle = this._colors[0];
|
|
4412
|
+
this._ctx.fillRect(this._borderWidth, this._borderWidth, this._effectiveWidth, this._effectiveHeight);
|
|
4413
|
+
this.drawBorder();
|
|
4414
|
+
this._isFullyDrawn = false;
|
|
4415
|
+
this._currentX = this._borderWidth;
|
|
4416
|
+
this._lastTimestamp = null;
|
|
4417
|
+
this._isTimemarkLine = false;
|
|
4418
|
+
}
|
|
4419
|
+
getColorIndices(value) {
|
|
4420
|
+
for (let i = 0; i < this._valueRanges.length - 1; i++) {
|
|
4421
|
+
if (value >= this._valueRanges[i] && value <= this._valueRanges[i + 1]) {
|
|
4422
|
+
return {
|
|
4423
|
+
lowerIndex: i,
|
|
4424
|
+
upperIndex: i + 1
|
|
4425
|
+
};
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
return {
|
|
4429
|
+
lowerIndex: this._valueRanges.length - 2,
|
|
4430
|
+
upperIndex: this._valueRanges.length - 1
|
|
4431
|
+
};
|
|
4432
|
+
}
|
|
4433
|
+
calculateHeightRatio(value, lowerBound, upperBound) {
|
|
4434
|
+
return (value - lowerBound) / (upperBound - lowerBound);
|
|
4435
|
+
}
|
|
4436
|
+
shiftCanvasLeft(shiftAmount) {
|
|
4437
|
+
const imageData = this._ctx.getImageData(this._borderWidth + shiftAmount, this._borderWidth, this._effectiveWidth - shiftAmount, this._effectiveHeight);
|
|
4438
|
+
this._ctx.fillStyle = this._colors[0];
|
|
4439
|
+
this._ctx.fillRect(this._borderWidth, this._borderWidth, this._effectiveWidth, this._effectiveHeight);
|
|
4440
|
+
this._ctx.putImageData(imageData, this._borderWidth, this._borderWidth);
|
|
4441
|
+
this.drawBorder();
|
|
4442
|
+
}
|
|
4443
|
+
applyOverlayEffect(baseColor, overlayOpacity = 0.5) {
|
|
4444
|
+
const r = parseInt(baseColor.slice(1, 3), 16);
|
|
4445
|
+
const g = parseInt(baseColor.slice(3, 5), 16);
|
|
4446
|
+
const b = parseInt(baseColor.slice(5, 7), 16);
|
|
4447
|
+
const overlayChannel = base => {
|
|
4448
|
+
const normalized = base / 255;
|
|
4449
|
+
let result;
|
|
4450
|
+
if (normalized <= 0.5) {
|
|
4451
|
+
result = 2 * normalized * 1;
|
|
4452
|
+
} else {
|
|
4453
|
+
result = 1 - 2 * (1 - normalized) * (1 - 1);
|
|
4454
|
+
}
|
|
4455
|
+
return Math.round(result * 255 * overlayOpacity + base * (1 - overlayOpacity));
|
|
4456
|
+
};
|
|
4457
|
+
const newR = overlayChannel(r);
|
|
4458
|
+
const newG = overlayChannel(g);
|
|
4459
|
+
const newB = overlayChannel(b);
|
|
4460
|
+
const toHex = n => {
|
|
4461
|
+
const hex = n.toString(16);
|
|
4462
|
+
return hex.length === 1 ? '0' + hex : hex;
|
|
4463
|
+
};
|
|
4464
|
+
return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;
|
|
4465
|
+
}
|
|
4466
|
+
addEntry(value) {
|
|
4467
|
+
value = Math.round(value * 100) / 100;
|
|
4468
|
+
const currentTime = Date.now();
|
|
4469
|
+
if (this._lastTimestamp === null) {
|
|
4470
|
+
this._lastTimestamp = currentTime;
|
|
4471
|
+
this._isTimemarkLine = false;
|
|
4472
|
+
} else {
|
|
4473
|
+
const timeDiff = currentTime - this._lastTimestamp;
|
|
4474
|
+
if (timeDiff >= 1000) {
|
|
4475
|
+
this._isTimemarkLine = true;
|
|
4476
|
+
this._lastTimestamp = currentTime;
|
|
4477
|
+
} else {
|
|
4478
|
+
this._isTimemarkLine = false;
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
const drawWidth = this._isTimemarkLine ? 1 : this._lineWidth;
|
|
4482
|
+
if (!this._isFullyDrawn && this._currentX >= this._width - this._borderWidth) {
|
|
4483
|
+
this._isFullyDrawn = true;
|
|
4484
|
+
}
|
|
4485
|
+
if (this._isFullyDrawn) {
|
|
4486
|
+
this.shiftCanvasLeft(drawWidth);
|
|
4487
|
+
this.drawLine(this._width - this._borderWidth - drawWidth, value, drawWidth);
|
|
4488
|
+
} else {
|
|
4489
|
+
this.drawLine(this._currentX, value, drawWidth);
|
|
4490
|
+
this._currentX += drawWidth;
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
drawLine(x, value, width) {
|
|
4494
|
+
const {
|
|
4495
|
+
lowerIndex,
|
|
4496
|
+
upperIndex
|
|
4497
|
+
} = this.getColorIndices(value);
|
|
4498
|
+
const ratio = this.calculateHeightRatio(value, this._valueRanges[lowerIndex], this._valueRanges[upperIndex]);
|
|
4499
|
+
let lowerColor = this._colors[lowerIndex];
|
|
4500
|
+
let upperColor = this._colors[upperIndex];
|
|
4501
|
+
if (this._isTimemarkLine) {
|
|
4502
|
+
lowerColor = this.applyOverlayEffect(lowerColor, 0.3);
|
|
4503
|
+
upperColor = this.applyOverlayEffect(upperColor, 0.3);
|
|
4504
|
+
}
|
|
4505
|
+
const upperHeight = Math.round(this._effectiveHeight * ratio);
|
|
4506
|
+
const lowerHeight = this._effectiveHeight - upperHeight;
|
|
4507
|
+
this._ctx.fillStyle = lowerColor;
|
|
4508
|
+
this._ctx.fillRect(x, this._height - this._borderWidth - lowerHeight, width, lowerHeight);
|
|
4509
|
+
this._ctx.fillStyle = upperColor;
|
|
4510
|
+
this._ctx.fillRect(x, this._borderWidth, width, upperHeight);
|
|
4511
|
+
}
|
|
4512
|
+
clearGraph() {
|
|
4513
|
+
this._currentX = this._borderWidth;
|
|
4514
|
+
this._isFullyDrawn = false;
|
|
4515
|
+
this._lastTimestamp = null;
|
|
4516
|
+
this._isTimemarkLine = false;
|
|
4517
|
+
this.clear();
|
|
4518
|
+
}
|
|
4519
|
+
destroy() {
|
|
4520
|
+
if (this._canvas.parentNode) {
|
|
4521
|
+
this._canvas.parentNode.removeChild(this._canvas);
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
|
|
4526
|
+
class BitrateGraph {
|
|
4527
|
+
constructor(main, container) {
|
|
4528
|
+
this.onStreamStatsUpdate = event => {
|
|
4529
|
+
var _a;
|
|
4530
|
+
(_a = this._graph) === null || _a === void 0 ? void 0 : _a.addEntry(event.streamStatus.currentBitrate);
|
|
4531
|
+
};
|
|
4532
|
+
this._main = main;
|
|
4533
|
+
this._object = container;
|
|
4534
|
+
this._main.addGraph(this);
|
|
4535
|
+
}
|
|
4536
|
+
start() {
|
|
4537
|
+
if (this._graph != null) stop();
|
|
4538
|
+
const valueRanges = [1000000, 2000000, 3000000, 5000000, 6000000, 7000000];
|
|
4539
|
+
const colors = ['#000000', '#0a3980', '#2793dd', '#3bc39c', '#c3df3e', '#f89539', '#f83f3f'];
|
|
4540
|
+
this._graph = new GraphDrawer(this._object, valueRanges, colors);
|
|
4541
|
+
this._main.addEventListener("streamStatusUpdate", this.onStreamStatsUpdate);
|
|
4542
|
+
return this;
|
|
4543
|
+
}
|
|
4544
|
+
stop() {
|
|
4545
|
+
this._main.removeEventListener("streamStatusUpdate", this.onStreamStatsUpdate);
|
|
4546
|
+
if (this._graph != null) this._graph.destroy();
|
|
4547
|
+
this._graph = null;
|
|
4548
|
+
return this;
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
class FPSGraph {
|
|
4553
|
+
constructor(main, container) {
|
|
4554
|
+
this.onStreamStatsUpdate = event => {
|
|
4555
|
+
var _a;
|
|
4556
|
+
(_a = this._graph) === null || _a === void 0 ? void 0 : _a.addEntry(event.streamStatus.frameRate);
|
|
4557
|
+
};
|
|
4558
|
+
this._main = main;
|
|
4559
|
+
this._object = container;
|
|
4560
|
+
this._main.addGraph(this);
|
|
4561
|
+
}
|
|
4562
|
+
start() {
|
|
4563
|
+
if (this._graph != null) stop();
|
|
4564
|
+
const valueRanges = [25, 26, 27, 28, 29, 30];
|
|
4565
|
+
const colors = ['#000000', '#0a3980', '#2793dd', '#3bc39c', '#c3df3e', '#f89539', '#f83f3f'];
|
|
4566
|
+
this._graph = new GraphDrawer(this._object, valueRanges, colors);
|
|
4567
|
+
this._main.addEventListener("streamStatusUpdate", this.onStreamStatsUpdate);
|
|
4568
|
+
return this;
|
|
4569
|
+
}
|
|
4570
|
+
stop() {
|
|
4571
|
+
this._main.removeEventListener("streamStatusUpdate", this.onStreamStatsUpdate);
|
|
4572
|
+
if (this._graph != null) this._graph.destroy();
|
|
4573
|
+
this._graph = null;
|
|
4574
|
+
return this;
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
|
|
4192
4578
|
class StormStreamer extends EventDispatcher {
|
|
4193
4579
|
constructor(streamConfig, autoInitialize = false) {
|
|
4194
4580
|
super();
|
|
4195
4581
|
this.DEV_MODE = true;
|
|
4196
|
-
this.STREAMER_VERSION = "0.9.
|
|
4197
|
-
this.COMPILE_DATE = "
|
|
4582
|
+
this.STREAMER_VERSION = "0.9.2-beta.0";
|
|
4583
|
+
this.COMPILE_DATE = "3/6/2025, 12:46:45 PM";
|
|
4198
4584
|
this.STREAMER_BRANCH = "Experimental";
|
|
4199
4585
|
this.STREAMER_PROTOCOL_VERSION = 1;
|
|
4200
4586
|
this._initialized = false;
|
|
4201
4587
|
if (typeof window === 'undefined' || !window.document || !window.document.createElement) {
|
|
4202
|
-
console.error(`
|
|
4588
|
+
console.error(`StormStreamer Creation Error - No "window" element in the provided context!`);
|
|
4203
4589
|
return;
|
|
4204
4590
|
}
|
|
4205
4591
|
if (this.DEV_MODE && !('StormStreamerArray' in window)) {
|
|
@@ -4213,12 +4599,13 @@
|
|
|
4213
4599
|
}
|
|
4214
4600
|
initialize() {
|
|
4215
4601
|
if (this._isRemoved) return;
|
|
4216
|
-
if (this._configManager == null) throw Error("Stream Config was not provided for this
|
|
4602
|
+
if (this._configManager == null) throw Error("Stream Config was not provided for this streamer! A properly configured object must be provided through the constructor or via the setConfig method before using the initialize() method.");
|
|
4217
4603
|
this._storageManager = new StorageManager(this);
|
|
4218
4604
|
this._stageController = new StageController(this);
|
|
4219
4605
|
this._networkController = new NetworkController(this);
|
|
4220
|
-
this.
|
|
4221
|
-
this.
|
|
4606
|
+
this._streamerController = new StreamerController(this);
|
|
4607
|
+
this._statsController = new StatsController(this);
|
|
4608
|
+
this._graphs = [];
|
|
4222
4609
|
this._initialized = true;
|
|
4223
4610
|
this.dispatchEvent("streamerReady", {
|
|
4224
4611
|
ref: this
|
|
@@ -4249,27 +4636,10 @@
|
|
|
4249
4636
|
});
|
|
4250
4637
|
}
|
|
4251
4638
|
}
|
|
4252
|
-
stop() {}
|
|
4253
4639
|
isConnected() {
|
|
4254
4640
|
var _a, _b;
|
|
4255
4641
|
return (_b = (_a = this._networkController) === null || _a === void 0 ? void 0 : _a.getConnection().isConnectionActive()) !== null && _b !== void 0 ? _b : false;
|
|
4256
4642
|
}
|
|
4257
|
-
attachToContainer(container) {
|
|
4258
|
-
var _a, _b;
|
|
4259
|
-
let result = false;
|
|
4260
|
-
if (this._initialized) return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.attachToParent(container)) !== null && _b !== void 0 ? _b : false;
|
|
4261
|
-
return result;
|
|
4262
|
-
}
|
|
4263
|
-
detachFromContainer() {
|
|
4264
|
-
var _a, _b;
|
|
4265
|
-
let result = false;
|
|
4266
|
-
if (this._initialized) return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.detachFromParent()) !== null && _b !== void 0 ? _b : false;
|
|
4267
|
-
return result;
|
|
4268
|
-
}
|
|
4269
|
-
getContainer() {
|
|
4270
|
-
var _a, _b;
|
|
4271
|
-
return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.getParentElement()) !== null && _b !== void 0 ? _b : null;
|
|
4272
|
-
}
|
|
4273
4643
|
mute() {
|
|
4274
4644
|
if (this._stageController != null) {
|
|
4275
4645
|
if (this._stageController.getScreenElement() != null) {
|
|
@@ -4314,69 +4684,89 @@
|
|
|
4314
4684
|
}
|
|
4315
4685
|
getCameraList() {
|
|
4316
4686
|
var _a, _b;
|
|
4317
|
-
return (_b = (_a = this.
|
|
4687
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getCameraList()) !== null && _b !== void 0 ? _b : [];
|
|
4318
4688
|
}
|
|
4319
4689
|
getMicrophoneList() {
|
|
4320
4690
|
var _a, _b;
|
|
4321
|
-
return (_b = (_a = this.
|
|
4691
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getMicrophoneList()) !== null && _b !== void 0 ? _b : [];
|
|
4322
4692
|
}
|
|
4323
4693
|
setCamera(cameraID) {
|
|
4324
4694
|
var _a;
|
|
4325
|
-
(_a = this.
|
|
4695
|
+
(_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.selectCamera(cameraID);
|
|
4326
4696
|
}
|
|
4327
4697
|
setMicrophone(microphoneID) {
|
|
4328
4698
|
var _a;
|
|
4329
|
-
(_a = this.
|
|
4699
|
+
(_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.selectMicrophone(microphoneID);
|
|
4330
4700
|
}
|
|
4331
4701
|
getCurrentCamera() {
|
|
4332
|
-
return this.
|
|
4702
|
+
return this._streamerController.getCurrentCamera();
|
|
4333
4703
|
}
|
|
4334
4704
|
getCurrentMicrophone() {
|
|
4335
|
-
return this.
|
|
4705
|
+
return this._streamerController.getCurrentMicrophone();
|
|
4336
4706
|
}
|
|
4337
4707
|
muteMicrophone(microphoneState) {
|
|
4338
4708
|
var _a;
|
|
4339
|
-
(_a = this.
|
|
4709
|
+
(_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.muteMicrophone(microphoneState);
|
|
4340
4710
|
}
|
|
4341
4711
|
isMicrophoneMuted() {
|
|
4342
4712
|
var _a, _b;
|
|
4343
|
-
return (_b = (_a = this.
|
|
4713
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.isMicrophoneMuted()) !== null && _b !== void 0 ? _b : false;
|
|
4344
4714
|
}
|
|
4345
4715
|
getPublishState() {
|
|
4346
4716
|
var _a, _b;
|
|
4347
|
-
return (_b = (_a = this.
|
|
4717
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getPublishState()) !== null && _b !== void 0 ? _b : exports.PublishState.NOT_INITIALIZED;
|
|
4718
|
+
}
|
|
4719
|
+
getPublishTime() {
|
|
4720
|
+
var _a, _b;
|
|
4721
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getPublishTime()) !== null && _b !== void 0 ? _b : 0;
|
|
4348
4722
|
}
|
|
4349
4723
|
publish(streamKey) {
|
|
4350
4724
|
var _a, _b;
|
|
4351
|
-
return (_b = (_a = this.
|
|
4725
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.publish(streamKey)) !== null && _b !== void 0 ? _b : false;
|
|
4352
4726
|
}
|
|
4353
|
-
|
|
4727
|
+
getInputDeviceState() {
|
|
4354
4728
|
var _a, _b;
|
|
4355
|
-
return (_b = (_a = this.
|
|
4729
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getInputDeviceState()) !== null && _b !== void 0 ? _b : exports.StreamerState.NOT_INITIALIZED;
|
|
4356
4730
|
}
|
|
4357
4731
|
getCamerState() {
|
|
4358
4732
|
var _a, _b;
|
|
4359
|
-
return (_b = (_a = this.
|
|
4733
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getCamerState()) !== null && _b !== void 0 ? _b : exports.DeviceState.NOT_INITIALIZED;
|
|
4360
4734
|
}
|
|
4361
4735
|
getMicrophoneState() {
|
|
4362
4736
|
var _a, _b;
|
|
4363
|
-
return (_b = (_a = this.
|
|
4737
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getMicrophoneState()) !== null && _b !== void 0 ? _b : exports.DeviceState.NOT_INITIALIZED;
|
|
4364
4738
|
}
|
|
4365
4739
|
clearSavedDevices() {
|
|
4366
4740
|
var _a;
|
|
4367
|
-
return (_a = this.
|
|
4741
|
+
return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.clearSavedDevices();
|
|
4368
4742
|
}
|
|
4369
4743
|
messSavedDevices() {
|
|
4370
4744
|
var _a;
|
|
4371
|
-
return (_a = this.
|
|
4745
|
+
return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.messSavedDevices();
|
|
4372
4746
|
}
|
|
4373
4747
|
isStreamReady() {
|
|
4374
4748
|
var _a, _b;
|
|
4375
|
-
return (_b = (_a = this.
|
|
4749
|
+
return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.isStreamReady()) !== null && _b !== void 0 ? _b : false;
|
|
4376
4750
|
}
|
|
4377
4751
|
unpublish() {
|
|
4378
4752
|
var _a;
|
|
4379
|
-
(_a = this.
|
|
4753
|
+
(_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.unpublish();
|
|
4754
|
+
}
|
|
4755
|
+
attachToContainer(container) {
|
|
4756
|
+
var _a, _b;
|
|
4757
|
+
let result = false;
|
|
4758
|
+
if (this._initialized) return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.attachToParent(container)) !== null && _b !== void 0 ? _b : false;
|
|
4759
|
+
return result;
|
|
4760
|
+
}
|
|
4761
|
+
detachFromContainer() {
|
|
4762
|
+
var _a, _b;
|
|
4763
|
+
let result = false;
|
|
4764
|
+
if (this._initialized) return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.detachFromParent()) !== null && _b !== void 0 ? _b : false;
|
|
4765
|
+
return result;
|
|
4766
|
+
}
|
|
4767
|
+
getContainer() {
|
|
4768
|
+
var _a, _b;
|
|
4769
|
+
return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.getParentElement()) !== null && _b !== void 0 ? _b : null;
|
|
4380
4770
|
}
|
|
4381
4771
|
setSize(width, height) {
|
|
4382
4772
|
if (this._initialized) this._stageController.setSize(width, height);else {
|
|
@@ -4454,6 +4844,22 @@
|
|
|
4454
4844
|
}
|
|
4455
4845
|
});
|
|
4456
4846
|
}
|
|
4847
|
+
createFPSGraph(container) {
|
|
4848
|
+
return new FPSGraph(this, container);
|
|
4849
|
+
}
|
|
4850
|
+
createBitrateGraph(container) {
|
|
4851
|
+
return new BitrateGraph(this, container);
|
|
4852
|
+
}
|
|
4853
|
+
addGraph(newGraph) {
|
|
4854
|
+
if (this._graphs != null) this._graphs.push(newGraph);
|
|
4855
|
+
}
|
|
4856
|
+
stopAllGraphs() {
|
|
4857
|
+
if (this._graphs != null && this._graphs.length > 0) {
|
|
4858
|
+
for (let i = 0; i < this._graphs.length; i++) {
|
|
4859
|
+
this._graphs[i].stop();
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
}
|
|
4457
4863
|
enterFullScreen() {
|
|
4458
4864
|
if (this._initialized && this._stageController) this._stageController.enterFullScreen();
|
|
4459
4865
|
}
|
|
@@ -4464,6 +4870,13 @@
|
|
|
4464
4870
|
if (this._initialized && this._stageController) return this._stageController.isFullScreenMode();
|
|
4465
4871
|
return false;
|
|
4466
4872
|
}
|
|
4873
|
+
getStreamKey() {
|
|
4874
|
+
var _a, _b, _c;
|
|
4875
|
+
return (_c = (_b = (_a = this.getConfigManager()) === null || _a === void 0 ? void 0 : _a.getStreamData()) === null || _b === void 0 ? void 0 : _b.streamKey) !== null && _c !== void 0 ? _c : null;
|
|
4876
|
+
}
|
|
4877
|
+
getStatsController() {
|
|
4878
|
+
return this._statsController;
|
|
4879
|
+
}
|
|
4467
4880
|
getStreamerID() {
|
|
4468
4881
|
return this._streamerID;
|
|
4469
4882
|
}
|
|
@@ -4476,8 +4889,8 @@
|
|
|
4476
4889
|
getNetworkController() {
|
|
4477
4890
|
return this._networkController;
|
|
4478
4891
|
}
|
|
4479
|
-
|
|
4480
|
-
return this.
|
|
4892
|
+
getStreamerController() {
|
|
4893
|
+
return this._streamerController;
|
|
4481
4894
|
}
|
|
4482
4895
|
getStageController() {
|
|
4483
4896
|
return this._stageController;
|
|
@@ -4501,14 +4914,24 @@
|
|
|
4501
4914
|
dispatchEvent(eventName, event) {
|
|
4502
4915
|
super.dispatchEvent(eventName, event);
|
|
4503
4916
|
}
|
|
4917
|
+
start() {
|
|
4918
|
+
var _a;
|
|
4919
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4920
|
+
return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.start();
|
|
4921
|
+
});
|
|
4922
|
+
}
|
|
4923
|
+
stop() {
|
|
4924
|
+
var _a;
|
|
4925
|
+
return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.stop();
|
|
4926
|
+
}
|
|
4504
4927
|
destroy() {
|
|
4505
4928
|
var _a, _b, _c, _d;
|
|
4506
|
-
this._logger.warning(this, "Destroying
|
|
4929
|
+
this._logger.warning(this, "Destroying streamer instance, bye, bye!");
|
|
4507
4930
|
if (this.DEV_MODE && 'StormStreamerArray' in window) window.StormStreamerArray[this._streamerID] = null;
|
|
4508
4931
|
this._initialized = false;
|
|
4509
4932
|
this._isRemoved = true;
|
|
4510
4933
|
(_b = (_a = this._networkController) === null || _a === void 0 ? void 0 : _a.getConnection()) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
4511
|
-
(_c = this.
|
|
4934
|
+
(_c = this._streamerController) === null || _c === void 0 ? void 0 : _c.destroy();
|
|
4512
4935
|
(_d = this._stageController) === null || _d === void 0 ? void 0 : _d.destroy();
|
|
4513
4936
|
this.removeAllEventListeners();
|
|
4514
4937
|
}
|