@overwolf/ow-electron-packages-types 0.0.13 → 0.1.0-beta.10

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/types.d.ts ADDED
@@ -0,0 +1,1733 @@
1
+ import { overwolf } from '@overwolf/ow-electron';
2
+ import {
3
+ BrowserWindow,
4
+ BrowserWindowConstructorOptions,
5
+ Size,
6
+ WebContents,
7
+ } from 'electron';
8
+
9
+ import { EventEmitter } from 'events';
10
+
11
+ // -----------------------------------------------------------------------------
12
+ // ow-electron packages
13
+ type GameProcessInfo = {
14
+ pid?: number;
15
+
16
+ fullPath: string;
17
+
18
+ commandLine?: string;
19
+
20
+ is32Bit?: boolean;
21
+
22
+ isElevated?: boolean;
23
+ };
24
+
25
+ // -----------------------------------------------------------------------------
26
+ type GameInfo = {
27
+ id: number;
28
+
29
+ classId: number;
30
+
31
+ name: string;
32
+
33
+ supported: boolean;
34
+
35
+ processInfo?: GameProcessInfo;
36
+
37
+ flags?: any;
38
+
39
+ type: 'Game' | 'Launcher';
40
+ };
41
+
42
+ // -----------------------------------------------------------------------------
43
+ type GameInfoType = 'Game' | 'Launcher' | undefined;
44
+ type InstalledGameInfo = {
45
+ /**
46
+ * Game overwolf class id
47
+ */
48
+ id: number;
49
+
50
+ /**
51
+ * Game Install location
52
+ */
53
+ path?: string;
54
+
55
+ /**
56
+ * Game Name
57
+ */
58
+ name?: string;
59
+
60
+ /**
61
+ * Game info type
62
+ */
63
+ type?: GameInfoType,
64
+
65
+ /**
66
+ * Overlay supported game
67
+ */
68
+ supported?: boolean;
69
+ }
70
+
71
+
72
+ // -----------------------------------------------------------------------------
73
+ interface GamesFilter {
74
+ /**
75
+ * Track also unsupported (overlay) games (Default is false)
76
+ */
77
+ includeUnsupported?: boolean;
78
+
79
+ /**
80
+ * Set games id's to track
81
+ *
82
+ * when null or empty, will filter all games
83
+ */
84
+ gamesIds?: number[];
85
+
86
+ /**
87
+ * when set to all, will also filter all games ()
88
+ */
89
+ all?: boolean;
90
+ }
91
+
92
+ // -----------------------------------------------------------------------------
93
+ interface OWPackages extends overwolf.packages.OverwolfPackageManager {
94
+ recorder: IOverwolfRecordingApi;
95
+ overlay: IOverwolfOverlayApi;
96
+ utility: IOverwolfUtilityApi;
97
+ }
98
+
99
+ /**
100
+ * Input pass through
101
+ *
102
+ * 'noPassThrough': Window will handle input and block from game (Default)
103
+ * 'PassThrough': window will not handle any input
104
+ * 'passThroughAndNotify': Window will handle input and also pass it to the game.
105
+ */
106
+ type PassthroughType = "noPassThrough" | "passThrough" | "passThroughAndNotify";
107
+
108
+ /**
109
+ * Overlay rendering Z-Order
110
+ */
111
+ type ZOrderType = "default" | "topMost" | "bottomMost";
112
+
113
+ /** Overlay ow-electron options */
114
+ interface OverlayOptions {
115
+ passthrough?: PassthroughType;
116
+
117
+ zOrder?: ZOrderType;
118
+ }
119
+
120
+ interface OverlayWindowOptions
121
+ extends BrowserWindowConstructorOptions,
122
+ OverlayOptions {
123
+ /**
124
+ * unique name (id)
125
+ */
126
+ name: string;
127
+
128
+ /** not supported yet */
129
+ enableHWAcceleration?: boolean;
130
+
131
+
132
+ /** */
133
+ enableIsolation?:boolean;
134
+ }
135
+
136
+ interface IOverlayHotkey {
137
+ name: string;
138
+ keyCode: number;
139
+ modifiers?: {
140
+ alt?: boolean;
141
+ ctrl?: boolean;
142
+ shift?: boolean;
143
+ custom?: number; // custom modifier (i.e key code)
144
+ meta?: boolean;
145
+ };
146
+ passthrough?: boolean;
147
+ }
148
+
149
+ interface GameLaunchEvent {
150
+ inject: () => void;
151
+ }
152
+
153
+ /**
154
+ * TBD
155
+ */
156
+ interface OverlayBrowserWindow {
157
+ window: BrowserWindow;
158
+
159
+ readonly overlayOptions: OverlayOptions;
160
+
161
+ readonly name: string;
162
+
163
+ readonly id: number;
164
+ }
165
+
166
+ interface InjectionError {
167
+ error: string;
168
+ }
169
+
170
+ interface GameWindowInfo {
171
+ size: Size;
172
+ nativeHandle: number;
173
+ focused: boolean;
174
+ graphics: 'd3d9' | 'd3d12' | 'd3d11' | string | undefined;
175
+ }
176
+
177
+ interface GameInputInterception {
178
+ /**
179
+ * Can the Overlay window process input
180
+ * Related to `mixed mode when available` and/or `exclusive only` games
181
+ */
182
+ readonly canInterceptInput?: boolean;
183
+ /**
184
+ * Overlay has full input control, blocking input from the game
185
+ */
186
+ readonly exclusiveMode?: boolean;
187
+ }
188
+
189
+ interface ActiveGameInfo {
190
+ readonly gameInfo: GameInfo;
191
+ readonly gameWindowInfo: GameWindowInfo;
192
+ readonly gameInputInfo: GameInputInterception;
193
+ }
194
+
195
+ type GameWindowUpdateReason = undefined | 'resized' | 'focus';
196
+ type HotkeyState = 'pressed' | 'released';
197
+
198
+ type HotkeyCallback = (
199
+ hotKey: IOverlayHotkey,
200
+ state: HotkeyState
201
+ ) => void;
202
+
203
+ interface ExclusiveInputOptions {
204
+ /**
205
+ * Exclusive mode FadeIn / FadeOut duration in miliseconds.
206
+ *
207
+ * Use `0` to disable.
208
+ * @default 100
209
+ */
210
+ fadeAnimateInterval?: number;
211
+
212
+ /**
213
+ * Exclusive mode overlay background color.
214
+ * Use `rgba(0,0,0,0)` to disable background color
215
+ *
216
+ * Note: Using an invalid color format (e.g: not `rgba(...)`) will throw an Error.
217
+ * @default 'rgba(12, 12, 12, , 0.5)'
218
+ */
219
+ backgroundColor?: string;
220
+ }
221
+
222
+ interface IOverlayHotkeys {
223
+ /**
224
+ * Register new hotkey.
225
+ * Throw error when hotkey already exits, or callback is missing
226
+ */
227
+ register(hotKey: IOverlayHotkey, callback: HotkeyCallback): void;
228
+
229
+ /**
230
+ * Update existing hotkey.
231
+ * Return false if hotkey doesn't exits
232
+ */
233
+ update(hotKey: IOverlayHotkey): boolean;
234
+
235
+ /**
236
+ * Clear all hotkeys
237
+ */
238
+ unregisterAll(): void;
239
+
240
+ /**
241
+ * Remove hotkey by name.
242
+ * Return false if doesn't exits.
243
+ */
244
+ unregister(name: string): boolean;
245
+
246
+ /**
247
+ * Get all active hotkeys.
248
+ */
249
+ all(): IOverlayHotkey[];
250
+ }
251
+
252
+ interface IOverwolfOverlayApi extends EventEmitter {
253
+ /**
254
+ * Create new Overlay window
255
+ */
256
+ createWindow(options: OverlayWindowOptions): Promise<OverlayBrowserWindow>;
257
+
258
+ /**
259
+ * Game launch registration
260
+ */
261
+ registerGames(filter: GamesFilter);
262
+
263
+ /**
264
+ * injected Game inforamation
265
+ */
266
+ getActiveGameInfo(): ActiveGameInfo | undefined;
267
+
268
+ /**
269
+ * Get all open overlay windows
270
+ */
271
+ getAllWindows(): OverlayBrowserWindow[];
272
+
273
+ /**
274
+ * The overlay window that owns the given `webContents` or `null` if the contents are not
275
+ * owned by a window.
276
+ */
277
+ fromWebContents(webContents: WebContents): OverlayBrowserWindow | null;
278
+
279
+ /**
280
+ * The overlay window that owns the given `BrowserWindow` or `null` if the browerWindow are not
281
+ * owned by a window.
282
+ */
283
+ fromBrowserWindow(browserWindow: BrowserWindow): OverlayBrowserWindow | null;
284
+
285
+ /**
286
+ * Overlay hotkeys api
287
+ */
288
+ hotkeys: IOverlayHotkeys;
289
+
290
+ /**
291
+ * Enters Overlay "Exclusive Mode" - meaning, the game no longer receives user
292
+ * input (all input will go to the overlay windows).
293
+ *
294
+ * The `game-input-exclusive-mode-changed` event fires if exclusive mode was entered.
295
+ *
296
+ * NOTE: This is only supported when getActiveGameInfo returns
297
+ * `"canInterceptInput" == false`. Calling this function when unsupported will
298
+ * be ignored and will not throw an exception.
299
+ */
300
+ enterExclusiveMode(options?: ExclusiveInputOptions): void;
301
+
302
+ /**
303
+ * Exits Overlay Exclusive Mode, returning input control to the game.
304
+ *
305
+ * The `game-input-exclusive-mode-changed` event fires when exiting exclusive mode.
306
+ */
307
+ exitExclusiveMode(): void;
308
+
309
+ /**
310
+ *TODO(bFox) :replace ...args
311
+ */
312
+ on(eventName: 'error', listener: (...args: any[]) => void): this;
313
+
314
+ /**
315
+ * Fired when registered game is detected
316
+ * call `event.inject()` to enable overlay for the game.
317
+ */
318
+ on(
319
+ eventName: 'game-launched',
320
+ listener: (event: GameLaunchEvent, gameInfo: GameInfo) => void
321
+ ): this;
322
+
323
+ /**
324
+ * Fired on registered game process terminated.
325
+ */
326
+ on(
327
+ eventName: 'game-exit',
328
+ listener: (gameInfo: GameInfo, wasInjected: boolean) => void
329
+ ): this;
330
+
331
+ /**
332
+ * Fired when overlay is ready for game.
333
+ *
334
+ */
335
+ on(eventName: 'game-injected', listener: (gameInfo: GameInfo) => void): this;
336
+
337
+ /**
338
+ * TODO(bFox) :replace ...args
339
+ */
340
+ on(
341
+ eventName: 'game-injection-error',
342
+ listener: (gameInfo: GameInfo, error: string, ...args: any[]) => void
343
+ ): this;
344
+
345
+ /** */
346
+ on(
347
+ eventName: 'game-focus-changed',
348
+ listener: (
349
+ window: GameWindowInfo,
350
+ gameInfo: GameInfo,
351
+ focus: boolean
352
+ ) => void
353
+ ): this;
354
+
355
+ /** */
356
+ on(
357
+ eventName: 'game-window-changed',
358
+ listener: (
359
+ window: GameWindowInfo,
360
+ gameInfo: GameInfo,
361
+ reason?: GameWindowUpdateReason
362
+ ) => void
363
+ ): this;
364
+
365
+ /**
366
+ * Fires when the game input interception state changes
367
+ */
368
+ on(
369
+ eventName: 'game-input-interception-changed',
370
+ listener: (info: GameInputInterception) => void
371
+ ): this;
372
+
373
+ /**
374
+ * Fires when Overlay input Exclusive Mode changes.
375
+ * Only relevant to `mixed mode when available` and/or `exclusive only` games
376
+ */
377
+ on(
378
+ eventName: 'game-input-exclusive-mode-changed',
379
+ listener: (info: GameInputInterception) => void
380
+ ): this;
381
+ }
382
+
383
+ interface IOverwolfUtilityApi {
384
+ /**
385
+ * Game launch/exit registration
386
+ */
387
+ trackGames(filter: GamesFilter): Promise<void>;
388
+
389
+ /**
390
+ * Scan for installed games
391
+ */
392
+ scan(filter?: GamesFilter): Promise<InstalledGameInfo[]>;
393
+
394
+ /**
395
+ *
396
+ */
397
+ on(eventName: 'game-launched', listener: (gameInfo: GameInfo) => void): this;
398
+
399
+ /**
400
+ *
401
+ */
402
+ on(eventName: 'game-exit', listener: (gameInfo: GameInfo) => void): this;
403
+ }
404
+
405
+ type Rect = { top: number; left: number; width: number; height: number };
406
+
407
+ type AudioDeviceType = 'input' | 'output';
408
+
409
+ type kSupportedEncodersTypes =
410
+ // jim_* are deprecated since obs 0.31.0. instead we use obs_nvenc_* encoders
411
+ | 'ffmpeg_svt_av1'
412
+ | 'ffmpeg_aom_av1'
413
+ | 'obs_x264'
414
+ | 'h264_texture_amf'
415
+ | 'h265_texture_amf'
416
+ | 'av1_texture_amf'
417
+ | 'obs_qsv11_v2'
418
+ | 'obs_qsv11_hevc'
419
+ | 'obs_qsv11_av1'
420
+ | 'obs_nvenc_h264_tex'
421
+ | 'obs_nvenc_hevc_tex'
422
+ | 'obs_nvenc_av1_tex';
423
+
424
+ type kKnownAudioEncodersTypes =
425
+ | 'ffmpeg_aac'
426
+ | 'ffmpeg_opus'
427
+ | 'ffmpeg_pcm_s16le'
428
+ | 'ffmpeg_pcm_s24le'
429
+ | 'ffmpeg_pcm_f32le'
430
+ | 'ffmpeg_alac'
431
+ | 'ffmpeg_flac'
432
+ | string;
433
+
434
+ // Sample Rate
435
+ type kSampleRate48kHz = 48000;
436
+ type kSampleRate441kHz = 44100;
437
+ type kSpeakerLayout =
438
+ | 'SPEAKERS_MONO'
439
+ | 'SPEAKERS_STEREO'
440
+ | 'SPEAKERS_2POINT1'
441
+ | 'SPEAKERS_4POINT0'
442
+ | 'SPEAKERS_4POINT1'
443
+ | 'SPEAKERS_5POINT1'
444
+ | 'SPEAKERS_7POINT1';
445
+
446
+ declare class Colors {
447
+ public static readonly Red = 'Red';
448
+ }
449
+
450
+ /**
451
+ * None = 0
452
+ * Track1 = 1
453
+ * Track2 = 2
454
+ * Track3 = 4
455
+ * Track4 = 8
456
+ * Track5 = 16
457
+ * Track6 = 32
458
+ * All = 0xff
459
+ */
460
+ type AudioTracks = 0 | 1 | 2 | 4 | 8 | 16 | 32 | 0xff | number;
461
+
462
+ type DisplayCaptureType = "Auto" | "DXGI" | "BitBlt" | "WGC";
463
+
464
+ type CaptureSourceType = 'Display' | 'Game' | 'Window';
465
+
466
+ interface AudioDevice {
467
+ readonly type: AudioDeviceType;
468
+ readonly id: string;
469
+ readonly name: string;
470
+ readonly isDefault: boolean;
471
+ }
472
+
473
+ interface EncoderInfoBase {
474
+ readonly codec: string;
475
+ readonly name: string;
476
+ }
477
+
478
+ interface EncoderProperty {
479
+ readonly default: any;
480
+ readonly description: string;
481
+ readonly values?: Record<string | number, string>;
482
+ }
483
+
484
+ interface AudioEncoderInfo extends EncoderInfoBase {
485
+ readonly type: kKnownAudioEncodersTypes;
486
+ }
487
+
488
+ interface VideoEncoderInfo extends EncoderInfoBase {
489
+ readonly type: kSupportedEncodersTypes;
490
+ readonly properties?: Record<string, EncoderProperty>;
491
+ }
492
+
493
+ interface AdapterInfo {
494
+ readonly index: 0;
495
+ readonly name: string;
496
+ readonly driver: string;
497
+ readonly hagsEnabled: boolean;
498
+ readonly hagsEnabledByDefault: boolean;
499
+ }
500
+
501
+ interface AudioInformation {
502
+ readonly inputDevices: AudioDevice[];
503
+ readonly outputDevices: AudioDevice[];
504
+ readonly encoders: AudioEncoderInfo[];
505
+
506
+ readonly defaultEncoder: kKnownAudioEncodersTypes;
507
+ }
508
+
509
+ interface MonitorInfo {
510
+ readonly adapterIndex: number;
511
+ readonly id: string;
512
+ readonly altId: string;
513
+ readonly dpi: number;
514
+ readonly attachedToDesktop: boolean;
515
+ readonly friendlyName: string;
516
+ readonly refreshRate: number;
517
+ readonly rect: Rect;
518
+ readonly isPrimary: boolean;
519
+ readonly displayIndex: number;
520
+ }
521
+
522
+ interface VideoInformation {
523
+ readonly encoders: VideoEncoderInfo[];
524
+ readonly adapters: AdapterInfo[];
525
+
526
+ readonly defaultEncoder: kSupportedEncodersTypes;
527
+ }
528
+
529
+ interface RecordingInformation {
530
+ audio: AudioInformation;
531
+ video: VideoInformation;
532
+ monitors: MonitorInfo[];
533
+ }
534
+
535
+ // Video settings
536
+ type kFileFormat =
537
+ | 'fragmented_mp4'
538
+ | 'fragmented_mov'
539
+ | 'mp4'
540
+ | 'flv'
541
+ | 'mkv'
542
+ | 'mov'
543
+ | 'mpegts'
544
+ | 'hls'
545
+ | 'hybrid_mp4';
546
+
547
+ type kVideoColorFormat =
548
+ | 'NV12'
549
+ | 'I420'
550
+ | 'I444'
551
+ | 'P010'
552
+ | 'I010'
553
+ | 'P216'
554
+ | 'P416'
555
+ | 'BGRA';
556
+
557
+ type kVideoColorSpec =
558
+ | 'sRGB'
559
+ | '709'
560
+ | '601'
561
+ | '2100PQ'
562
+ | '2100HLG';
563
+
564
+ type kVideoColorRange = 'Partial' | 'Full';
565
+
566
+ // encoder AMD
567
+ type kAMDEncoderRateControl =
568
+ | 'CBR'
569
+ | 'CQP'
570
+ | 'VBR'
571
+ | 'VBR_LAT'
572
+ | 'QVBR'
573
+ | 'HQVBR'
574
+ | 'HQCBR';
575
+
576
+ type kAMDEncoderPreset = 'quality' | 'balanced' | 'speed';
577
+ type kAMDEncoderPresetAV1 = kAMDEncoderPreset | 'highQuality';
578
+ type kAMDEncoderProfileAV1 = 'main';
579
+ type kAMDEncoderProfile264 =
580
+ | kAMDEncoderProfileAV1
581
+ | 'high'
582
+ | 'baseline';
583
+
584
+ // encoder NVENC
585
+ type kNVENCEncoderRateControl =
586
+ | 'CBR'
587
+ | 'CQP'
588
+ | 'VBR'
589
+ | 'Lossless';
590
+ type kNVENCEncoderMultipass = 'qres' | 'fullres' | 'disabled';
591
+ type kNVENCEncoderTuning = 'hq' | 'll' | 'ull';
592
+ type kNVENCEncoderProfile = 'main';
593
+ type kNVENCEncoderProfile264 =
594
+ | kNVENCEncoderProfile
595
+ | 'high'
596
+ | 'baseline';
597
+ type kNVENCEncoderProfileHEVC = kNVENCEncoderProfile | 'main10';
598
+
599
+ // encoder X264
600
+ type kX264EncoderRateControl = 'CBR' | 'ABR' | 'VBR' | 'CRF';
601
+
602
+ type kX264EncoderProfile = '' | 'baseline' | 'main' | 'high';
603
+ type kX264EncoderTune =
604
+ | ''
605
+ | 'film'
606
+ | 'animation'
607
+ | 'grain'
608
+ | 'stillimage'
609
+ | 'psnr'
610
+ | 'ssim'
611
+ | 'fastdecode'
612
+ | 'zerolatency';
613
+
614
+ type kX264EncoderPreset =
615
+ | 'ultrafast'
616
+ | 'superfast'
617
+ | 'veryfast' // default
618
+ | 'faster'
619
+ | 'fast'
620
+ | 'medium'
621
+ | 'slow'
622
+ | 'slower'
623
+ | 'veryslow'
624
+ | 'placebo';
625
+
626
+ // QuickSync
627
+
628
+ type kQuickSyncEncoderProfileHEVC = kNVENCEncoderProfileHEVC;
629
+ type kQuickSyncEncoderProfile264 = kNVENCEncoderProfile264;
630
+ type kQuickSyncTargetUsage =
631
+ | 'TU1' // Slowest (Best Quality)
632
+ | 'TU2' // Slower
633
+ | 'TU3' // Slow
634
+ | 'TU4' // Balanced (Medium Quality)
635
+ | 'TU5' // Fast
636
+ | 'TU6' // Faster
637
+ | 'TU7'; // Fastest (Best Speed)
638
+
639
+ type kQuickSyncEncoderRateControl =
640
+ | 'CBR'
641
+ | 'CQP'
642
+ | 'VBR'
643
+ | 'ICQ';
644
+
645
+ type VideoRecordingSplitType = 'byTime' | 'bySize' | 'manual';
646
+
647
+ interface VideoSettings {
648
+ /*
649
+ Base width resolution. Default Half HD (main monitor ratio)
650
+ */
651
+ baseWidth: number;
652
+
653
+ /*
654
+ Base height resolution. Default Half HD (main monitor ratio)
655
+ */
656
+ baseHeight: number;
657
+
658
+ /**
659
+ * Video FPS.
660
+ *
661
+ * Default is 30.
662
+ */
663
+ fps?: number;
664
+
665
+ /**
666
+ * Output (scaled) resolution. Default is same as baseWidth
667
+ */
668
+ outputWidth?: number;
669
+
670
+ /**
671
+ * Output (scaled) resolution. Default is same as baseHeight
672
+ */
673
+ outputHeight?: number;
674
+
675
+ /** Default is 'NV12' */
676
+ colorFormat?: kVideoColorFormat;
677
+
678
+ /**
679
+ * Default is '709'
680
+ */
681
+ colorRange?: kVideoColorRange;
682
+
683
+ /**
684
+ * Default is Partial
685
+ */
686
+ colorSpec?: kVideoColorSpec;
687
+
688
+ /**
689
+ * Default is 300 nits
690
+ */
691
+ sdrWhite?: number;
692
+
693
+ /*
694
+ *Default is 1000 nits
695
+ */
696
+ hdrPeak?: number;
697
+ }
698
+
699
+ interface AudioDeviceSettings {
700
+ /**
701
+ * 0.0 - 20.0, default is 1.0 (100%)
702
+ */
703
+ volume?: number;
704
+
705
+ /**
706
+ * Default is False
707
+ */
708
+ mono?: boolean;
709
+
710
+ /**
711
+ * 0.0. - 1.0. Default is 0.5
712
+ * */
713
+ balance?: number;
714
+
715
+ /**
716
+ * include Device tracks. default is include to all
717
+ */
718
+ tracks?: AudioTracks;
719
+
720
+ /**
721
+ *
722
+ */
723
+ use_device_timing?: boolean;
724
+ }
725
+
726
+ interface AudioDeviceSettingsInfo extends AudioDeviceSettings {
727
+ readonly type: AudioDeviceType;
728
+
729
+ /**
730
+ * Device Id
731
+ */
732
+ readonly id: string;
733
+
734
+ /**
735
+ * Audio device unique name or Process name for application
736
+ */
737
+ readonly name: string;
738
+ }
739
+
740
+ interface ApplicationAudioDeviceSettingsInfo
741
+ extends AudioDeviceSettingsInfo {
742
+ readonly type: 'output';
743
+ }
744
+
745
+ interface DefaultAudioDeviceParams {
746
+ /**
747
+ * Auto Separate audio tracks
748
+ * when using the default audio sources, the Input and the Output audio sources
749
+ * will use dedicate tracks (2, 3).
750
+ * and track number 1 include both
751
+ */
752
+ separateAudioTracks?: boolean;
753
+ }
754
+
755
+ interface AudioDeviceParams extends DefaultAudioDeviceParams {
756
+ /**
757
+ * Device Id
758
+ */
759
+ id: string;
760
+
761
+ /**
762
+ * Audio device unique name
763
+ */
764
+ name: string;
765
+ }
766
+
767
+ interface ApplicationAudioCaptureParams
768
+ extends DefaultAudioDeviceParams {
769
+ /**
770
+ * Process name to capture (i.e Discord.exe or minecraft.exe)
771
+ */
772
+ processName: string;
773
+ }
774
+
775
+ interface AudioGeneralSettings {
776
+ /**
777
+ * Audio sample rate.
778
+ * Default is 48000
779
+ */
780
+ sampleRate?: kSampleRate48kHz | kSampleRate441kHz;
781
+
782
+ /**
783
+ * Speaker layout.
784
+ * Default is Stereo
785
+ */
786
+ speakerLayer?: kSpeakerLayout;
787
+
788
+ /**
789
+ * Win32 only. Default it True
790
+ */
791
+ disableAudioDucking?: boolean;
792
+
793
+ /**
794
+ *
795
+ */
796
+ lowLatencyAudioBuffering?: boolean;
797
+ }
798
+
799
+ interface CaptureSourceSettings {
800
+ /**
801
+ * Source will be center and stretch (if needed) to video output size
802
+ * (Default is True)
803
+ */
804
+ stretchToOutputSize?: boolean;
805
+ }
806
+
807
+ interface MonitorCaptureSourceSettings extends CaptureSourceSettings {
808
+ monitorId: string;
809
+
810
+ /**
811
+ * Default is Auto
812
+ */
813
+ type?: DisplayCaptureType;
814
+
815
+ /**
816
+ *Capture mouse cursor. Default is true.
817
+ */
818
+ captureCursor?: boolean;
819
+
820
+ /**
821
+ *
822
+ */
823
+ forceSDR?: boolean;
824
+ }
825
+
826
+ interface GameCaptureSourceSettings extends CaptureSourceSettings {
827
+ /**
828
+ * Game Process to capture, may contain the process name or process Id.
829
+ */
830
+ gameProcess: string | number;
831
+
832
+ /**
833
+ * Slow capture. using shared memory
834
+ */
835
+ sliCompatibility?: boolean;
836
+
837
+ /**
838
+ *Capture mouse cursor. Default is true.
839
+ */
840
+ captureCursor?: boolean;
841
+
842
+ /**
843
+ *
844
+ */
845
+ allowTransparency?: boolean;
846
+
847
+ /**
848
+ *
849
+ */
850
+ premultipliedAlpha?: boolean;
851
+
852
+ /**
853
+ *Capture third-party overlays
854
+ */
855
+ captureOverlays?: boolean;
856
+
857
+ /**
858
+ * Limit capture framerate
859
+ */
860
+ limitFramerate?: boolean;
861
+
862
+ /**
863
+ *Use Rec.2100 (PQ) instead sRGB
864
+ */
865
+ rgb10a2Space?: boolean;
866
+ }
867
+
868
+ interface WindowCaptureSourceSettings extends CaptureSourceSettings {
869
+ /**
870
+ * The process name
871
+ */
872
+ executable: string;
873
+
874
+ /**
875
+ * Window Capture method (Default is Auto, WGC if enabled)
876
+ */
877
+ type?: WindowCaptureType;
878
+
879
+ /**
880
+ *Capture mouse cursor. Default is true.
881
+ */
882
+ captureCursor?: boolean;
883
+
884
+ /**
885
+ *
886
+ */
887
+ forceSDR?: boolean;
888
+
889
+ /**
890
+ * Default is True
891
+ */
892
+ clientArea?: boolean;
893
+
894
+ /**
895
+ * BitBlt multi adapter compatibility
896
+ */
897
+ compatibility?: boolean;
898
+ }
899
+
900
+ interface CaptureSource {
901
+ readonly type: CaptureSourceType;
902
+ readonly properties: any;
903
+ }
904
+
905
+ interface GameCaptureSource extends CaptureSource {
906
+ readonly type: 'Game';
907
+ readonly properties: GameCaptureSourceSettings;
908
+ }
909
+
910
+ interface MonitorCaptureSource extends CaptureSource {
911
+ readonly type: 'Display';
912
+ readonly properties: MonitorCaptureSourceSettings;
913
+ }
914
+
915
+ interface WindowCaptureSource extends CaptureSource {
916
+ readonly type: 'Window';
917
+ readonly properties: WindowCaptureSourceSettings;
918
+ }
919
+
920
+ interface AudioSettings extends AudioGeneralSettings {
921
+ inputs: AudioDeviceSettingsInfo[];
922
+ outputs: AudioDeviceSettingsInfo[];
923
+ applications: ApplicationAudioDeviceSettingsInfo[];
924
+ }
925
+
926
+ interface VideoEncoderSettingsBase {
927
+ type: kSupportedEncodersTypes;
928
+
929
+ /**
930
+ * Bitrate.
931
+ *
932
+ * Default is 8000
933
+ */
934
+ bitrate?: number;
935
+
936
+ /**
937
+ * Key frame in second.
938
+ *
939
+ * Default is 0 (i.e auto)
940
+ * Adjusting keyint_sec can optimize video streaming quality and performance, balancing between file size and video playback smoothness.
941
+ * For most recording scenarios, a keyframe interval of 2-4 seconds is recommended. This balances quality, file size, and ease of editing.
942
+ * Example: keyint_sec=2 for higher quality and easier editing, keyint_sec=4 for smaller file size.
943
+ * keyint=1 is best for splitting video or replay's but require more resources from the engine.
944
+ */
945
+ keyint_sec?: number;
946
+
947
+ /**
948
+ * Max bitrate
949
+ */
950
+ max_bitrate?: number;
951
+ }
952
+
953
+ /**
954
+ * NVENC encoder setting
955
+ */
956
+ interface EncoderSettingsNVENC extends VideoEncoderSettingsBase {
957
+ /**
958
+ * Rate Control. Default is 'CBR'
959
+ */
960
+ rate_control?: kNVENCEncoderRateControl;
961
+
962
+ /**
963
+ * Default is p5.
964
+ *
965
+ * 'p1' - Fastest (Lowest Quality)
966
+ *
967
+ * 'p2' - Faster (Lower Quality)
968
+ *
969
+ * 'p3' - Fast (Low Quality)
970
+ *
971
+ * 'p4' - Medium (Medium Quality)
972
+ *
973
+ * 'p5' - Slow (Good Quality) - Default
974
+ *
975
+ * 'p6' - Slower (Better Quality)
976
+ *
977
+ * 'p7' - Slowest (Best Quality)
978
+ */
979
+ preset2?: 'p1' | 'p2' | 'p3' | 'p4' | 'p5' | 'p6' | 'p7';
980
+
981
+ /**
982
+ * 'qres' - Two Passes (Quarter Resolution) - Default
983
+ *
984
+ * 'disabled' - Single Pass
985
+ *
986
+ * 'fullres' - Two Passes (Full Resolution)
987
+ */
988
+ multipass?: kNVENCEncoderMultipass;
989
+
990
+ /**
991
+ * Default is 'hq'
992
+ */
993
+ tune?: kNVENCEncoderTuning;
994
+
995
+ /**
996
+ * Default is True
997
+ */
998
+ psycho_aq?: boolean;
999
+
1000
+ /**
1001
+ * B-Frame. Default is 2
1002
+ */
1003
+ bf?: number;
1004
+
1005
+ /**
1006
+ * Enables dynamic B-frames.If disabled, the encoder will always use the number
1007
+ * of B-frames specified in the 'Max B-frames' setting.\n\nIf enabled,
1008
+ * it will increase visual quality by only using however many B-frames
1009
+ * are necessary, up to the maximum,\nat the cost of increased GPU utilization.
1010
+ * Default is False.
1011
+ */
1012
+ lookahead?: boolean;
1013
+
1014
+ /**
1015
+ * Gpu index. Default is 0
1016
+ */
1017
+ gpu?: number;
1018
+
1019
+ /**
1020
+ * Default is 'main'
1021
+ */
1022
+ profile?: kNVENCEncoderProfile | string;
1023
+ }
1024
+
1025
+ interface EncoderSettingsNVENC264 extends EncoderSettingsNVENC {
1026
+ /**
1027
+ * Profile (Default is 'high')
1028
+ */
1029
+ profile?: kNVENCEncoderProfile264;
1030
+ }
1031
+
1032
+ interface EncoderSettingsNVENCHEVC extends EncoderSettingsNVENC {
1033
+ /**
1034
+ * Profile (Default is 'main')
1035
+ */
1036
+ profile?: kNVENCEncoderProfileHEVC;
1037
+ }
1038
+
1039
+ // AMD
1040
+ interface EncoderSettingsAMF extends VideoEncoderSettingsBase {
1041
+ /**
1042
+ * Rate Control. Default is 'CBR'
1043
+ */
1044
+ rate_control?: kAMDEncoderRateControl;
1045
+
1046
+ /**
1047
+ * Use to specify custom AMF or FFmpeg options.
1048
+ * For example, \"level=5.2 profile=main\". Check the AMF encoder docs for more details.
1049
+ */
1050
+ ffmpeg_opts?: string;
1051
+
1052
+ /**
1053
+ * CPQ (Default is 20)
1054
+ */
1055
+ cpq?: number;
1056
+
1057
+ /**
1058
+ * Max B-frames (Default is 3)
1059
+ */
1060
+ bf?: number;
1061
+ }
1062
+
1063
+ interface EncoderSettingsAMFAV1 extends EncoderSettingsAMF {
1064
+ /**
1065
+ * Preset (Default is main)
1066
+ */
1067
+ profile?: kAMDEncoderProfileAV1;
1068
+
1069
+ /**
1070
+ * preset
1071
+ */
1072
+ preset?: kAMDEncoderPresetAV1;
1073
+ }
1074
+
1075
+ interface EncoderSettingsAMF264 extends EncoderSettingsAMF {
1076
+ /**
1077
+ * Preset (Default is high)
1078
+ */
1079
+ profile?: kAMDEncoderProfile264;
1080
+
1081
+ /*
1082
+ * preset
1083
+ */
1084
+ preset?: kAMDEncoderPreset;
1085
+ }
1086
+
1087
+ interface EncoderSettingsAMFHVEC extends EncoderSettingsAMF {
1088
+ /*
1089
+ * preset
1090
+ */
1091
+ preset?: kAMDEncoderPreset;
1092
+ }
1093
+
1094
+ interface EncoderSettingsQuickSync extends VideoEncoderSettingsBase {
1095
+ /**
1096
+ * Rate Control (Default is 'CBR')
1097
+ */
1098
+ rate_control?: kQuickSyncEncoderRateControl;
1099
+
1100
+ /**
1101
+ * Target Usage / Preset (Default is 'TU4' - Balanced (Medium Quality))
1102
+ */
1103
+ target_usage?: kQuickSyncTargetUsage;
1104
+
1105
+ /**
1106
+ * bFrames (Default is 3)
1107
+ */
1108
+ bframes?: number;
1109
+
1110
+ /**
1111
+ * Subjective Video Enhancements (Default is 'true')
1112
+ */
1113
+ enhancements?: boolean;
1114
+ }
1115
+
1116
+ interface EncoderSettingsQuickSync264 extends EncoderSettingsQuickSync {
1117
+ /**
1118
+ * Profile (Default 'high' for x264 and 'main' for 'HEVC' or 'AV1' )
1119
+ */
1120
+ profile?: kQuickSyncEncoderProfile264;
1121
+ }
1122
+
1123
+ interface EncoderSettingsQuickSyncHEVC extends EncoderSettingsQuickSync {
1124
+ /**
1125
+ * Profile (Default 'high' for x264 and 'main' for 'HEVC' or 'AV1' )
1126
+ */
1127
+ profile?: kQuickSyncEncoderProfileHEVC;
1128
+ }
1129
+
1130
+ interface EncoderSettingsX264 extends VideoEncoderSettingsBase {
1131
+ /**
1132
+ * Rate Control (Default is rate_control);
1133
+ */
1134
+ rate_control?: kX264EncoderRateControl;
1135
+
1136
+ /**
1137
+ * Preset (Default is 'veryfast')
1138
+ */
1139
+ preset?: kX264EncoderPreset;
1140
+
1141
+ /**
1142
+ * Profile (Default is None)
1143
+ */
1144
+ profile?: kX264EncoderProfile;
1145
+
1146
+ /**
1147
+ * Tun (Default is None)
1148
+ */
1149
+ tune?: kX264EncoderTune;
1150
+
1151
+ /**
1152
+ * x264 Options (separated by space)
1153
+ */
1154
+ x264opts?: string;
1155
+
1156
+ /**
1157
+ * Use Custom buffer size
1158
+ */
1159
+ use_bufsize?: boolean;
1160
+
1161
+ /**
1162
+ * Custom buffer size (Valid when 'use_bufsize' is true)
1163
+ */
1164
+ buffer_size?: number;
1165
+ }
1166
+
1167
+ interface EncoderSettingsQuickSyncH264 extends VideoEncoderSettingsBase {
1168
+ profile?: kQuickSyncEncoderProfile264;
1169
+ }
1170
+
1171
+ interface CaptureSettings {
1172
+ videoSettings: VideoSettings;
1173
+
1174
+ audioSettings: AudioSettings;
1175
+
1176
+ videoEncoderSettings: VideoEncoderSettingsBase;
1177
+
1178
+ audioEncoder: AudioEncoderInfo;
1179
+
1180
+ sources: CaptureSource[];
1181
+ }
1182
+
1183
+ interface CaptureSettingsBuilder extends CaptureSettings {
1184
+ /**
1185
+ * Add Screen video capture source
1186
+ * @param settings
1187
+ */
1188
+ addScreenSource(
1189
+ settings: MonitorCaptureSourceSettings
1190
+ ): CaptureSettingsBuilder;
1191
+
1192
+ /**
1193
+ * Add Game video capture source
1194
+ * @param settings
1195
+ */
1196
+ addGameSource(settings: GameCaptureSourceSettings): CaptureSettingsBuilder;
1197
+
1198
+ /**
1199
+ * Add Audio device capture
1200
+ */
1201
+ addAudioCapture(
1202
+ params: AudioDeviceParams,
1203
+ settings?: AudioDeviceSettings
1204
+ ): CaptureSettingsBuilder;
1205
+
1206
+ /**
1207
+ * Add Default device (Input or Output) if not already added
1208
+ * @param type
1209
+ * @param params
1210
+ * @param settings
1211
+ */
1212
+ addAudioDefaultCapture(
1213
+ type: AudioDeviceType,
1214
+ params?: DefaultAudioDeviceParams,
1215
+ settings?: AudioDeviceSettings
1216
+ ): CaptureSettingsBuilder;
1217
+
1218
+ /**
1219
+ *
1220
+ * @param param
1221
+ * @param settings
1222
+ */
1223
+ addApplicationAudioCapture(
1224
+ param: ApplicationAudioCaptureParams,
1225
+ settings?: AudioDeviceSettings
1226
+ ): CaptureSettingsBuilder;
1227
+
1228
+ /**
1229
+ * Return CaptureSettings object
1230
+ */
1231
+ build(): CaptureSettings;
1232
+ }
1233
+
1234
+ interface CaptureSettingsOptions {
1235
+ /**
1236
+ * encoder type to create capture setting.
1237
+ * Default is the best default encoder detected (GPU -> x264)
1238
+ */
1239
+ videoEncoder?: kSupportedEncodersTypes;
1240
+
1241
+ /**
1242
+ * Default is 'ffmpeg_aac' (FFmpeg AAC).
1243
+ * use queryInformation().encoders.audio gor supported encoders
1244
+ */
1245
+ audioEncoder?: kKnownAudioEncodersTypes;
1246
+
1247
+ /**
1248
+ * Add Default Audio Devices (Default is True)
1249
+ */
1250
+ includeDefaultAudioSources?: boolean;
1251
+
1252
+ /**
1253
+ * Auto Separate audio tracks
1254
+ * when using the default audio sources, the Input and the Output audio sources
1255
+ * will use dedicate tracks (2, 3).
1256
+ * and track number 1 include both
1257
+ */
1258
+ separateAudioTracks?: boolean;
1259
+ }
1260
+
1261
+ // Obs Query Information types
1262
+ interface GraphicsInformation {
1263
+ adapters: AdapterInfo[];
1264
+ monitors: MonitorInfo[];
1265
+ }
1266
+
1267
+ interface EncoderInformation {
1268
+ video: VideoEncoderInfo[];
1269
+ audio: AudioEncoderInfo[];
1270
+ }
1271
+
1272
+ interface RecordingAppOptions {
1273
+ /**
1274
+ * Show Recorder capture window
1275
+ */
1276
+ showDebugWindow?: boolean;
1277
+
1278
+ /**
1279
+ * Enable recorder debug logs
1280
+ */
1281
+ enableDebugLogs?: boolean;
1282
+
1283
+ /**
1284
+ * Custom command lines when launching recorder
1285
+ */
1286
+ customCommandLineArgs?: string[];
1287
+
1288
+ /**
1289
+ * Override OBS binaries
1290
+ */
1291
+ overrideOBSFolder?: string;
1292
+
1293
+ /**
1294
+ * Emit 'stats' event interval in milliseconds. Default is 2000 (2 second)
1295
+ * note: set 0 to disable stats emit
1296
+ */
1297
+ statsInterval?: number;
1298
+ }
1299
+
1300
+ type ErrorCode =
1301
+ | -1001 // Generic Unknown error 'Unknown'
1302
+ | -1000 // Obs process crashed 'ProcessTerminated'
1303
+ | -999 // Missing binaries 'MissingBinaries'
1304
+ | -998 // Connection to obs process error 'ConnectionOBSError'
1305
+ | -997 // Can't perform request while recording 'AlreadyRunning'
1306
+ | -12 // Split recording disabled 'SplitRecordingDisabled'
1307
+ | -11 // Missing or invalid parameters 'MissingOrInvalidParameters'
1308
+ | -10 // No active recording 'NoActiveRecording'
1309
+ | -8 // Encoder error 'EncoderError'
1310
+ | -7 // No disk space error 'NoDiskSpaceError'
1311
+ | -4 // Video file processing error 'ProcessOutputError'
1312
+ | -1 // Video bad path 'BadPathError'
1313
+ | 0 // Success 'Success'
1314
+ | 1 // Stop due to low disk space 'SuccessLowDiskSpace'
1315
+ | 2; // Replay stopped while creating replay 'SuccessWithError'
1316
+
1317
+ /**
1318
+ * Constants for error codes.
1319
+ */
1320
+ interface RecordingBaseOptions {
1321
+ /**
1322
+ * Video file format. Default is 'fragmented_mp4'
1323
+ */
1324
+ fileFormat?: kFileFormat;
1325
+
1326
+ /**
1327
+ * Video Audio tracks, default is 'Track1' or 'Track1'| 'Track2' |'Track3'
1328
+ * if |separateAudioTracks| is on.
1329
+ */
1330
+ audioTrack?: AudioTracks;
1331
+
1332
+ /**
1333
+ * Auto shutdown recording when game exit
1334
+ * Note: valid when recording with game capture source
1335
+ */
1336
+ autoShutdownOnGameExit?: boolean;
1337
+ }
1338
+
1339
+ /**
1340
+ *
1341
+ */
1342
+ interface SplitOptions {
1343
+ //splitType: VideoRecordingSplitType;
1344
+
1345
+ enableManual: boolean;
1346
+
1347
+ /**
1348
+ * Split video by time (in seconds).
1349
+ */
1350
+ maxTimeSecond?: number;
1351
+
1352
+ /**
1353
+ * Split video by size (MB).
1354
+ */
1355
+ maxBySizeMB?: number;
1356
+
1357
+ /**
1358
+ * Full video will be recorded to disk
1359
+ * parallel to splits videos (when 'splitType' is bySize or byTime)
1360
+ */
1361
+ //includeFullVideo?: boolean;
1362
+ }
1363
+
1364
+ interface RecordingOptions extends RecordingBaseOptions {
1365
+ split?: SplitOptions;
1366
+
1367
+ /**
1368
+ * Output file path (without file extension)
1369
+ */
1370
+ filePath: string;
1371
+ }
1372
+
1373
+ interface ReplayOptions extends RecordingBaseOptions {
1374
+ /**
1375
+ * Defines the length of the buffer to be recorded in seconds
1376
+ */
1377
+ bufferSecond: number;
1378
+
1379
+ /**
1380
+ * Set replay's root folder path
1381
+ */
1382
+ rootFolder: string;
1383
+ }
1384
+
1385
+ type ReplayCallback = (replay: ReplayVideo) => void;
1386
+ type StopCallback = (args: RecordStopEventArgs) => void;
1387
+ type SplitCallback = (videoInfo: SplitRecordArgs) => void;
1388
+ type StartCallback = (args: RecordEventArgs) => void;
1389
+ type ReplayStopCallback = (args: RecordEventArgs) => void;
1390
+
1391
+ interface CaptureReplayOptions {
1392
+ /**
1393
+ * Replay file name (without extension)
1394
+ */
1395
+ fileName: string;
1396
+
1397
+ /**
1398
+ * The video length, in milliseconds to include prior to the time of this call.
1399
+ */
1400
+ pastDuration: number;
1401
+
1402
+ /**
1403
+ * Auto stop (optional) in milliseconds.
1404
+ * When set to Zero, will create replay with pass duration only.
1405
+ * if not set, use |ActiveReplay| to stop the replay
1406
+ */
1407
+ timeout?: number;
1408
+ }
1409
+
1410
+ interface RecordEventArgs {
1411
+ /**
1412
+ * Video file path
1413
+ */
1414
+ filePath?: string | undefined;
1415
+
1416
+ /**
1417
+ * Recording error message when recording fail to record successfully.
1418
+ */
1419
+ error?: string;
1420
+
1421
+ /**
1422
+ * Recording stop reason
1423
+ */
1424
+ reason?: ErrorCode | number;
1425
+
1426
+ /**
1427
+ * Recording Stats
1428
+ */
1429
+ stats?: RecorderStats;
1430
+ }
1431
+
1432
+ interface RecordStopEventArgs extends RecordEventArgs {
1433
+ /**
1434
+ * Video duration in milliseconds when recording ended successfully
1435
+ */
1436
+ duration?: number;
1437
+
1438
+ /**
1439
+ *
1440
+ */
1441
+ hasError: boolean;
1442
+
1443
+ /**
1444
+ * number of splits (if had any)
1445
+ */
1446
+ splitCount?: number;
1447
+
1448
+ /**
1449
+ * Video start time (Epoch)
1450
+ */
1451
+ startTimeEpoch?: number;
1452
+ }
1453
+
1454
+ interface SplitRecordArgs extends RecordEventArgs {
1455
+ /**
1456
+ * Video duration in milliseconds when recording ended successfully
1457
+ */
1458
+ duration: number;
1459
+
1460
+ /**
1461
+ * number of split
1462
+ */
1463
+ splitCount: number;
1464
+
1465
+ /** Next video file path */
1466
+ nextFilePath: string;
1467
+
1468
+ /**
1469
+ * Video start time (Epoch)
1470
+ */
1471
+ startTimeEpoch?: number;
1472
+ }
1473
+
1474
+ interface ReplayVideo extends RecordEventArgs {
1475
+ /**
1476
+ * Replay video duration in millisecond
1477
+ */
1478
+ duration: number;
1479
+
1480
+ /**
1481
+ * Video start time (Epoch UTC) (first frame)
1482
+ */
1483
+ startTimeEpoch: number;
1484
+ }
1485
+
1486
+ /**
1487
+ * handling current ongoing active replay video.
1488
+ */
1489
+ interface ActiveReplay {
1490
+ callback?: ReplayCallback;
1491
+
1492
+ /**
1493
+ * current replay timeout in milliseconds (since was set, if was set)
1494
+ */
1495
+ readonly timeout?: number;
1496
+
1497
+ /**
1498
+ * Stop replay now.
1499
+ * @param callback (optional) set or override exiting complete callback
1500
+ */
1501
+ stop(callback?: ReplayCallback);
1502
+
1503
+ /**
1504
+ * Stop after |timeout| in milliseconds
1505
+ * @param callback (optional) set or override exiting complete callback
1506
+ */
1507
+ stopAfter(timeout: number, callback?: ReplayCallback);
1508
+ }
1509
+
1510
+ interface RecorderStats {
1511
+ /**
1512
+ * Current CPU usage in percent
1513
+ */
1514
+ cpuUsage: number;
1515
+ /**
1516
+ * Amount of memory in MB currently being used by Recorder
1517
+ */
1518
+ memoryUsage: number;
1519
+ /**
1520
+ * Available disk space on the device being used for recording storage
1521
+ */
1522
+ availableDiskSpace: number;
1523
+ /**
1524
+ * Current FPS being rendered
1525
+ */
1526
+ activeFps: number;
1527
+ /**
1528
+ * Average time in milliseconds that Recorder is taking to render a frame
1529
+ */
1530
+ averageFrameRenderTime: number;
1531
+ /**
1532
+ * Number of frames skipped by Recorder in the render thread
1533
+ */
1534
+ renderSkippedFrames: number;
1535
+ /**
1536
+ * Total number of frames outputted by the render thread
1537
+ */
1538
+ renderTotalFrames: number;
1539
+ /**
1540
+ * Number of frames skipped by Recorder in the output thread
1541
+ */
1542
+ outputSkippedFrames: number;
1543
+ /**
1544
+ * Total number of frames outputted by the output thread
1545
+ */
1546
+ outputTotalFrames: number;
1547
+ }
1548
+
1549
+ /**
1550
+ * Recorder Error object
1551
+ */
1552
+ export class RecorderError extends Error {
1553
+ code: ErrorCode;
1554
+ codeStr: string; //ErrorCodeAs
1555
+ internalError?: Error;
1556
+ }
1557
+
1558
+ interface IOverwolfRecordingApi {
1559
+ /**
1560
+ * Set Global options (For Debugging)
1561
+ */
1562
+ options: RecordingAppOptions;
1563
+
1564
+ /**
1565
+ * Is recording or replays active
1566
+ */
1567
+ isActive(): Promise<boolean>;
1568
+
1569
+ /**
1570
+ * Query System information.
1571
+ *
1572
+ * (Supported encoder, available audio\video devices, available setting with descriptions)
1573
+ */
1574
+ queryInformation(): Promise<RecordingInformation>;
1575
+
1576
+ /**
1577
+ * Setting builder class, helps to create CaptureSettings object
1578
+ * @param options
1579
+ */
1580
+ createSettingsBuilder(
1581
+ options?: CaptureSettingsOptions
1582
+ ): Promise<CaptureSettingsBuilder>;
1583
+
1584
+ /**
1585
+ * Starts video recording.
1586
+ *
1587
+ * A 'recording-started' event is triggered when recording starts.
1588
+ * Note: If recording fails to start, an exception (RecorderError) will be thrown.
1589
+ *
1590
+ * when the recording stopped to due error or game-exit, or stopRecording() call,
1591
+ * 'recording-stopped' event is trigged with the details.
1592
+ *
1593
+ * @param options - The options for the recording.
1594
+ * @param setting - Optional. Capture settings if the replay service is already running.
1595
+ * @param listener - Optional. Callback for handling recording stopped event (same as 'recording-stopped' event) .
1596
+ * @returns A promise that resolves when recording has started.
1597
+ */
1598
+ startRecording(
1599
+ options: RecordingOptions,
1600
+ setting?: CaptureSettings,
1601
+ listener?: StopCallback
1602
+ ): Promise<void>;
1603
+
1604
+ /**
1605
+ * Stop active recording
1606
+ * @param listener Optional. Callback for handling recording stopped event (same as 'recording-stopped' event). this will override the listener set in the startRecording (if was set).
1607
+ */
1608
+ stopRecording(listener?: StopCallback): Promise<void>;
1609
+
1610
+ /**
1611
+ * Split active recording video (if split option was enabled at 'RecordingOptions').
1612
+ * 'recording-split' is fired once the video split.
1613
+ *
1614
+ * ```
1615
+ * try {
1616
+ * await splitRecording(...);
1617
+ * } catch(err) {
1618
+ * if (error instanceof RecorderError) {... }
1619
+ * }
1620
+ *
1621
+ * ```
1622
+ * @param listener (optional) callback when video split.
1623
+ */
1624
+ splitRecording(listener?: SplitCallback): Promise<void>;
1625
+
1626
+ /**
1627
+ * Starts replay's recording.
1628
+ *
1629
+ * A 'replays-started' event is triggered when recording starts.
1630
+ *
1631
+ * Note: If recording fails to start, an exception (RecorderError) will be thrown.
1632
+ * ```
1633
+ * try {
1634
+ * await startReplays(...);
1635
+ * } catch(err) {
1636
+ * if (error instanceof RecorderError) {... }
1637
+ * }
1638
+ *
1639
+ * ```
1640
+ * @param options - The options for the replays.
1641
+ * @param setting - Optional. Capture settings if the replay service is already running.
1642
+ * @returns A promise that resolves when recording has started.
1643
+ */
1644
+ startReplays(
1645
+ options: ReplayOptions,
1646
+ setting?: CaptureSettings
1647
+ ): Promise<void>;
1648
+
1649
+ /**
1650
+ * Stop Replays service
1651
+ *
1652
+ * A 'replays-stopped' event is triggered when replays service stopped .
1653
+ *
1654
+ * Note: an exception (RecorderError) will be thrown, if the stop command fails
1655
+ *
1656
+ * ```
1657
+ * try {
1658
+ * await stopReplays(...);
1659
+ * } catch(err) {
1660
+ * if (error instanceof RecorderError) {... }
1661
+ * }
1662
+ *
1663
+ * ```
1664
+ *
1665
+ * (for example, replay's service is not active)
1666
+ */
1667
+ stopReplays(): Promise<void>;
1668
+
1669
+ /**
1670
+ * Capture Replay.
1671
+ * 'ActiveReplay' object to control replay (stop and such...)
1672
+ * Note: an exception (RecorderError) will be thrown, if the stop command fails
1673
+ * @param option
1674
+ * @param callback (optional) called when replay is ready in addition to 'replay-ready' event.
1675
+ */
1676
+ captureReplay(
1677
+ option: CaptureReplayOptions,
1678
+ callback?: ReplayCallback
1679
+ ): Promise<ActiveReplay>;
1680
+
1681
+ /**
1682
+ * Game launch registration
1683
+ * register to track running game, witch triggers 'game-launched' and 'game-exit' events.
1684
+ */
1685
+ registerGames(filter: GamesFilter);
1686
+
1687
+ /**
1688
+ * Fired when registered game is detected
1689
+ */
1690
+ on(eventName: 'game-launched', listener: (gameInfo: GameInfo) => void): this;
1691
+
1692
+ /**
1693
+ * Fired on registered game process terminated.
1694
+ */
1695
+ on(eventName: 'game-exit', listener: (gameInfo: GameInfo) => void): this;
1696
+
1697
+ /**
1698
+ * Fired on video recording started
1699
+ */
1700
+ on(eventName: 'recording-started', listener: StartCallback): this;
1701
+
1702
+ /**
1703
+ * Fired on video recording stopped
1704
+ */
1705
+ on(eventName: 'recording-stopped', listener: StopCallback): this;
1706
+
1707
+ /**
1708
+ * Fired on recording video split (manual/size/time)
1709
+ */
1710
+ on(eventName: 'recording-split', listener: SplitCallback): this;
1711
+
1712
+ /**
1713
+ * Fired on replays record started
1714
+ */
1715
+ on(eventName: 'replays-started', listener: StartCallback): this;
1716
+
1717
+ /**
1718
+ * Fired on replays record stopped
1719
+ */
1720
+ on(eventName: 'replays-stopped', listener: ReplayStopCallback): this;
1721
+
1722
+ /**
1723
+ * Fired on replay video was captured
1724
+ */
1725
+ on(eventName: 'replay-captured', listener: ReplayCallback): this;
1726
+
1727
+ /**
1728
+ * Fired every |statsIntervalMS| (RecordingAppOptions) interval
1729
+ * @param eventName
1730
+ * @param listener
1731
+ */
1732
+ on(eventName: 'stats', listener: (args: RecorderStats) => void): this;
1733
+ }