@stormstreaming/stormstreamer 1.0.0-rc.0 → 1.0.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.
@@ -21,470 +21,92 @@ import { MicrophoneGraph } from "./graph/MicrophoneGraph";
21
21
  * Main class of the player. The player itself has no GUI, but can be controlled via provided API.
22
22
  */
23
23
  export declare class StormStreamer extends EventDispatcher {
24
- /**
25
- * Next ID for the streamer instance. Each subsequent instance has a higher number.
26
- * @private
27
- */
28
24
  private static NEXT_STREAMER_ID;
29
- /**
30
- * Indicates whether the streamer object is in development mode (provides more debug options)
31
- * @private
32
- */
33
25
  private readonly DEV_MODE;
34
- /**
35
- * Version of this streamer in SemVer format (Major.Minor.Patch).
36
- * @private
37
- */
38
26
  private readonly STREAMER_VERSION;
39
- /**
40
- * Compile date for this streamer
41
- * @private
42
- */
43
27
  private readonly COMPILE_DATE;
44
- /**
45
- * Defines from which branch this streamer comes from e.g. "Main", "Experimental"
46
- * @private
47
- */
48
28
  private readonly STREAMER_BRANCH;
49
- /**
50
- * Defines number of streamer protocol that is required on server-side
51
- * @private
52
- */
53
29
  readonly STREAMER_PROTOCOL_VERSION: number;
54
- /**
55
- * ID of the streamer within StormStreamerArray collection
56
- * @private
57
- */
58
30
  private readonly _streamerID;
59
- /**
60
- * Contains all streamer configuration objects
61
- * @private
62
- */
63
31
  private _configManager;
64
- /**
65
- * Indicates whether streamer was initialized or not
66
- * @private
67
- */
68
32
  private _initialized;
69
- /**
70
- * Manages data storage like bandwidth settings, volume preferences
71
- * @private
72
- */
33
+ private _isDestroyed;
73
34
  private _storageManager;
74
- /**
75
- * Controls all HTML elements and visual presentation
76
- * @private
77
- */
78
35
  private _stageController;
79
- /**
80
- * Controls all streaming and media operations
81
- * @private
82
- */
83
36
  private _streamerController;
84
- /**
85
- * Controls all network communication with the server
86
- * @private
87
- */
88
37
  private _networkController;
89
- /**
90
- * Collects and manages streaming statistics
91
- * @private
92
- */
93
38
  private _statsController;
94
- /**
95
- * Collection of active performance graphs
96
- * @private
97
- */
98
39
  private _graphs;
99
- /**
100
- * Constructor - creates a new StormStreamer instance
101
- *
102
- * @param streamConfig - Configuration object for the streamer
103
- * @param autoInitialize - Whether to automatically initialize the streamer after creation
104
- */
105
40
  constructor(streamConfig?: StreamerConfig, autoInitialize?: boolean);
106
- /**
107
- * Initializes the streamer object. From this point, a connection to the server is established and authentication occurs.
108
- * It is recommended to add all event listeners before calling this method to ensure they can be properly captured.
109
- */
110
41
  initialize(): void;
111
- /**
112
- * Sets stream config for the streamer (or overwrites an existing one).
113
- *
114
- * @param streamConfig - New configuration object for the streamer
115
- */
116
42
  setStreamConfig(streamConfig: StreamerConfig): void;
117
- /**
118
- * Returns true if this streamer instance is currently connected to a Storm Server/Cloud instance.
119
- *
120
- * @returns Boolean indicating connection status
121
- */
122
43
  isConnected(): boolean;
123
- /**
124
- * Mutes the streamer's video object. Audio output will be silenced.
125
- */
126
44
  mute(): void;
127
- /**
128
- * Unmutes the streamer's video object. Audio output will be restored.
129
- */
130
45
  unmute(): void;
131
- /**
132
- * Checks whether the streamer audio is currently muted.
133
- *
134
- * @returns Boolean indicating mute status
135
- */
136
46
  isMute(): boolean;
137
- /**
138
- * Toggles between mute and unmute states. Returns the new mute state.
139
- *
140
- * @returns New mute state (true = muted, false = unmuted)
141
- */
142
47
  toggleMute(): boolean;
143
- /**
144
- * Sets new volume for the streamer (0-100). Once the method is performed, the volumeChange event will be triggered.
145
- * If the video was muted prior to the volume change, it will be automatically unmuted.
146
- *
147
- * @param newVolume - Volume level (0-100)
148
- */
149
48
  setVolume(newVolume: number): void;
150
- /**
151
- * Returns current streamer volume (0-100).
152
- *
153
- * @returns Current volume level
154
- */
155
49
  getVolume(): number;
156
- /**
157
- * Returns the list of available camera devices.
158
- *
159
- * @returns Array of camera input devices
160
- */
161
50
  getCameraList(): InputDevice[];
162
- /**
163
- * Returns the list of available microphone devices.
164
- *
165
- * @returns Array of microphone input devices
166
- */
167
51
  getMicrophoneList(): InputDevice[];
168
- /**
169
- * Sets the active camera device by ID.
170
- *
171
- * @param cameraID - ID of the camera device to use
172
- */
173
52
  setCamera(cameraID: string): void;
174
- /**
175
- * Sets the active microphone device by ID.
176
- *
177
- * @param microphoneID - ID of the microphone device to use
178
- */
179
53
  setMicrophone(microphoneID: string): void;
180
- /**
181
- * Returns the currently active camera device.
182
- *
183
- * @returns Current camera device or null if none is active
184
- */
185
54
  getCurrentCamera(): InputDevice | null;
186
- /**
187
- * Returns the currently active microphone device.
188
- *
189
- * @returns Current microphone device or null if none is active
190
- */
191
55
  getCurrentMicrophone(): InputDevice | null;
192
- /**
193
- * Mutes or unmutes the microphone.
194
- *
195
- * @param microphoneState - True to mute, false to unmute
196
- */
197
56
  muteMicrophone(microphoneState: boolean): void;
198
- /**
199
- * Checks if the microphone is currently muted.
200
- *
201
- * @returns Boolean indicating if microphone is muted
202
- */
203
57
  isMicrophoneMuted(): boolean;
204
- /**
205
- * Returns the current publishing state of the streamer.
206
- *
207
- * @returns Current publishing state
208
- */
209
58
  getPublishState(): PublishState;
210
- /**
211
- * Returns the total time the stream has been publishing in milliseconds.
212
- *
213
- * @returns Publishing time in milliseconds
214
- */
215
59
  getPublishTime(): number;
216
- /**
217
- * Starts publishing a stream with the given stream key.
218
- *
219
- * @param streamKey - Key identifying the stream to publish
220
- * @returns Boolean indicating if publishing was successfully initiated
221
- */
222
60
  publish(streamKey: string): boolean;
223
- /**
224
- * Stops publishing the current stream.
225
- */
226
61
  unpublish(): void;
227
- /**
228
- * Returns the current state of input devices (camera and microphone).
229
- *
230
- * @returns Current state of input devices
231
- */
232
62
  getInputDevicesState(): InputDevicesState;
233
- /**
234
- * Returns the current state of the camera device.
235
- *
236
- * @returns Current camera device state
237
- */
238
63
  getCameraState(): DeviceState;
239
- /**
240
- * Returns the current state of the microphone device.
241
- *
242
- * @returns Current microphone device state
243
- */
244
64
  getMicrophoneState(): DeviceState;
245
- /**
246
- * Clears saved device preferences from storage.
247
- */
248
65
  clearSavedDevices(): void;
249
- /**
250
- * Randomizes saved device preferences (for testing purposes).
251
- */
252
66
  messSavedDevices(): void;
253
- /**
254
- * Checks if the stream is ready for publishing.
255
- *
256
- * @returns Boolean indicating if stream is ready
257
- */
258
67
  isStreamReady(): boolean;
259
- /**
260
- * Attaches the streamer to a new parent container using either a container ID (string) or a reference to an HTMLElement.
261
- * If the instance is already attached, it will be moved to a new parent.
262
- *
263
- * @param container - Container ID (string) or HTMLElement reference
264
- * @returns Boolean indicating if attachment was successful
265
- */
266
68
  attachToContainer(container: string | HTMLElement): boolean;
267
- /**
268
- * Detaches the streamer from the current parent element, if possible.
269
- *
270
- * @returns Boolean indicating if detachment was successful
271
- */
272
69
  detachFromContainer(): boolean;
273
- /**
274
- * Returns the current parent element of the streamer, or null if none exists.
275
- *
276
- * @returns Current container element or null
277
- */
278
70
  getContainer(): HTMLElement | null;
279
- /**
280
- * Sets a new width and height for the streamer. The values can be given as a number (in which case they are
281
- * treated as the number of pixels), or as a string ending with "px" (this will also be the number of pixels) or "%",
282
- * where the number is treated as a percentage of the parent container's value.
283
- *
284
- * @param width - Can be provided as number or a string with "%" or "px" suffix
285
- * @param height - Can be provided as number or a string with "%" or "px" suffix
286
- */
287
71
  setSize(width: number | string, height: number | string): void;
288
- /**
289
- * Sets a new width for the streamer. The value can be given as a number (in which case it is treated as the
290
- * number of pixels), or as a string ending with "px" (this will also be the number of pixels) or "%", where the
291
- * number is treated as a percentage of the parent container's value.
292
- *
293
- * @param width - Can be provided as number or a string with "%" or "px" suffix
294
- */
295
72
  setWidth(width: number | string): void;
296
- /**
297
- * Sets a new height for the streamer. The value can be given as a number (in which case it is treated as the
298
- * number of pixels), or as a string ending with "px" (this will also be the number of pixels) or "%", where the
299
- * number is treated as a percentage of the parent container's value.
300
- *
301
- * @param height - Can be provided as number or a string with "%" or "px" suffix
302
- */
303
73
  setHeight(height: number | string): void;
304
- /**
305
- * Returns current streamer width in pixels.
306
- *
307
- * @returns Current width in pixels
308
- */
309
74
  getWidth(): number;
310
- /**
311
- * Returns current streamer height in pixels.
312
- *
313
- * @returns Current height in pixels
314
- */
315
75
  getHeight(): number;
316
- /**
317
- * Changes the streamer scaling mode. Available modes include fill, letterbox, original, and crop.
318
- *
319
- * @param newMode - New scaling mode name (fill, letterbox, original, crop)
320
- */
321
76
  setScalingMode(newMode: string): void;
322
- /**
323
- * Returns the current streamer scaling mode.
324
- *
325
- * @returns Current scaling mode
326
- */
327
77
  getScalingMode(): ScalingType;
328
- /**
329
- * Forces the streamer to recalculate its size based on parent internal dimensions.
330
- */
331
78
  updateToSize(): void;
332
- /**
333
- * Returns a promise that resolves with a screenshot of the video element as a blob, or null if taking the
334
- * screenshot was not possible.
335
- *
336
- * @returns Promise resolving to a Blob containing the screenshot or null
337
- */
338
79
  makeScreenshot(): Promise<Blob | null>;
339
- /**
340
- * Creates a FPS performance graph in the specified location (container ID or reference). The graph is a
341
- * separate object that must be started using its start() method and stopped using its stop() method. The dimensions
342
- * of the graph depend on the dimensions of the specified container.
343
- *
344
- * @param container - Element ID or reference to HTMLElement
345
- * @returns FPS graph instance
346
- */
347
80
  createFPSGraph(container: string | HTMLElement): FPSGraph;
348
- /**
349
- * Creates a bitrate performance graph in the specified location (container ID or reference). The graph is a
350
- * separate object that must be started using its start() method and stopped using its stop() method. The dimensions
351
- * of the graph depend on the dimensions of the specified container.
352
- *
353
- * @param container - Element ID or reference to HTMLElement
354
- * @returns Bitrate graph instance
355
- */
356
81
  createBitrateGraph(container: string | HTMLElement): BitrateGraph;
357
- /**
358
- * Creates a microphone graph in the specified location (container ID or reference). The graph is a
359
- * separate object that must be started using its start() method and stopped using its stop() method. The dimensions
360
- * of the graph depend on the dimensions of the specified container.
361
- *
362
- * @param container - Element ID or reference to HTMLElement
363
- * @returns Bitrate graph instance
364
- */
365
82
  createMicrophoneGraph(container: string | HTMLElement): MicrophoneGraph;
366
- /**
367
- * Adds new graph to the internal collection of active graphs.
368
- *
369
- * @param newGraph - Graph instance to add
370
- */
371
83
  addGraph(newGraph: IGraph): void;
372
- /**
373
- * Stops all active performance graphs.
374
- */
375
84
  stopAllGraphs(): void;
376
- /**
377
- * Enters fullscreen mode for the streamer container.
378
- */
379
85
  enterFullScreen(): void;
380
- /**
381
- * Exits fullscreen mode.
382
- */
383
86
  exitFullScreen(): void;
384
- /**
385
- * Returns true if the streamer is currently in fullscreen mode.
386
- *
387
- * @returns Boolean indicating fullscreen status
388
- */
389
87
  isFullScreenMode(): boolean;
390
- /**
391
- * Returns the current stream key or null if none is set.
392
- *
393
- * @returns Current stream key or null
394
- */
395
88
  getStreamKey(): string | null;
396
- /**
397
- * Returns the Stats Controller instance which contains statistical data about streaming performance.
398
- *
399
- * @returns Stats controller instance or null
400
- */
401
89
  getStatsController(): StatsController | null;
402
- /**
403
- * Returns the unique ID of this streamer instance. Each subsequent instance has a higher number.
404
- *
405
- * @returns Streamer instance ID
406
- */
407
90
  getStreamerID(): number;
408
- /**
409
- * Returns the logger instance used by this streamer.
410
- *
411
- * @returns Logger instance
412
- */
413
91
  getLogger(): Logger;
414
- /**
415
- * Returns the configuration manager for this streamer.
416
- *
417
- * @returns Config manager instance or null
418
- */
419
92
  getConfigManager(): ConfigManager | null;
420
- /**
421
- * Returns the network controller which manages all server communication.
422
- *
423
- * @returns Network controller instance or null
424
- */
425
93
  getNetworkController(): NetworkController | null;
426
- /**
427
- * Returns the streamer controller which manages media stream operations.
428
- *
429
- * @returns Streamer controller instance or null
430
- */
431
94
  getStreamerController(): StreamerController | null;
432
- /**
433
- * Returns the stage controller which manages visual presentation.
434
- *
435
- * @returns Stage controller instance or null
436
- */
437
95
  getStageController(): StageController | null;
438
- /**
439
- * Returns the storage manager which handles persistent data storage.
440
- *
441
- * @returns Storage manager instance or null
442
- */
443
96
  getStorageManager(): StorageManager | null;
444
- /**
445
- * Returns the HTML video element used by this streamer instance.
446
- *
447
- * @returns Video element or null
448
- */
449
97
  getVideoElement(): HTMLVideoElement | null;
450
- /**
451
- * Returns true if this streamer instance has already been initialized.
452
- *
453
- * @returns Boolean indicating initialization status
454
- */
455
98
  isInitialized(): boolean;
456
- /**
457
- * Returns the version of this streamer instance. The version is returned in the SemVer format (Major.Minor.Patch).
458
- *
459
- * @returns Streamer version string
460
- */
99
+ isDestroyed(): boolean;
461
100
  getVersion(): string;
462
- /**
463
- * Returns the development branch of this streamer (e.g., main, experimental).
464
- *
465
- * @returns Branch name string
466
- */
467
101
  getBranch(): string;
468
- /**
469
- * Dispatches an event with the specified name and data.
470
- *
471
- * @param eventName - Name of the event to dispatch
472
- * @param event - Object containing event data
473
- */
474
102
  dispatchEvent<K extends keyof StormStreamerEvent>(eventName: K, event: StormStreamerEvent[K]): void;
475
- /**
476
- * Starts the streaming process.
477
- *
478
- * @returns Promise that resolves when streaming has started
479
- */
480
103
  start(): Promise<void>;
481
- /**
482
- * Stops the streaming process.
483
- */
484
104
  stop(): void;
105
+ debugMediaState(): void;
485
106
  /**
486
- * Destroys this instance of StormStreamer, releasing all resources and disconnecting from the server.
487
- * After calling this method, the instance should not be used anymore.
107
+ * Destroys this instance of StormStreamer, releasing all resources.
108
+ * This method is SYNCHRONOUS - it sets flags immediately to prevent race conditions.
109
+ * All pending async operations will detect the destroyed state and abort.
488
110
  */
489
111
  destroy(): void;
490
112
  }
@@ -7,11 +7,14 @@ export declare class SoundMeter {
7
7
  private _lastEventTime;
8
8
  private readonly THROTTLE_INTERVAL;
9
9
  private _isMonitoring;
10
+ private _animationFrameId;
10
11
  private _instant;
11
12
  private _slow;
13
+ private readonly PEAK_DECAY;
12
14
  constructor(main: StormStreamer);
13
15
  attach(stream: MediaStream): void;
14
16
  detach(): void;
15
17
  private clear;
16
18
  private startMonitoring;
19
+ destroy(): void;
17
20
  }