-
Notifications
You must be signed in to change notification settings - Fork 0
/
RerunOBSBinding.ts
155 lines (123 loc) · 4.02 KB
/
RerunOBSBinding.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const OBSBinding = require('bindings')('RerunOBSBinding.node');
export interface OBSClient {
init(video: VideoSettings, audio: AudioSettings, moduleConfigPath: string): boolean;
loadModule(moduleBinaryPath: string, moduleDataPath: string) : void;
setupEncoders(video: EncoderConfig, audio: EncoderConfig) : void;
shutdown() : void;
createSource(name: string, type: string, settings: OBSDataObject) : OBSSource;
destroySource(source: OBSSource) : void;
startStream(address: string, key: string) : void;
stopStream() : void;
getMainScene() : OBSScene;
openPreviewWindow() : void;
}
export interface OBSScene {
getName() : string;
addSource(source: OBSSource) : OBSSceneItem;
removeSceneItem(sceneItem: OBSSceneItem) : void;
findSceneItemForSource(source: OBSSource) : OBSSceneItem | null;
}
export interface OBSSceneItem {
isVisible() : boolean;
setVisible(visible: boolean) : void;
getSource() : OBSSource;
getParentScene() : OBSScene;
changeOrder(order: OBSOrder) : void;
setOrderIndex(index: number) : void;
}
export interface OBSSource {
getName() : string;
updateSettings(settings: OBSDataObject) : void;
isEnabled() : boolean;
setEnabled(enabled: boolean) : void;
playMedia() : void;
pauseMedia() : void;
stopMedia() : void;
restartMedia() : void;
getMediaTime() : number;
/**
* Register a one-time callback to fire after the source's media time
* passes a certain number of milliseconds. If the specified time has
* already passed when this method is called, the callback will fire immediately.
* @param timeMs The time in milliseconds the callback should be triggered after
* @param callback Function to run once timeMs is reached
*/
onceMediaTime(timeMs: number, callback: () => void) : number;
offMediaTime(listenerId: number) : void;
on(signal: string, callback: (data: any)=>void) : number;
once(signal: string, callback: (data: any)=>void) : number;
off(listenerId: number) : void;
}
export const enum OBSOrder {
MOVE_UP = 0,
MOVE_DOWN = 1,
MOVE_TO_TOP = 2,
MOVE_TO_BOTTOM = 3
}
export const enum SpeakerLayout {
"Mono" = 1,
"Stereo" = 2,
"Surround51" = 6,
"Surround71" = 8
}
export const enum GraphicsModule {
Direct3D = "libobs-d3d11",
OpenGL = "libobs-opengl"
}
export interface VideoSettings {
module: GraphicsModule;
fps: number;
width: number;
height: number;
}
export interface AudioSettings {
samples: number;
speakerLayout: SpeakerLayout;
}
export const enum VideoEncoderType {
x264 = 'obs_x264',
NVENC = 'jim_nvenc',
QuickSync = 'obs_qsv11'
}
export const enum AudioEncoderType {
AAC = 'ffmpeg_aac',
Opus = 'ffmpeg_opus'
}
export interface EncoderConfig {
encoder: VideoEncoderType | AudioEncoderType;
encoderSettings: OBSDataObject;
}
export enum OBSStatus {
NOT_STARTED = 0, //The OBS process is not running
INITIALIZED = 1, //OBS has started and the video/audio systems are active
READY = 2, //Audio/video encoders and the RTMP output are configured
STREAM_CONNECTING = 3, //Attempting to connect to the RTMP server
STREAMING = 4 //Connected and streaming
}
export type OBSDataObject = {[key: string] : OBSDataValue};
type SupportedOBSType = string | number | boolean;
export interface OBSDataValue {
type: string;
value: SupportedOBSType | Array<OBSDataObject>;
}
export class OBSString implements OBSDataValue {
type = 'string';
constructor(public value: string){};
}
export class OBSInt implements OBSDataValue {
type = 'int';
constructor(public value: number){};
}
export class OBSDouble implements OBSDataValue {
type = 'double';
constructor(public value: number){};
}
export class OBSBool implements OBSDataValue {
type = 'bool';
constructor(public value: boolean){};
}
export class OBSArray implements OBSDataValue {
type = 'array';
constructor(public value: Array<OBSDataObject>){};
}
export default <OBSClient> OBSBinding;