@stormstreaming/stormstreamer 0.9.1-beta.3 → 0.9.2-beta.1

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 CHANGED
@@ -4,8 +4,8 @@
4
4
  * contact@stormstreaming.com
5
5
  * https://stormstreaming.com
6
6
  *
7
- * Version: 0.9.1-beta.3
8
- * Version: 1/25/2025, 7:07:05 AM
7
+ * Version: 0.9.2-beta.1
8
+ * Version: 3/6/2025, 1:40:53 PM
9
9
  *
10
10
  * LEGAL NOTICE:
11
11
  * This software is subject to the terms and conditions defined in
@@ -372,10 +372,12 @@
372
372
  this._containerLogEnabled = false;
373
373
  this._enabledContainerTypes = [LogType.INFO, LogType.ERROR, LogType.SUCCESS, LogType.TRACE, LogType.WARNING];
374
374
  this._containerLogMonoColor = false;
375
+ this._stageController = true;
376
+ this._streamerController = true;
375
377
  this.parse(debugConfig);
376
378
  }
377
379
  parse(debugConfig) {
378
- 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;
379
381
  this._debugConfig = debugConfig;
380
382
  if (this._debugConfig) {
381
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;
@@ -385,6 +387,8 @@
385
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;
386
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;
387
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;
388
392
  }
389
393
  }
390
394
  parseLogTypes(logTypes) {
@@ -485,6 +489,12 @@
485
489
  set containerLogMonoColor(newValue) {
486
490
  this._containerLogMonoColor = newValue;
487
491
  }
492
+ get stageControllerDebug() {
493
+ return this._stageController;
494
+ }
495
+ get streamerControllerDebug() {
496
+ return this._streamerController;
497
+ }
488
498
  print(logger, force = false) {
489
499
  if (DebugData.PRINT_ON_STARTUP || force) {
490
500
  let consoleLogTypes = "";
@@ -876,6 +886,23 @@
876
886
  }
877
887
  }
878
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
+ }
879
906
  error(objectName, message) {
880
907
  let output = this.logData(objectName, message);
881
908
  if (this._debugConfig.consoleLogEnabled) {
@@ -955,18 +982,6 @@
955
982
  Logger.SUCCESS_COLOR = "green";
956
983
  Logger.TRACE_COLOR = "black";
957
984
 
958
- class ClientUser {
959
- constructor() {
960
- this.bandwidthCapabilities = 0;
961
- }
962
- setBandwidthCapabilities(newCapabilities) {
963
- this.bandwidthCapabilities = newCapabilities;
964
- }
965
- getBandwidthCapabilities() {
966
- return this.bandwidthCapabilities;
967
- }
968
- }
969
-
970
985
  class UserCapabilities {
971
986
  static hasWebSocketsSupport() {
972
987
  return window.WebSocket != null;
@@ -1761,6 +1776,7 @@
1761
1776
  this._isResizing = false;
1762
1777
  this._autoResizeEnabled = true;
1763
1778
  this._parentOriginalOverflow = '';
1779
+ this._debug = false;
1764
1780
  this.onFullScreenChange = () => {
1765
1781
  if (document.fullscreenElement == null) {
1766
1782
  this.isInFullScreenMode = false;
@@ -1782,9 +1798,10 @@
1782
1798
  this.initialize();
1783
1799
  }
1784
1800
  initialize() {
1785
- var _a, _b, _c, _d, _e, _f;
1801
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1786
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;
1787
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;
1788
1805
  this._videoContainer = document.createElement('div');
1789
1806
  this._videoContainer.setAttribute("id", "stormStreamer_" + this._main.getStreamerID());
1790
1807
  this._videoContainer.style.overflow = "hidden";
@@ -1830,10 +1847,12 @@
1830
1847
  tempParentElement = container;
1831
1848
  }
1832
1849
  if (tempParentElement === this._parentElement) {
1850
+ if (this._debug) this._logger.decoratedLog("Attaching Failed (container is the same)", "dark-pink");
1833
1851
  this._logger.warning(this, "attachToParent :: container is the same");
1834
1852
  return false;
1835
1853
  }
1836
1854
  if (tempParentElement && this._videoContainer) {
1855
+ if (this._debug) this._logger.decoratedLog("Attach To Parent: " + container + " (success)", "dark-pink");
1837
1856
  this._parentElement = tempParentElement;
1838
1857
  this._parentElement.appendChild(this._videoContainer);
1839
1858
  this._resizeObserver.observe(this._parentElement);
@@ -1847,13 +1866,13 @@
1847
1866
  this.handleResize();
1848
1867
  result = true;
1849
1868
  } else {
1850
- console.log("tempParentElement", tempParentElement);
1851
- console.log("this._videoContainer", this._videoContainer);
1852
- 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");
1853
1871
  }
1854
1872
  return result;
1855
1873
  }
1856
1874
  detachFromParent() {
1875
+ if (this._debug) this._logger.decoratedLog("Detach From Parent", "dark-pink");
1857
1876
  let result = false;
1858
1877
  if (this._parentElement != null && this._videoContainer != null) {
1859
1878
  this._logger.info(this, "Detaching from parent: " + this._videoContainer);
@@ -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;
@@ -2570,16 +2587,16 @@
2570
2587
  }
2571
2588
  }
2572
2589
 
2573
- exports.StreamerState = void 0;
2574
- (function (StreamerState) {
2575
- StreamerState["NOT_INITIALIZED"] = "NOT_INITIALIZED";
2576
- StreamerState["INITIALIZED"] = "INITIALIZED";
2577
- StreamerState["READY"] = "READY";
2578
- StreamerState["UPDATING"] = "UPDATING";
2579
- StreamerState["INVALID"] = "INVALID";
2580
- StreamerState["UNKNOWN"] = "UNKNOWN";
2581
- StreamerState["STOPPED"] = "STOPPED";
2582
- })(exports.StreamerState || (exports.StreamerState = {}));
2590
+ exports.InputDevicesState = void 0;
2591
+ (function (InputDevicesState) {
2592
+ InputDevicesState["NOT_INITIALIZED"] = "NOT_INITIALIZED";
2593
+ InputDevicesState["INITIALIZED"] = "INITIALIZED";
2594
+ InputDevicesState["READY"] = "READY";
2595
+ InputDevicesState["UPDATING"] = "UPDATING";
2596
+ InputDevicesState["INVALID"] = "INVALID";
2597
+ InputDevicesState["UNKNOWN"] = "UNKNOWN";
2598
+ InputDevicesState["STOPPED"] = "STOPPED";
2599
+ })(exports.InputDevicesState || (exports.InputDevicesState = {}));
2583
2600
 
2584
2601
  exports.DeviceState = void 0;
2585
2602
  (function (DeviceState) {
@@ -2708,11 +2725,14 @@
2708
2725
  class StreamStatusInfo {
2709
2726
  constructor() {
2710
2727
  this._publishState = exports.PublishState.NOT_INITIALIZED;
2711
- this._videoBitrate = 0;
2712
- this._audioBitrate = 0;
2728
+ this._videoPublishBitrate = 0;
2729
+ this._audioPublishBitrate = 0;
2730
+ this._currentBitrate = 0;
2713
2731
  this._audioFrameCount = 0;
2714
2732
  this._videoFrameCount = 0;
2715
2733
  this._frameRate = 0;
2734
+ this._videoWidth = 0;
2735
+ this._videoHeight = 0;
2716
2736
  }
2717
2737
  get publishState() {
2718
2738
  return this._publishState;
@@ -2720,17 +2740,23 @@
2720
2740
  set publishState(value) {
2721
2741
  this._publishState = value === "published" ? exports.PublishState.PUBLISHED : exports.PublishState.CONNECTED;
2722
2742
  }
2723
- get videoBitrate() {
2724
- return this._videoBitrate;
2743
+ get videoPublishBitrate() {
2744
+ return this._videoPublishBitrate;
2745
+ }
2746
+ set videoPublishBitrate(value) {
2747
+ this._videoPublishBitrate = value;
2725
2748
  }
2726
- set videoBitrate(value) {
2727
- this._videoBitrate = value;
2749
+ get audioPublishBitrate() {
2750
+ return this._audioPublishBitrate;
2728
2751
  }
2729
- get audioBitrate() {
2730
- return this._audioBitrate;
2752
+ set audioPublishBitrate(value) {
2753
+ this._audioPublishBitrate = value;
2731
2754
  }
2732
- set audioBitrate(value) {
2733
- this._audioBitrate = value;
2755
+ set currentBitrate(value) {
2756
+ this._currentBitrate = value;
2757
+ }
2758
+ get currentBitrate() {
2759
+ return this._currentBitrate;
2734
2760
  }
2735
2761
  get audioFrameCount() {
2736
2762
  return this._audioFrameCount;
@@ -2750,6 +2776,18 @@
2750
2776
  set frameRate(value) {
2751
2777
  this._frameRate = value;
2752
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
+ }
2753
2791
  }
2754
2792
 
2755
2793
  class WowzaStatusConnection extends AbstractSocket {
@@ -2809,11 +2847,15 @@
2809
2847
  case "STREAM_STATUS_RESPONSE":
2810
2848
  const streamStatusInfo = new StreamStatusInfo();
2811
2849
  streamStatusInfo.publishState = msgJSON.streamStatus;
2812
- streamStatusInfo.videoBitrate = msgJSON.videoBitrate;
2813
- streamStatusInfo.audioBitrate = msgJSON.audioBitrate;
2850
+ streamStatusInfo.videoPublishBitrate = msgJSON.publishVideoBitrate;
2851
+ streamStatusInfo.audioPublishBitrate = msgJSON.publishAudioBitrate;
2814
2852
  streamStatusInfo.videoFrameCount = msgJSON.videoFrameCount;
2815
2853
  streamStatusInfo.audioFrameCount = msgJSON.audioFrameCount;
2816
2854
  streamStatusInfo.frameRate = msgJSON.frameRate;
2855
+ streamStatusInfo.videoWidth = msgJSON.videoWidth;
2856
+ streamStatusInfo.videoHeight = msgJSON.videoHeight;
2857
+ streamStatusInfo.currentBitrate = msgJSON.realBitrate;
2858
+ console.log(streamStatusInfo);
2817
2859
  this._main.dispatchEvent("streamStatusUpdate", {
2818
2860
  ref: this._main,
2819
2861
  streamStatus: streamStatusInfo
@@ -2901,9 +2943,9 @@
2901
2943
  }
2902
2944
  }
2903
2945
 
2904
- class PlaybackController {
2946
+ class StreamerController {
2905
2947
  constructor(main) {
2906
- var _a;
2948
+ var _a, _b, _c;
2907
2949
  this._isWindowActive = true;
2908
2950
  this._peerConnectionConfig = {
2909
2951
  'iceServers': []
@@ -2934,27 +2976,29 @@
2934
2976
  this._restartTimerCount = 0;
2935
2977
  this._restartTimerMaxCount = 5;
2936
2978
  this._publishState = exports.PublishState.NOT_INITIALIZED;
2937
- this._inputDeviceState = exports.StreamerState.NOT_INITIALIZED;
2979
+ this._publishTime = 0;
2980
+ this._inputDeviceState = exports.InputDevicesState.NOT_INITIALIZED;
2938
2981
  this._cameraState = exports.DeviceState.NOT_INITIALIZED;
2939
2982
  this._microphoneState = exports.DeviceState.NOT_INITIALIZED;
2940
2983
  this._publishTimer = 0;
2941
2984
  this._currentOrientation = ((_a = window.screen.orientation) === null || _a === void 0 ? void 0 : _a.type) || '';
2942
2985
  this._statusTimer = null;
2986
+ this._debug = false;
2943
2987
  this.onDeviceStateChange = event => {
2944
2988
  var _a;
2945
2989
  const usedStreamKey = (_a = this._main.getConfigManager()) === null || _a === void 0 ? void 0 : _a.getStreamData().streamKey;
2946
- if (event.state == exports.StreamerState.READY && usedStreamKey != null) {
2990
+ if (event.state == exports.InputDevicesState.READY && usedStreamKey != null) {
2947
2991
  this.publish(usedStreamKey);
2948
2992
  }
2949
2993
  };
2950
2994
  this.handleOrientationChange = () => __awaiter(this, void 0, void 0, function* () {
2951
- var _b, _c;
2995
+ var _d, _e;
2952
2996
  yield new Promise(resolve => setTimeout(resolve, 500));
2953
- const newOrientation = ((_b = window.screen.orientation) === null || _b === void 0 ? void 0 : _b.type) || '';
2997
+ const newOrientation = ((_d = window.screen.orientation) === null || _d === void 0 ? void 0 : _d.type) || '';
2954
2998
  if (this._currentOrientation !== newOrientation) {
2955
2999
  this._logger.info(this, `Orientation changed from ${this._currentOrientation} to ${newOrientation}`);
2956
3000
  this._currentOrientation = newOrientation;
2957
- const streamKey = (_c = this._main.getConfigManager()) === null || _c === void 0 ? void 0 : _c.getStreamData().streamKey;
3001
+ const streamKey = (_e = this._main.getConfigManager()) === null || _e === void 0 ? void 0 : _e.getStreamData().streamKey;
2958
3002
  this._publishState === exports.PublishState.PUBLISHED;
2959
3003
  this.closeWebRTCConnection();
2960
3004
  if (this._stream) {
@@ -2970,7 +3014,7 @@
2970
3014
  }
2971
3015
  } catch (error) {
2972
3016
  this._logger.error(this, "Error restarting stream after orientation change: " + JSON.stringify(error));
2973
- this.setInputDeviceState(exports.StreamerState.INVALID);
3017
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
2974
3018
  }
2975
3019
  }
2976
3020
  });
@@ -3044,12 +3088,16 @@
3044
3088
  if (this._statusTimer == null) {
3045
3089
  if (this._statusConnection != null && usedStreamKey != null) {
3046
3090
  this._statusTimer = setInterval(() => {
3047
- var _a;
3048
- (_a = this._statusConnection) === null || _a === void 0 ? void 0 : _a.sendData('{"packetID":"STREAM_STATUS", "streamKey": "' + usedStreamKey + '"}');
3091
+ this.requestStatusData();
3049
3092
  }, 1000);
3050
3093
  }
3051
3094
  }
3052
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
+ };
3053
3101
  this.onStatusServerDisconnect = () => {
3054
3102
  if (this._statusTimer != null) clearInterval(this._statusTimer);
3055
3103
  this._statusTimer = null;
@@ -3058,7 +3106,6 @@
3058
3106
  const update = event.streamStatus;
3059
3107
  if (this._publishState == exports.PublishState.PUBLISHED && update.publishState != exports.PublishState.PUBLISHED) this.setPublishState(exports.PublishState.UNPUBLISHED);
3060
3108
  if (this._publishState == exports.PublishState.CONNECTED && update.publishState == exports.PublishState.PUBLISHED) this.setPublishState(exports.PublishState.PUBLISHED);
3061
- this._logger.info(this, "Stream Status Update :: VideoBitrate " + update.videoBitrate + " | AudioBitrate : " + update.audioBitrate + " | Video Frames: " + update.videoFrameCount + " | Audio Frames: " + update.audioFrameCount + " | FPS: " + update.frameRate);
3062
3109
  };
3063
3110
  this.onDescriptionSuccess = description => {
3064
3111
  var _a, _b, _c;
@@ -3106,6 +3153,7 @@
3106
3153
  this._logger = main.getLogger();
3107
3154
  this._mungeSDP = new MungeSDP();
3108
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;
3109
3157
  this.initialize();
3110
3158
  }
3111
3159
  initialize() {
@@ -3125,7 +3173,7 @@
3125
3173
  }
3126
3174
  } catch (error) {
3127
3175
  this._logger.error(this, "Initialization failed: " + JSON.stringify(error));
3128
- this.setInputDeviceState(exports.StreamerState.INVALID);
3176
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3129
3177
  }
3130
3178
  });
3131
3179
  }
@@ -3184,7 +3232,7 @@
3184
3232
  handlePermissionChange(device, state) {
3185
3233
  return __awaiter(this, void 0, void 0, function* () {
3186
3234
  if (state === 'denied') {
3187
- this.setInputDeviceState(exports.StreamerState.INVALID);
3235
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3188
3236
  if (this._publishState == exports.PublishState.CONNECTED) {
3189
3237
  this.closeStream();
3190
3238
  }
@@ -3271,16 +3319,18 @@
3271
3319
  }
3272
3320
  }
3273
3321
  publish(streamKey) {
3274
- this._logger.warning(this, "Publishing: " + streamKey);
3322
+ if (this._statusTimer != null) clearInterval(this._statusTimer);
3275
3323
  if (this._main.getConfigManager().getStreamData().streamKey == streamKey && this._publishState == exports.PublishState.CONNECTED) {
3276
3324
  this._logger.warning(this, "Already published!");
3277
3325
  return false;
3278
3326
  }
3327
+ if (this._main.getConfigManager().getStreamData().streamKey != null) this.unpublish();
3279
3328
  this._main.getConfigManager().getStreamData().streamKey = streamKey;
3280
3329
  if (!this.isStreamReady(true, true)) {
3281
3330
  this._logger.warning(this, "Cannot publish - stream not ready (missing video or audio track)");
3282
3331
  return false;
3283
3332
  }
3333
+ if (this._debug) this._logger.decoratedLog("Publishing: " + streamKey, "dark-red");
3284
3334
  this._logger.info(this, "Publish: " + streamKey);
3285
3335
  this.closeWebRTCConnection();
3286
3336
  this._main.dispatchEvent("publish", {
@@ -3291,10 +3341,13 @@
3291
3341
  return true;
3292
3342
  }
3293
3343
  unpublish() {
3344
+ if (this._debug) this._logger.decoratedLog("Unpublish", "dark-red");
3294
3345
  if (this._statusConnection != null) {
3295
3346
  this._statusConnection.destroy();
3296
3347
  this._statusConnection = null;
3297
- if (this._statusTimer != null) clearInterval(this._statusTimer);
3348
+ }
3349
+ if (this._statusTimer != null) {
3350
+ clearInterval(this._statusTimer);
3298
3351
  this._statusTimer = null;
3299
3352
  }
3300
3353
  clearTimeout(this._publishTimer);
@@ -3433,26 +3486,26 @@
3433
3486
  ref: this._main
3434
3487
  });
3435
3488
  this.setCameraState(exports.DeviceState.ACCESS_DENIED);
3436
- this.setInputDeviceState(exports.StreamerState.INVALID);
3489
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3437
3490
  } else if (!deviceAccess.camera.available) {
3438
3491
  this._main.dispatchEvent("noCameraFound", {
3439
3492
  ref: this._main
3440
3493
  });
3441
3494
  this.setCameraState(exports.DeviceState.NOT_FOUND);
3442
- this.setInputDeviceState(exports.StreamerState.INVALID);
3495
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3443
3496
  }
3444
3497
  if (!deviceAccess.microphone.allowed) {
3445
3498
  this._main.dispatchEvent("microphoneAccessDenied", {
3446
3499
  ref: this._main
3447
3500
  });
3448
3501
  this.setMicrophoneState(exports.DeviceState.ACCESS_DENIED);
3449
- this.setInputDeviceState(exports.StreamerState.INVALID);
3502
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3450
3503
  } else if (!deviceAccess.microphone.available) {
3451
3504
  this._main.dispatchEvent("noMicrophoneFound", {
3452
3505
  ref: this._main
3453
3506
  });
3454
3507
  this.setMicrophoneState(exports.DeviceState.NOT_FOUND);
3455
- this.setInputDeviceState(exports.StreamerState.INVALID);
3508
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3456
3509
  }
3457
3510
  }
3458
3511
  const devices = yield navigator.mediaDevices.enumerateDevices();
@@ -3475,7 +3528,7 @@
3475
3528
  this._selectedMicrophone = this.pickMicrophone();
3476
3529
  }
3477
3530
  } catch (error) {
3478
- this.setInputDeviceState(exports.StreamerState.INVALID);
3531
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3479
3532
  this._logger.error(this, "Errror on grab devices: " + JSON.stringify(error));
3480
3533
  }
3481
3534
  this._main.dispatchEvent("deviceListUpdate", {
@@ -3505,7 +3558,7 @@
3505
3558
  this._cameraList.get(i).setSelected(false);
3506
3559
  }
3507
3560
  this._selectedCamera = null;
3508
- this.setInputDeviceState(exports.StreamerState.UPDATING);
3561
+ this.setInputDeviceState(exports.InputDevicesState.UPDATING);
3509
3562
  this.setCameraState(exports.DeviceState.NOT_INITIALIZED);
3510
3563
  const streamKey = (_a = this._main.getConfigManager()) === null || _a === void 0 ? void 0 : _a.getStreamData().streamKey;
3511
3564
  const wasPublished = this._publishState === exports.PublishState.CONNECTED;
@@ -3527,13 +3580,13 @@
3527
3580
  this._constraints.video.deviceId = this._selectedCamera.getID();
3528
3581
  this.startCamera().then(() => {
3529
3582
  this.setCameraState(exports.DeviceState.ENABLED);
3530
- if (this._cameraState == exports.DeviceState.ENABLED && this._microphoneState == exports.DeviceState.ENABLED) this.setInputDeviceState(exports.StreamerState.READY);else this.setInputDeviceState(exports.StreamerState.INVALID);
3583
+ if (this._cameraState == exports.DeviceState.ENABLED && this._microphoneState == exports.DeviceState.ENABLED) this.setInputDeviceState(exports.InputDevicesState.READY);else this.setInputDeviceState(exports.InputDevicesState.INVALID);
3531
3584
  if (wasPublished && streamKey) {
3532
3585
  this.publish(streamKey);
3533
3586
  }
3534
3587
  });
3535
3588
  } else {
3536
- this.setInputDeviceState(exports.StreamerState.INVALID);
3589
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3537
3590
  }
3538
3591
  }
3539
3592
  selectMicrophone(micID) {
@@ -3543,7 +3596,7 @@
3543
3596
  this._microphoneList.get(i).setSelected(false);
3544
3597
  }
3545
3598
  this._selectedMicrophone = null;
3546
- this.setInputDeviceState(exports.StreamerState.UPDATING);
3599
+ this.setInputDeviceState(exports.InputDevicesState.UPDATING);
3547
3600
  this.setMicrophoneState(exports.DeviceState.NOT_INITIALIZED);
3548
3601
  this._logger.info(this, "Selecting microphone: " + micID);
3549
3602
  const streamKey = (_a = this._main.getConfigManager()) === null || _a === void 0 ? void 0 : _a.getStreamData().streamKey;
@@ -3573,9 +3626,9 @@
3573
3626
  yield this.startCamera();
3574
3627
  this.setMicrophoneState(exports.DeviceState.ENABLED);
3575
3628
  if (this._cameraState == exports.DeviceState.ENABLED && this._microphoneState == exports.DeviceState.ENABLED) {
3576
- this.setInputDeviceState(exports.StreamerState.READY);
3629
+ this.setInputDeviceState(exports.InputDevicesState.READY);
3577
3630
  } else {
3578
- this.setInputDeviceState(exports.StreamerState.INVALID);
3631
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3579
3632
  }
3580
3633
  if (wasPublished && streamKey) {
3581
3634
  this.publish(streamKey);
@@ -3585,7 +3638,7 @@
3585
3638
  this._main.dispatchEvent("inputDeviceError", {
3586
3639
  ref: this._main
3587
3640
  });
3588
- this.setInputDeviceState(exports.StreamerState.INVALID);
3641
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3589
3642
  }
3590
3643
  });
3591
3644
  }
@@ -3630,7 +3683,7 @@
3630
3683
  });
3631
3684
  }
3632
3685
  }
3633
- if (this._cameraState == exports.DeviceState.ENABLED && this._microphoneState == exports.DeviceState.ENABLED) this.setInputDeviceState(exports.StreamerState.READY);
3686
+ if (this._cameraState == exports.DeviceState.ENABLED && this._microphoneState == exports.DeviceState.ENABLED) this.setInputDeviceState(exports.InputDevicesState.READY);
3634
3687
  } catch (error) {
3635
3688
  console.error("Error in startCamera:", error);
3636
3689
  yield this.grabDevices();
@@ -3676,7 +3729,7 @@
3676
3729
  }
3677
3730
  if (!found) {
3678
3731
  this.setCameraState(exports.DeviceState.NOT_FOUND);
3679
- this.setInputDeviceState(exports.StreamerState.INVALID);
3732
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3680
3733
  this._main.dispatchEvent("savedCameraNotFound", {
3681
3734
  ref: this._main,
3682
3735
  savedDeviceID: savedCameraID
@@ -3705,7 +3758,7 @@
3705
3758
  this.setCameraState(exports.DeviceState.ENABLED);
3706
3759
  } else {
3707
3760
  this.setCameraState(exports.DeviceState.NOT_FOUND);
3708
- this.setInputDeviceState(exports.StreamerState.INVALID);
3761
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3709
3762
  return null;
3710
3763
  }
3711
3764
  }
@@ -3740,7 +3793,7 @@
3740
3793
  savedDeviceID: savedMicID
3741
3794
  });
3742
3795
  this.setMicrophoneState(exports.DeviceState.NOT_FOUND);
3743
- this.setInputDeviceState(exports.StreamerState.INVALID);
3796
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3744
3797
  if ((_c = this._main.getConfigManager()) === null || _c === void 0 ? void 0 : _c.getSettingsData().getIfCancelPublishOnError()) {
3745
3798
  this._logger.info(this, "Canceling Publish!");
3746
3799
  this._main.getConfigManager().getStreamData().streamKey = null;
@@ -3763,7 +3816,7 @@
3763
3816
  (_f = this._main.getStorageManager()) === null || _f === void 0 ? void 0 : _f.saveField("microphoneID", this._selectedMicrophone.getID());
3764
3817
  } else {
3765
3818
  this.setMicrophoneState(exports.DeviceState.NOT_FOUND);
3766
- this.setInputDeviceState(exports.StreamerState.INVALID);
3819
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
3767
3820
  return null;
3768
3821
  }
3769
3822
  }
@@ -3857,13 +3910,18 @@
3857
3910
  }
3858
3911
  setPublishState(newState) {
3859
3912
  if (this._publishState == newState) return;
3913
+ if (this._debug) this._logger.decoratedLog("Publish State: " + newState, "dark-blue");
3860
3914
  this._logger.info(this, "Publish State: " + newState);
3915
+ if (newState == exports.PublishState.PUBLISHED) this._publishTime = new Date().getTime();
3861
3916
  this._publishState = newState;
3862
3917
  this._main.dispatchEvent("publishStateChange", {
3863
3918
  ref: this._main,
3864
3919
  state: this._publishState
3865
3920
  });
3866
3921
  }
3922
+ getPublishTime() {
3923
+ return this._publishState == exports.PublishState.PUBLISHED ? this._publishTime : 0;
3924
+ }
3867
3925
  setInputDeviceState(newState) {
3868
3926
  if (this._inputDeviceState == newState) return;
3869
3927
  this._inputDeviceState = newState;
@@ -3990,10 +4048,11 @@
3990
4048
  clearInterval(this._statusTimer);
3991
4049
  this._statusTimer = null;
3992
4050
  }
4051
+ this._main.getConfigManager().getStreamData().streamKey = null;
3993
4052
  this.closeWebRTCConnection();
3994
4053
  this.stopCameraStream();
3995
4054
  this.setPublishState(exports.PublishState.STOPPED);
3996
- this.setInputDeviceState(exports.StreamerState.STOPPED);
4055
+ this.setInputDeviceState(exports.InputDevicesState.STOPPED);
3997
4056
  this.setCameraState(exports.DeviceState.STOPPED);
3998
4057
  this.setMicrophoneState(exports.DeviceState.STOPPED);
3999
4058
  if (this._restartTimer) {
@@ -4008,7 +4067,7 @@
4008
4067
  return __awaiter(this, void 0, void 0, function* () {
4009
4068
  try {
4010
4069
  this._publishState = exports.PublishState.NOT_INITIALIZED;
4011
- this._inputDeviceState = exports.StreamerState.NOT_INITIALIZED;
4070
+ this._inputDeviceState = exports.InputDevicesState.NOT_INITIALIZED;
4012
4071
  this._cameraState = exports.DeviceState.NOT_INITIALIZED;
4013
4072
  this._microphoneState = exports.DeviceState.NOT_INITIALIZED;
4014
4073
  yield this.initializeDevices();
@@ -4021,7 +4080,7 @@
4021
4080
  }
4022
4081
  } catch (error) {
4023
4082
  this._logger.error(this, "Start failed: " + JSON.stringify(error));
4024
- this.setInputDeviceState(exports.StreamerState.INVALID);
4083
+ this.setInputDeviceState(exports.InputDevicesState.INVALID);
4025
4084
  throw error;
4026
4085
  }
4027
4086
  });
@@ -4199,7 +4258,7 @@
4199
4258
  };
4200
4259
  this.onMessage = event => {
4201
4260
  var _a;
4202
- (_a = this._main.getPlaybackController()) === null || _a === void 0 ? void 0 : _a.onSocketMessage(event.data);
4261
+ (_a = this._main.getStreamerController()) === null || _a === void 0 ? void 0 : _a.onSocketMessage(event.data);
4203
4262
  };
4204
4263
  this._main = main;
4205
4264
  this._logger = main.getLogger();
@@ -4236,17 +4295,297 @@
4236
4295
  }
4237
4296
  }
4238
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
+
4239
4578
  class StormStreamer extends EventDispatcher {
4240
4579
  constructor(streamConfig, autoInitialize = false) {
4241
4580
  super();
4242
4581
  this.DEV_MODE = true;
4243
- this.STREAMER_VERSION = "0.9.1-beta.3";
4244
- this.COMPILE_DATE = "1/25/2025, 7:07:04 AM";
4582
+ this.STREAMER_VERSION = "0.9.2-beta.1";
4583
+ this.COMPILE_DATE = "3/6/2025, 1:40:51 PM";
4245
4584
  this.STREAMER_BRANCH = "Experimental";
4246
4585
  this.STREAMER_PROTOCOL_VERSION = 1;
4247
4586
  this._initialized = false;
4248
4587
  if (typeof window === 'undefined' || !window.document || !window.document.createElement) {
4249
- console.error(`StormLibrary Creation Error - No "window" element in the provided context!`);
4588
+ console.error(`StormStreamer Creation Error - No "window" element in the provided context!`);
4250
4589
  return;
4251
4590
  }
4252
4591
  if (this.DEV_MODE && !('StormStreamerArray' in window)) {
@@ -4260,12 +4599,13 @@
4260
4599
  }
4261
4600
  initialize() {
4262
4601
  if (this._isRemoved) return;
4263
- if (this._configManager == null) throw Error("Stream Config was not provided for this library! A properly configured object must be provided through the constructor or via the setConfig method before using the initialize() method.");
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.");
4264
4603
  this._storageManager = new StorageManager(this);
4265
4604
  this._stageController = new StageController(this);
4266
4605
  this._networkController = new NetworkController(this);
4267
- this._playbackController = new PlaybackController(this);
4268
- this._clientUser = new ClientUser();
4606
+ this._streamerController = new StreamerController(this);
4607
+ this._statsController = new StatsController(this);
4608
+ this._graphs = [];
4269
4609
  this._initialized = true;
4270
4610
  this.dispatchEvent("streamerReady", {
4271
4611
  ref: this
@@ -4300,22 +4640,6 @@
4300
4640
  var _a, _b;
4301
4641
  return (_b = (_a = this._networkController) === null || _a === void 0 ? void 0 : _a.getConnection().isConnectionActive()) !== null && _b !== void 0 ? _b : false;
4302
4642
  }
4303
- attachToContainer(container) {
4304
- var _a, _b;
4305
- let result = false;
4306
- if (this._initialized) return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.attachToParent(container)) !== null && _b !== void 0 ? _b : false;
4307
- return result;
4308
- }
4309
- detachFromContainer() {
4310
- var _a, _b;
4311
- let result = false;
4312
- if (this._initialized) return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.detachFromParent()) !== null && _b !== void 0 ? _b : false;
4313
- return result;
4314
- }
4315
- getContainer() {
4316
- var _a, _b;
4317
- return (_b = (_a = this._stageController) === null || _a === void 0 ? void 0 : _a.getParentElement()) !== null && _b !== void 0 ? _b : null;
4318
- }
4319
4643
  mute() {
4320
4644
  if (this._stageController != null) {
4321
4645
  if (this._stageController.getScreenElement() != null) {
@@ -4360,69 +4684,89 @@
4360
4684
  }
4361
4685
  getCameraList() {
4362
4686
  var _a, _b;
4363
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getCameraList()) !== null && _b !== void 0 ? _b : [];
4687
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getCameraList()) !== null && _b !== void 0 ? _b : [];
4364
4688
  }
4365
4689
  getMicrophoneList() {
4366
4690
  var _a, _b;
4367
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getMicrophoneList()) !== null && _b !== void 0 ? _b : [];
4691
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getMicrophoneList()) !== null && _b !== void 0 ? _b : [];
4368
4692
  }
4369
4693
  setCamera(cameraID) {
4370
4694
  var _a;
4371
- (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.selectCamera(cameraID);
4695
+ (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.selectCamera(cameraID);
4372
4696
  }
4373
4697
  setMicrophone(microphoneID) {
4374
4698
  var _a;
4375
- (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.selectMicrophone(microphoneID);
4699
+ (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.selectMicrophone(microphoneID);
4376
4700
  }
4377
4701
  getCurrentCamera() {
4378
- return this._playbackController.getCurrentCamera();
4702
+ return this._streamerController.getCurrentCamera();
4379
4703
  }
4380
4704
  getCurrentMicrophone() {
4381
- return this._playbackController.getCurrentMicrophone();
4705
+ return this._streamerController.getCurrentMicrophone();
4382
4706
  }
4383
4707
  muteMicrophone(microphoneState) {
4384
4708
  var _a;
4385
- (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.muteMicrophone(microphoneState);
4709
+ (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.muteMicrophone(microphoneState);
4386
4710
  }
4387
4711
  isMicrophoneMuted() {
4388
4712
  var _a, _b;
4389
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.isMicrophoneMuted()) !== null && _b !== void 0 ? _b : false;
4713
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.isMicrophoneMuted()) !== null && _b !== void 0 ? _b : false;
4390
4714
  }
4391
4715
  getPublishState() {
4392
4716
  var _a, _b;
4393
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getPublishState()) !== null && _b !== void 0 ? _b : exports.PublishState.NOT_INITIALIZED;
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;
4394
4722
  }
4395
4723
  publish(streamKey) {
4396
4724
  var _a, _b;
4397
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.publish(streamKey)) !== null && _b !== void 0 ? _b : false;
4725
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.publish(streamKey)) !== null && _b !== void 0 ? _b : false;
4398
4726
  }
4399
- getStreamerState() {
4727
+ getInputDevicesState() {
4400
4728
  var _a, _b;
4401
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getInputDeviceState()) !== null && _b !== void 0 ? _b : exports.StreamerState.NOT_INITIALIZED;
4729
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getInputDeviceState()) !== null && _b !== void 0 ? _b : exports.InputDevicesState.NOT_INITIALIZED;
4402
4730
  }
4403
4731
  getCamerState() {
4404
4732
  var _a, _b;
4405
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getCamerState()) !== null && _b !== void 0 ? _b : exports.DeviceState.NOT_INITIALIZED;
4733
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getCamerState()) !== null && _b !== void 0 ? _b : exports.DeviceState.NOT_INITIALIZED;
4406
4734
  }
4407
4735
  getMicrophoneState() {
4408
4736
  var _a, _b;
4409
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getMicrophoneState()) !== null && _b !== void 0 ? _b : exports.DeviceState.NOT_INITIALIZED;
4737
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.getMicrophoneState()) !== null && _b !== void 0 ? _b : exports.DeviceState.NOT_INITIALIZED;
4410
4738
  }
4411
4739
  clearSavedDevices() {
4412
4740
  var _a;
4413
- return (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.clearSavedDevices();
4741
+ return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.clearSavedDevices();
4414
4742
  }
4415
4743
  messSavedDevices() {
4416
4744
  var _a;
4417
- return (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.messSavedDevices();
4745
+ return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.messSavedDevices();
4418
4746
  }
4419
4747
  isStreamReady() {
4420
4748
  var _a, _b;
4421
- return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.isStreamReady()) !== null && _b !== void 0 ? _b : false;
4749
+ return (_b = (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.isStreamReady()) !== null && _b !== void 0 ? _b : false;
4422
4750
  }
4423
4751
  unpublish() {
4424
4752
  var _a;
4425
- (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.unpublish();
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;
4426
4770
  }
4427
4771
  setSize(width, height) {
4428
4772
  if (this._initialized) this._stageController.setSize(width, height);else {
@@ -4500,6 +4844,22 @@
4500
4844
  }
4501
4845
  });
4502
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
+ }
4503
4863
  enterFullScreen() {
4504
4864
  if (this._initialized && this._stageController) this._stageController.enterFullScreen();
4505
4865
  }
@@ -4510,6 +4870,13 @@
4510
4870
  if (this._initialized && this._stageController) return this._stageController.isFullScreenMode();
4511
4871
  return false;
4512
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
+ }
4513
4880
  getStreamerID() {
4514
4881
  return this._streamerID;
4515
4882
  }
@@ -4522,8 +4889,8 @@
4522
4889
  getNetworkController() {
4523
4890
  return this._networkController;
4524
4891
  }
4525
- getPlaybackController() {
4526
- return this._playbackController;
4892
+ getStreamerController() {
4893
+ return this._streamerController;
4527
4894
  }
4528
4895
  getStageController() {
4529
4896
  return this._stageController;
@@ -4550,21 +4917,21 @@
4550
4917
  start() {
4551
4918
  var _a;
4552
4919
  return __awaiter(this, void 0, void 0, function* () {
4553
- return (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.start();
4920
+ return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.start();
4554
4921
  });
4555
4922
  }
4556
4923
  stop() {
4557
4924
  var _a;
4558
- return (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.stop();
4925
+ return (_a = this._streamerController) === null || _a === void 0 ? void 0 : _a.stop();
4559
4926
  }
4560
4927
  destroy() {
4561
4928
  var _a, _b, _c, _d;
4562
- this._logger.warning(this, "Destroying library instance, bye, bye!");
4929
+ this._logger.warning(this, "Destroying streamer instance, bye, bye!");
4563
4930
  if (this.DEV_MODE && 'StormStreamerArray' in window) window.StormStreamerArray[this._streamerID] = null;
4564
4931
  this._initialized = false;
4565
4932
  this._isRemoved = true;
4566
4933
  (_b = (_a = this._networkController) === null || _a === void 0 ? void 0 : _a.getConnection()) === null || _b === void 0 ? void 0 : _b.destroy();
4567
- (_c = this._playbackController) === null || _c === void 0 ? void 0 : _c.destroy();
4934
+ (_c = this._streamerController) === null || _c === void 0 ? void 0 : _c.destroy();
4568
4935
  (_d = this._stageController) === null || _d === void 0 ? void 0 : _d.destroy();
4569
4936
  this.removeAllEventListeners();
4570
4937
  }