@flowplayer/player 3.11.2-rc.2 → 3.11.2-rc.3
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/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +2 -2
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/plugins/ads.js +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/asel.d.ts +5 -43
- package/plugins/asel.js +1 -1
- package/plugins/audio.d.ts +1 -23
- package/plugins/chromecast.d.ts +20 -82
- package/plugins/consent.d.ts +3 -47
- package/plugins/cuepoints.d.ts +1 -6
- package/plugins/dash.d.ts +5 -44
- package/plugins/drm.d.ts +2 -39
- package/plugins/endscreen.d.ts +7 -53
- package/plugins/gemius.d.ts +7 -45
- package/plugins/health.js +1 -1
- package/plugins/hls.d.ts +76 -14
- package/plugins/hls.js +1 -1
- package/plugins/preview.d.ts +86 -50
- package/plugins/qsel.d.ts +3 -26
- package/plugins/qul.d.ts +78 -29
- package/plugins/rts.d.ts +68 -82
- package/plugins/rts.js +1 -1
- package/plugins/speed.d.ts +1 -10
- package/plugins/ssai.d.ts +2 -47
- package/plugins/ssai.js +1 -1
- package/util/loader.d.ts +1 -1
package/plugins/preview.d.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
+
declare type AnyPlugin<PluginOwnConfig extends KeyValue> = Plugin_2<PluginOwnConfig> | Loader<PluginOwnConfig>;
|
|
4
|
+
|
|
5
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
6
|
+
|
|
7
|
+
declare enum AutoplayOpts {
|
|
8
|
+
OFF = 0,
|
|
9
|
+
ON = 1,
|
|
10
|
+
AUDIO_REQUIRED = 2
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
declare type BitOpts = number;
|
|
4
14
|
|
|
15
|
+
declare type Component = {
|
|
16
|
+
onrender?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
17
|
+
onremove?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare interface Components {
|
|
21
|
+
render(key: string, args: any[]): void;
|
|
22
|
+
remove(key: string, args: any[]): void;
|
|
23
|
+
put(key: string, args: Component): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
declare interface Config {
|
|
6
27
|
src?: UnsafeSource;
|
|
7
28
|
preload?: "none" | "metadata" | "auto";
|
|
@@ -52,21 +73,29 @@ declare interface Config {
|
|
|
52
73
|
seconds_to_dvr?: number;
|
|
53
74
|
}
|
|
54
75
|
|
|
55
|
-
declare namespace Configs {
|
|
56
|
-
export {
|
|
57
|
-
BitOpts,
|
|
58
|
-
FlowplayerCustomElementRegistry,
|
|
59
|
-
Config,
|
|
60
|
-
CustomConfig,
|
|
61
|
-
PluginConfig
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
declare type ConfigWith<T> = Configs.Config & T;
|
|
66
|
-
|
|
67
76
|
declare type CustomConfig<T> = Config & T;
|
|
68
77
|
|
|
69
|
-
declare const _default:
|
|
78
|
+
declare const _default: PluginCtor< {
|
|
79
|
+
preview?: false | ({
|
|
80
|
+
trigger?: number | undefined;
|
|
81
|
+
} & ({
|
|
82
|
+
src: string;
|
|
83
|
+
type: string;
|
|
84
|
+
dimensions?: {
|
|
85
|
+
width: number;
|
|
86
|
+
height: number;
|
|
87
|
+
} | undefined;
|
|
88
|
+
} | {
|
|
89
|
+
src: {
|
|
90
|
+
src: string;
|
|
91
|
+
type: string;
|
|
92
|
+
dimensions?: {
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
} | undefined;
|
|
96
|
+
}[];
|
|
97
|
+
})) | undefined;
|
|
98
|
+
}>;
|
|
70
99
|
export default _default;
|
|
71
100
|
|
|
72
101
|
declare type DeviceId = string;
|
|
@@ -96,6 +125,39 @@ declare type DRMVendorImplementation = {
|
|
|
96
125
|
|
|
97
126
|
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
98
127
|
|
|
128
|
+
declare interface FlowplayerUMD extends FlowplayerUMDBase {
|
|
129
|
+
(selector: string, config?: Config): Player;
|
|
130
|
+
(element: HTMLElement, config?: Config): Player;
|
|
131
|
+
<T>(selector: string, config?: CustomConfig<T>): Player;
|
|
132
|
+
<T>(element: HTMLElement, config?: CustomConfig<T>): Player;
|
|
133
|
+
<PluginCtors extends PluginCtor[]>(...plugins: PluginCtors): FlowplayerUMDWithPlugins<CustomConfig<MergeConfigs<PluginCtors>>>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare interface FlowplayerUMDBase {
|
|
137
|
+
instances: Player[];
|
|
138
|
+
extensions: PluginCtor[];
|
|
139
|
+
events: Record<string, string>;
|
|
140
|
+
ads?: {
|
|
141
|
+
events: Record<string, string>;
|
|
142
|
+
};
|
|
143
|
+
states: Record<string, string>;
|
|
144
|
+
quality: typeof QualityOpts;
|
|
145
|
+
commit: string;
|
|
146
|
+
version: string;
|
|
147
|
+
customElements: FlowplayerCustomElementRegistry;
|
|
148
|
+
defaultElements: Record<string, string>;
|
|
149
|
+
components: Components;
|
|
150
|
+
support: any;
|
|
151
|
+
autoplay: typeof AutoplayOpts;
|
|
152
|
+
jwt: any;
|
|
153
|
+
loaders: any;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config> extends FlowplayerUMDBase {
|
|
157
|
+
(selector: string, config?: ConfigWithPlugins): Player;
|
|
158
|
+
(element: HTMLElement, config?: ConfigWithPlugins): Player;
|
|
159
|
+
}
|
|
160
|
+
|
|
99
161
|
declare interface FPEvent<T> extends CustomEvent<T> {
|
|
100
162
|
/**
|
|
101
163
|
* @deprecated
|
|
@@ -115,9 +177,11 @@ declare interface Loader<PluginOwnConfig extends KeyValue = KeyValue> extends Pl
|
|
|
115
177
|
wants<S = KeyValue, T = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: PluginConfig<T>): boolean;
|
|
116
178
|
}
|
|
117
179
|
|
|
118
|
-
declare
|
|
180
|
+
declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
181
|
+
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
182
|
+
};
|
|
119
183
|
|
|
120
|
-
declare
|
|
184
|
+
declare type MergeConfigs<Arr extends PluginCtor[]> = ArrayToIntersection<MapToConfigs<Arr>>;
|
|
121
185
|
|
|
122
186
|
declare interface Player extends HTMLVideoElement {
|
|
123
187
|
renderPlugin: (pluginContainer: HTMLElement) => void;
|
|
@@ -183,32 +247,14 @@ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
|
183
247
|
|
|
184
248
|
declare type PluginConfig<T> = Config & T;
|
|
185
249
|
|
|
186
|
-
declare
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
} & ({
|
|
190
|
-
src: PreviewOpts[];
|
|
191
|
-
} | PreviewOpts)) | false;
|
|
192
|
-
}>;
|
|
193
|
-
|
|
194
|
-
declare type PreviewOpts = {
|
|
195
|
-
src: string;
|
|
196
|
-
type: string;
|
|
197
|
-
dimensions?: {
|
|
198
|
-
width: number;
|
|
199
|
-
height: number;
|
|
200
|
-
};
|
|
201
|
-
};
|
|
250
|
+
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
251
|
+
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
252
|
+
}
|
|
202
253
|
|
|
203
|
-
declare
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
preview_config?: PreviewConfig["preview"];
|
|
208
|
-
preview?: HTMLImageElement;
|
|
209
|
-
init(config: PreviewConfig, root: PlayerRoot, player: Player): void;
|
|
210
|
-
configure(config: PreviewConfig): void;
|
|
211
|
-
createPreview(opts: PreviewOpts[] | string): void;
|
|
254
|
+
declare enum QualityOpts {
|
|
255
|
+
LOW = 1,
|
|
256
|
+
MEDIUM = 2,
|
|
257
|
+
HIGH = 4
|
|
212
258
|
}
|
|
213
259
|
|
|
214
260
|
declare type SourceObj = {
|
|
@@ -221,14 +267,6 @@ declare type SourceStr = string;
|
|
|
221
267
|
|
|
222
268
|
declare type SourceWith<T> = SourceObj & T;
|
|
223
269
|
|
|
224
|
-
declare namespace triggers {
|
|
225
|
-
export {
|
|
226
|
-
MOUSEOVER,
|
|
227
|
-
MOBILE_VIEWPORT_VISIBLE,
|
|
228
|
-
VIEWPORT_VISIBLE
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
270
|
declare type UnsafeSource = SourceStr | SourceObj | Array<SourceStr | SourceObj>;
|
|
233
271
|
|
|
234
272
|
declare interface VideoTrack {
|
|
@@ -238,6 +276,4 @@ declare interface VideoTrack {
|
|
|
238
276
|
selected: boolean;
|
|
239
277
|
}
|
|
240
278
|
|
|
241
|
-
declare const VIEWPORT_VISIBLE: number;
|
|
242
|
-
|
|
243
279
|
export { }
|
package/plugins/qsel.d.ts
CHANGED
|
@@ -73,21 +73,11 @@ declare interface Config {
|
|
|
73
73
|
seconds_to_dvr?: number;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
declare namespace Configs {
|
|
77
|
-
export {
|
|
78
|
-
BitOpts,
|
|
79
|
-
FlowplayerCustomElementRegistry,
|
|
80
|
-
Config,
|
|
81
|
-
CustomConfig,
|
|
82
|
-
PluginConfig
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
declare type ConfigWith<T> = Configs.Config & T;
|
|
87
|
-
|
|
88
76
|
declare type CustomConfig<T> = Config & T;
|
|
89
77
|
|
|
90
|
-
declare const _default:
|
|
78
|
+
declare const _default: PluginCtor< {
|
|
79
|
+
qsel?: boolean | undefined;
|
|
80
|
+
}>;
|
|
91
81
|
export default _default;
|
|
92
82
|
|
|
93
83
|
declare type DeviceId = string;
|
|
@@ -243,19 +233,6 @@ declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
|
243
233
|
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
244
234
|
}
|
|
245
235
|
|
|
246
|
-
declare class Qsel implements Plugin_2 {
|
|
247
|
-
static events: {
|
|
248
|
-
TRACKS: string;
|
|
249
|
-
SWITCH: string;
|
|
250
|
-
};
|
|
251
|
-
constructor(umd: FlowplayerUMD);
|
|
252
|
-
init(config: QselConfig, container: PlayerRoot, player: Player): void;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
declare type QselConfig = ConfigWith<{
|
|
256
|
-
qsel?: boolean;
|
|
257
|
-
}>;
|
|
258
|
-
|
|
259
236
|
declare enum QualityOpts {
|
|
260
237
|
LOW = 1,
|
|
261
238
|
MEDIUM = 2,
|
package/plugins/qul.d.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
+
declare type AnyPlugin<PluginOwnConfig extends KeyValue> = Plugin_2<PluginOwnConfig> | Loader<PluginOwnConfig>;
|
|
4
|
+
|
|
5
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
6
|
+
|
|
7
|
+
declare enum AutoplayOpts {
|
|
8
|
+
OFF = 0,
|
|
9
|
+
ON = 1,
|
|
10
|
+
AUDIO_REQUIRED = 2
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
declare type BitOpts = number;
|
|
4
14
|
|
|
15
|
+
declare type Component = {
|
|
16
|
+
onrender?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
17
|
+
onremove?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare interface Components {
|
|
21
|
+
render(key: string, args: any[]): void;
|
|
22
|
+
remove(key: string, args: any[]): void;
|
|
23
|
+
put(key: string, args: Component): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
declare interface Config {
|
|
6
27
|
src?: UnsafeSource;
|
|
7
28
|
preload?: "none" | "metadata" | "auto";
|
|
@@ -52,21 +73,19 @@ declare interface Config {
|
|
|
52
73
|
seconds_to_dvr?: number;
|
|
53
74
|
}
|
|
54
75
|
|
|
55
|
-
declare namespace Configs {
|
|
56
|
-
export {
|
|
57
|
-
BitOpts,
|
|
58
|
-
FlowplayerCustomElementRegistry,
|
|
59
|
-
Config,
|
|
60
|
-
CustomConfig,
|
|
61
|
-
PluginConfig
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
declare type ConfigWith<T> = Configs.Config & T;
|
|
66
|
-
|
|
67
76
|
declare type CustomConfig<T> = Config & T;
|
|
68
77
|
|
|
69
|
-
declare const _default:
|
|
78
|
+
declare const _default: PluginCtor< {
|
|
79
|
+
hls?: {
|
|
80
|
+
native?: boolean | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
qul?: {
|
|
83
|
+
token: string;
|
|
84
|
+
device_id?: string | undefined;
|
|
85
|
+
dId?: string | undefined;
|
|
86
|
+
interval?: number | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
}>;
|
|
70
89
|
export default _default;
|
|
71
90
|
|
|
72
91
|
declare type DeviceId = string;
|
|
@@ -96,6 +115,39 @@ declare type DRMVendorImplementation = {
|
|
|
96
115
|
|
|
97
116
|
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
98
117
|
|
|
118
|
+
declare interface FlowplayerUMD extends FlowplayerUMDBase {
|
|
119
|
+
(selector: string, config?: Config): Player;
|
|
120
|
+
(element: HTMLElement, config?: Config): Player;
|
|
121
|
+
<T>(selector: string, config?: CustomConfig<T>): Player;
|
|
122
|
+
<T>(element: HTMLElement, config?: CustomConfig<T>): Player;
|
|
123
|
+
<PluginCtors extends PluginCtor[]>(...plugins: PluginCtors): FlowplayerUMDWithPlugins<CustomConfig<MergeConfigs<PluginCtors>>>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare interface FlowplayerUMDBase {
|
|
127
|
+
instances: Player[];
|
|
128
|
+
extensions: PluginCtor[];
|
|
129
|
+
events: Record<string, string>;
|
|
130
|
+
ads?: {
|
|
131
|
+
events: Record<string, string>;
|
|
132
|
+
};
|
|
133
|
+
states: Record<string, string>;
|
|
134
|
+
quality: typeof QualityOpts;
|
|
135
|
+
commit: string;
|
|
136
|
+
version: string;
|
|
137
|
+
customElements: FlowplayerCustomElementRegistry;
|
|
138
|
+
defaultElements: Record<string, string>;
|
|
139
|
+
components: Components;
|
|
140
|
+
support: any;
|
|
141
|
+
autoplay: typeof AutoplayOpts;
|
|
142
|
+
jwt: any;
|
|
143
|
+
loaders: any;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config> extends FlowplayerUMDBase {
|
|
147
|
+
(selector: string, config?: ConfigWithPlugins): Player;
|
|
148
|
+
(element: HTMLElement, config?: ConfigWithPlugins): Player;
|
|
149
|
+
}
|
|
150
|
+
|
|
99
151
|
declare interface FPEvent<T> extends CustomEvent<T> {
|
|
100
152
|
/**
|
|
101
153
|
* @deprecated
|
|
@@ -115,6 +167,12 @@ declare interface Loader<PluginOwnConfig extends KeyValue = KeyValue> extends Pl
|
|
|
115
167
|
wants<S = KeyValue, T = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: PluginConfig<T>): boolean;
|
|
116
168
|
}
|
|
117
169
|
|
|
170
|
+
declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
171
|
+
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
declare type MergeConfigs<Arr extends PluginCtor[]> = ArrayToIntersection<MapToConfigs<Arr>>;
|
|
175
|
+
|
|
118
176
|
declare interface Player extends HTMLVideoElement {
|
|
119
177
|
renderPlugin: (pluginContainer: HTMLElement) => void;
|
|
120
178
|
toggleDisable: (flag: boolean) => void;
|
|
@@ -179,23 +237,14 @@ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
|
179
237
|
|
|
180
238
|
declare type PluginConfig<T> = Config & T;
|
|
181
239
|
|
|
182
|
-
declare
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
};
|
|
186
|
-
qul?: {
|
|
187
|
-
token: string;
|
|
188
|
-
device_id?: string;
|
|
189
|
-
dId?: string;
|
|
190
|
-
interval?: number;
|
|
191
|
-
};
|
|
192
|
-
}>;
|
|
240
|
+
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
241
|
+
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
242
|
+
}
|
|
193
243
|
|
|
194
|
-
declare
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
init(config: QULConfig, root: PlayerRoot, player: Player): void;
|
|
244
|
+
declare enum QualityOpts {
|
|
245
|
+
LOW = 1,
|
|
246
|
+
MEDIUM = 2,
|
|
247
|
+
HIGH = 4
|
|
199
248
|
}
|
|
200
249
|
|
|
201
250
|
declare type SourceObj = {
|
package/plugins/rts.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
declare type AnyPlugin<PluginOwnConfig extends KeyValue> = Plugin_2<PluginOwnConfig> | Loader<PluginOwnConfig>;
|
|
4
|
+
|
|
5
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
6
|
+
|
|
7
|
+
declare enum AutoplayOpts {
|
|
8
|
+
OFF = 0,
|
|
9
|
+
ON = 1,
|
|
10
|
+
AUDIO_REQUIRED = 2
|
|
11
|
+
}
|
|
4
12
|
|
|
5
13
|
declare type BitOpts = number;
|
|
6
14
|
|
|
15
|
+
declare type Component = {
|
|
16
|
+
onrender?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
17
|
+
onremove?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare interface Components {
|
|
21
|
+
render(key: string, args: any[]): void;
|
|
22
|
+
remove(key: string, args: any[]): void;
|
|
23
|
+
put(key: string, args: Component): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
7
26
|
declare interface Config {
|
|
8
27
|
src?: UnsafeSource;
|
|
9
28
|
preload?: "none" | "metadata" | "auto";
|
|
@@ -54,6 +73,11 @@ declare interface Config {
|
|
|
54
73
|
seconds_to_dvr?: number;
|
|
55
74
|
}
|
|
56
75
|
|
|
76
|
+
declare type CustomConfig<T> = Config & T;
|
|
77
|
+
|
|
78
|
+
declare const _default: PluginCtor<KeyValue>;
|
|
79
|
+
export default _default;
|
|
80
|
+
|
|
57
81
|
declare type DeviceId = string;
|
|
58
82
|
|
|
59
83
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
|
@@ -79,14 +103,40 @@ declare type DRMVendorImplementation = {
|
|
|
79
103
|
}, cb: (license_data: Uint8Array) => void) => void;
|
|
80
104
|
};
|
|
81
105
|
|
|
82
|
-
declare
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
107
|
+
|
|
108
|
+
declare interface FlowplayerUMD extends FlowplayerUMDBase {
|
|
109
|
+
(selector: string, config?: Config): Player;
|
|
110
|
+
(element: HTMLElement, config?: Config): Player;
|
|
111
|
+
<T>(selector: string, config?: CustomConfig<T>): Player;
|
|
112
|
+
<T>(element: HTMLElement, config?: CustomConfig<T>): Player;
|
|
113
|
+
<PluginCtors extends PluginCtor[]>(...plugins: PluginCtors): FlowplayerUMDWithPlugins<CustomConfig<MergeConfigs<PluginCtors>>>;
|
|
87
114
|
}
|
|
88
115
|
|
|
89
|
-
declare
|
|
116
|
+
declare interface FlowplayerUMDBase {
|
|
117
|
+
instances: Player[];
|
|
118
|
+
extensions: PluginCtor[];
|
|
119
|
+
events: Record<string, string>;
|
|
120
|
+
ads?: {
|
|
121
|
+
events: Record<string, string>;
|
|
122
|
+
};
|
|
123
|
+
states: Record<string, string>;
|
|
124
|
+
quality: typeof QualityOpts;
|
|
125
|
+
commit: string;
|
|
126
|
+
version: string;
|
|
127
|
+
customElements: FlowplayerCustomElementRegistry;
|
|
128
|
+
defaultElements: Record<string, string>;
|
|
129
|
+
components: Components;
|
|
130
|
+
support: any;
|
|
131
|
+
autoplay: typeof AutoplayOpts;
|
|
132
|
+
jwt: any;
|
|
133
|
+
loaders: any;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config> extends FlowplayerUMDBase {
|
|
137
|
+
(selector: string, config?: ConfigWithPlugins): Player;
|
|
138
|
+
(element: HTMLElement, config?: ConfigWithPlugins): Player;
|
|
139
|
+
}
|
|
90
140
|
|
|
91
141
|
declare interface FPEvent<T> extends CustomEvent<T> {
|
|
92
142
|
/**
|
|
@@ -107,35 +157,11 @@ declare interface Loader<PluginOwnConfig extends KeyValue = KeyValue> extends Pl
|
|
|
107
157
|
wants<S = KeyValue, T = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: PluginConfig<T>): boolean;
|
|
108
158
|
}
|
|
109
159
|
|
|
110
|
-
declare
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
160
|
+
declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
161
|
+
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
162
|
+
};
|
|
114
163
|
|
|
115
|
-
declare
|
|
116
|
-
type Src = {
|
|
117
|
-
streamName: string;
|
|
118
|
-
streamAccountId: string;
|
|
119
|
-
subscriberToken?: string;
|
|
120
|
-
type: "wowza/rts";
|
|
121
|
-
};
|
|
122
|
-
type ViewerCountEvent = {
|
|
123
|
-
type: string;
|
|
124
|
-
name: "viewercount";
|
|
125
|
-
data: ViewerCount;
|
|
126
|
-
};
|
|
127
|
-
type ActiveEvent = {
|
|
128
|
-
type: string;
|
|
129
|
-
name: "active";
|
|
130
|
-
data: MediaStreamSource;
|
|
131
|
-
};
|
|
132
|
-
type InactiveEvent = {
|
|
133
|
-
type: string;
|
|
134
|
-
name: "inactive";
|
|
135
|
-
data: MediaStreamSource;
|
|
136
|
-
};
|
|
137
|
-
type BroadcastEvent = ViewerCountEvent | ActiveEvent | InactiveEvent;
|
|
138
|
-
}
|
|
164
|
+
declare type MergeConfigs<Arr extends PluginCtor[]> = ArrayToIntersection<MapToConfigs<Arr>>;
|
|
139
165
|
|
|
140
166
|
declare interface Player extends HTMLVideoElement {
|
|
141
167
|
renderPlugin: (pluginContainer: HTMLElement) => void;
|
|
@@ -201,37 +227,15 @@ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
|
201
227
|
|
|
202
228
|
declare type PluginConfig<T> = Config & T;
|
|
203
229
|
|
|
204
|
-
declare
|
|
205
|
-
|
|
206
|
-
rtsAdapter?: RTS.Adapter;
|
|
207
|
-
};
|
|
208
|
-
type Src = Millicast.Src | WowzaWebRTC.Src;
|
|
209
|
-
interface Adapter {
|
|
210
|
-
readonly log: Logger;
|
|
211
|
-
load(): void;
|
|
212
|
-
stop(): void;
|
|
213
|
-
}
|
|
214
|
-
type StatusMessage = {
|
|
215
|
-
status: Status;
|
|
216
|
-
message?: string;
|
|
217
|
-
data?: MediaStreamSource;
|
|
218
|
-
};
|
|
219
|
-
type ViewerCountEvent = {
|
|
220
|
-
viewerCount: number;
|
|
221
|
-
};
|
|
230
|
+
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
231
|
+
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
222
232
|
}
|
|
223
233
|
|
|
224
|
-
declare
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
engine?: RTS.Adapter;
|
|
229
|
-
constructor();
|
|
230
|
-
init(_config: Config, _root: PlayerRoot, player: RTS.Player): void;
|
|
231
|
-
onload(_config: Config, _root: PlayerRoot, video: RTS.Player, src: RTS.Src): void;
|
|
232
|
-
wants(_srcString: string, src: RTS.Src, _config: Config): boolean;
|
|
234
|
+
declare enum QualityOpts {
|
|
235
|
+
LOW = 1,
|
|
236
|
+
MEDIUM = 2,
|
|
237
|
+
HIGH = 4
|
|
233
238
|
}
|
|
234
|
-
export default RTSLoader;
|
|
235
239
|
|
|
236
240
|
declare type SourceObj = {
|
|
237
241
|
src?: SourceStr;
|
|
@@ -243,13 +247,6 @@ declare type SourceStr = string;
|
|
|
243
247
|
|
|
244
248
|
declare type SourceWith<T> = SourceObj & T;
|
|
245
249
|
|
|
246
|
-
declare const STATUS = "rts/status";
|
|
247
|
-
|
|
248
|
-
declare enum Status {
|
|
249
|
-
Idle = 0,
|
|
250
|
-
Receiving = 1
|
|
251
|
-
}
|
|
252
|
-
|
|
253
250
|
declare type UnsafeSource = SourceStr | SourceObj | Array<SourceStr | SourceObj>;
|
|
254
251
|
|
|
255
252
|
declare interface VideoTrack {
|
|
@@ -259,15 +256,4 @@ declare interface VideoTrack {
|
|
|
259
256
|
selected: boolean;
|
|
260
257
|
}
|
|
261
258
|
|
|
262
|
-
declare const VIEWER_COUNT = "rts/viewer-count";
|
|
263
|
-
|
|
264
|
-
declare namespace WowzaWebRTC {
|
|
265
|
-
type Src = {
|
|
266
|
-
sdpUrl: string;
|
|
267
|
-
applicationName: string;
|
|
268
|
-
streamName: string;
|
|
269
|
-
type: "wowza/webrtc";
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
259
|
export { }
|
package/plugins/rts.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* Copyright (c) 2018-2022 Koala Interactive, Inc.
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
|
-
function Df(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Mf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Df(Object(r),!0).forEach((function(t){_f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Df(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Nf(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function jf(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){Nf(o,n,i,s,a,"next",e)}function a(e){Nf(o,n,i,s,a,"throw",e)}s(void 0)}))}}function _f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bf(){}function Uf(){Uf.init.call(this)}function Vf(e){return void 0===e._maxListeners?Uf.defaultMaxListeners:e._maxListeners}function Ff(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Yf(e,n),o=0;o<n;++o)i[o].call(r)}function zf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].call(r,n)}function $f(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=Yf(e,o),a=0;a<o;++a)s[a].call(r,n,i)}function Gf(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=Yf(e,s),c=0;c<s;++c)a[c].call(r,n,i,o)}function Wf(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].apply(r,n)}function qf(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new Bf,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=Vf(e))&&i>0&&s.length>i){s.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function Hf(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Xf(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Yf(e,t){for(var r=Array(t);t--;)r[t]=e[t];return r}MillicastAdapter.Events={ACTIVE:"rts/millicast/active",INACTIVE:"rts/millicast/inactive"},MillicastAdapter.Type="wowza/rts",MillicastAdapter.Options={events:["active","inactive","viewercount"]},MillicastAdapter.WOWZA_DIRECTOR_ENDPOINT="https://realtime1.wowza.com",Bf.prototype=Object.create(null),Uf.EventEmitter=Uf,Uf.usingDomains=!1,Uf.prototype.domain=void 0,Uf.prototype._events=void 0,Uf.prototype._maxListeners=void 0,Uf.defaultMaxListeners=10,Uf.init=function(){this.domain=null,Uf.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Bf,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Uf.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Uf.prototype.getMaxListeners=function(){return Vf(this)},Uf.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:Ff(r,l,this);break;case 2:zf(r,l,this,arguments[1]);break;case 3:$f(r,l,this,arguments[1],arguments[2]);break;case 4:Gf(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];Wf(r,l,this,i)}return!0},Uf.prototype.addListener=function(e,t){return qf(this,e,t,!1)},Uf.prototype.on=Uf.prototype.addListener,Uf.prototype.prependListener=function(e,t){return qf(this,e,t,!0)},Uf.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Hf(this,e,t)),this},Uf.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Hf(this,e,t)),this},Uf.prototype.removeListener=function(e,t){var r,n,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Bf:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Bf,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},Uf.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Bf,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Bf:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Bf,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Uf.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Uf.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Xf.call(e,t)},Uf.prototype.listenerCount=Xf,Uf.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Jf=window.RTCPeerConnection,Kf=window.RTCIceCandidate,Zf=window.RTCSessionDescription;class b extends Uf{constructor(e){super(),_f(this,"pc",void 0),this.pc=new Jf({iceServers:e}),"ontrack"in this.pc?this.pc.ontrack=this.handleTrackEvent.bind(this):this.pc.onaddstream=this.handleNewStreamEvent.bind(this)}getPeerConnection(){return this.pc}close(){this.pc.close()}setRemoteDescription(e){return this.pc.setRemoteDescription(new Zf(e))}setLocalDescription(e){return this.pc.setLocalDescription(new Zf(e))}createAnswer(){var e=this;return jf((function*(){return e.pc.createAnswer()}))()}createOffer(){var e=this;return jf((function*(){return e.pc.createOffer()}))()}attachIceCandidate(e){return this.pc.addIceCandidate(new Kf(e))}attachMediaStream(e){var t=this.pc,r=t.getSenders(),n=e.getTracks();r.length?n.forEach(e=>{r.filter(t=>{var r;return(null===(r=t.track)||void 0===r?void 0:r.kind)===e.kind}).forEach(t=>{t.replaceTrack(e)})}):n.forEach(r=>{t.addTrack(r,e)})}handleNewStreamEvent(e){var{stream:t}=e;this.emit("addstream",t)}handleTrackEvent(e){e.streams.forEach(e=>{this.emit("addstream",e)})}}class C{constructor(e,t,r){this.url=e,this.streamInfo=t,this.userData=r,_f(this,"ws",null),_f(this,"pendingCommands",new Map)}connect(){return this.ws?Promise.resolve(this.ws):new Promise((e,t)=>{var r=new WebSocket(this.url);r.binaryType="arraybuffer",r.onopen=()=>e(r),r.onerror=()=>t(),r.onclose=()=>t(),r.onmessage=this.handleSocketData.bind(this),this.ws=r})}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}getOffer(){var e={direction:"play",command:"getOffer"};return this.streamInfo.secureToken&&(e.secureToken=this.streamInfo.secureToken),this.send(e)}sendOffer(e){return this.send({direction:"publish",command:"sendOffer",sdp:e})}sendResponse(e){return this.send({direction:"play",command:"sendResponse",sdp:e})}getAvailableStreams(){return this.send({direction:"play",command:"getAvailableStreams"})}send(e){var t=this;return jf((function*(){var r,n=t.ws||(yield t.connect());return t.pendingCommands.has(e.command)||t.pendingCommands.set(e.command,((r={}).promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r)),n.send(JSON.stringify(Mf(Mf({},e),{},{streamInfo:t.streamInfo,userData:t.userData}))),t.pendingCommands.get(e.command).promise}))()}handleSocketData(e){var t,r=JSON.parse(e.data);200===r.status?(null!==(t=r.streamInfo)&&void 0!==t&&t.sessionId&&(this.streamInfo.sessionId=r.streamInfo.sessionId),this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).resolve(r),this.pendingCommands.delete(r.command))):this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).reject(r),this.pendingCommands.delete(r.command))}}var Qf="mozGetUserMedia"in navigator?"firefox":"webkitGetUserMedia"in navigator||!1===window.isSecureContext&&"webkitRTCPeerConnection"in window&&!("RTCIceGatherer"in window)?"chrome":navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?"edge":window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?"safari":"unknown",ep=["vp9","vp8","h264","red","ulpfec","rtx"],tp=["opus","isac","g722","pcmu","pcma","cn"];class S{constructor(e,t){this.videoOptions=e,this.audioOptions=t,_f(this,"audioIndex",-1),_f(this,"videoIndex",-1)}transformPlay(e){return e.sdp?(e.sdp=e.sdp.replace(/profile-level-id=(\w+)/gi,(e,t)=>{var r=parseInt(t,16),n=r>>16&255,i=r>>8&255,o=255&r;return n>66?(n=66,i=224,o=31):0===i&&(i=224),"profile-level-id=".concat((n<<16|i<<8|o).toString(16))}),e):e}transformPublish(e){var t=this.prepareSDP(e),r=this.videoOptions,n=this.audioOptions,i=null,o=()=>"m=audio"===i?n:"m=video"===i?r:null,s=t.filter(Boolean).map(e=>{var[t]=e.split(/\s|:/,1);switch(t){case"m=audio":case"m=video":var s="m=audio"===t?this.audioIndex:this.videoIndex;if(-1!==s&&"chrome"===Qf){var[a,c,u]=e.split(" ");return"".concat(a," ").concat(c," ").concat(u," ").concat(s)}i=t;break;case"a=rtpmap":var l=/^a=rtpmap:(\d+)\s+(\w+)\/(\d+)/.exec(e);if(!l||"chrome"!==Qf)break;var d=l[2].toLowerCase();r.bitRate&&ep.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(r.bitRate,";x-google-max-bitrate=").concat(r.bitRate)),n.bitRate&&tp.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(n.bitRate,";x-google-max-bitrate=").concat(n.bitRate));break;case"c=IN":var f=o();if(null!=f&&f.bitRate&&["firefox","safari"].includes(Qf)){var p=1e3*f.bitRate;e+="\r\nb=TIAS:".concat(.95*p-16e3),e+="\r\nb=AS:".concat(p),e+="\r\nb=CT:".concat(p)}break;case"a=mid":var h=o();h&&"chrome"===Qf&&(h.bitRate&&(e+="\r\nb=CT:".concat(h.bitRate),e+="\r\nb=AS:".concat(h.bitRate),"frameRate"in h&&h.frameRate&&(e+="\r\na=framerate:".concat(h.frameRate.toFixed(2)))),i=null)}return e}).join("\r\n")+"\r\n";return{type:e.type,sdp:s}}checkLine(e,t){if(/^a=(rtpmap|rtcp-fb|fmtp)/.test(e)){var r=e.split(":");if(r.length>1){var[n,i]=r[1].split(" ");if(!i.startsWith("http")&&!i.startsWith("ur")){var o=parseInt(n,10),s=t.get(o)||[];return s.push(e),t.set(o,s),!1}}}return!0}deliverCheckLine(e,t,r){var n=Array.from(r).find(t=>{var[,r]=t;return r.join("\r\n").includes(e)});if(!n)return[];var[i,o]=n;return"audio"===t?this.audioIndex=i:this.videoIndex=i,"VP8"!==e&&"VP9"!==e?o:o.filter(e=>!e.includes("transport-cc")&&!e.includes("goog-remb")&&!e.includes("nack"))}addAudio(e,t){for(var r="",n=0,i=e.length;n<i;++n){var o=e[n];if(o.startsWith("m=audio"))r="audio";else if(o.startsWith("m=video"))r="video";else if("a=rtcp-mux"===o&&"audio"===r){var s=this.deliverCheckLine(this.audioOptions.codec,"audio",t);e.splice(n+1,0,...s);break}}return e}addVideo(e,t){var r=e.includes("a=rtcp-rsize"),n=e.includes("a=rtcp-mux"),i=!1;if(!r&&!n)return e;var o=this.deliverCheckLine(this.videoOptions.codec,"video",t);return e.map(e=>{if(r){if(!i&&"a=rtcp-rsize"===e)return i=!0,[e].concat(o).join("\r\n")}else if("a=rtcp-mux"===e){if(i)return[e].concat(o).join("\r\n");i=!0}return e})}flattenLines(e){return e.join("\r\n").split("\r\n")}prepareSDP(e){var t=new Map,r=(e.sdp||"").split(/\r\n/);return r=r.filter(e=>e&&this.checkLine(e,t)),r=this.flattenLines(this.addAudio(r,t)),this.flattenLines(this.addVideo(r,t))}}class x extends Uf{constructor(e,t){super(),this.video=e,_f(this,"sdpUrl",""),_f(this,"applicationName",""),_f(this,"streamName",""),_f(this,"userData",null),_f(this,"sdpHandler",void 0),_f(this,"secureToken",void 0),_f(this,"constraints",{audio:!0,video:!0}),_f(this,"videoConfigs",{bitRate:360,codec:"42e01f",frameRate:29.97}),_f(this,"audioConfigs",{codec:"opus",bitRate:64}),_f(this,"iceServers",[]),_f(this,"mediaStream",null),_f(this,"pc",null),t&&this.setConfigurations(t)}setConfigurations(e){e.constraints&&(this.constraints=e.constraints),e.videoConfigs&&(this.videoConfigs=e.videoConfigs),e.audioConfigs&&(this.audioConfigs=e.audioConfigs),e.applicationName&&(this.applicationName=e.applicationName),e.streamName&&(this.streamName=e.streamName),e.sdpUrl&&(this.sdpUrl=e.sdpUrl),void 0!==e.userData&&(this.userData=e.userData),e.iceServers&&(this.iceServers=e.iceServers),e.sdpHandler&&(this.sdpHandler=e.sdpHandler),e.secureToken&&(this.secureToken=e.secureToken)}stop(){this.pc&&(this.pc.close(),this.pc=null)}getMediaStream(){return this.mediaStream}getPeerConnection(){return this.pc?this.pc.getPeerConnection():null}playLocal(e){var t=this;return jf((function*(){e&&(t.constraints=e);var r=yield function(e){var t;return null!==(t=navigator.mediaDevices)&&void 0!==t&&t.getUserMedia?navigator.mediaDevices.getUserMedia(e):"getUserMedia"in navigator?new Promise((t,r)=>{navigator.getUserMedia(e,t,r)}):Promise.reject("Your browser does not support getUserMedia API")}(t.constraints);return t.attachStream(r),r}))()}stopLocal(){this.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>{e.stop()}),this.mediaStream=null)}playRemote(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var{sdp:n}=yield r.getOffer(),i=t.createPeerConnection();i.on("addstream",t.attachStream.bind(t)),yield i.setRemoteDescription(n);var o=yield i.createAnswer(),s=new S(t.videoConfigs,t.audioConfigs),a=t.sdpHandler?t.sdpHandler(o,e=>s.transformPlay(e),"play"):s.transformPlay(o);yield i.setLocalDescription(a);var{iceCandidates:c}=yield r.sendResponse(a);c.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}publish(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var n=t.mediaStream||(yield t.playLocal()),i=t.createPeerConnection();i.attachMediaStream(n);var o=new S(t.videoConfigs,t.audioConfigs),s=yield i.createOffer(),a=t.sdpHandler?t.sdpHandler(s,e=>o.transformPublish(e),"publish"):o.transformPublish(s);yield i.setLocalDescription(a);var{sdp:c,iceCandidates:u}=yield r.sendOffer(a);yield i.setRemoteDescription(c),u.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}getAvailableStreams(){var e=this;return jf((function*(){var t=e.createWowzaInstance();try{var{availableStreams:r}=yield t.getAvailableStreams();return r||[]}catch(e){return[]}finally{t.disconnect()}}))()}createWowzaInstance(){return new C(this.sdpUrl,{applicationName:this.applicationName,sessionId:"[empty]",streamName:this.streamName,secureToken:this.secureToken},this.userData)}createPeerConnection(){return this.pc=new b(this.iceServers),this.pc}attachStream(e){this.mediaStream=e;try{var t=this.video.srcObject instanceof MediaStream&&this.video.srcObject;t&&t.id===e.id||(this.video.srcObject=e)}catch(t){this.video.src=window.URL.createObjectURL(e)}this.pc&&this.pc.attachMediaStream(e),this.video.play()}}class WowzaWebRTCAdapter{constructor(e,r,n=t("rts/webrtc")){this.player=e,this.src=r,this.log=n}static wants(e){return e.type==WowzaWebRTCAdapter.Type}async load(){this.log("loading",this.src.streamName),this.player.original_src=this.src.sdpUrl,this.engine=new x(this.player,this.src),await this.playRemote()}async playRemote(){var e;try{await(null===(e=this.engine)||void 0===e?void 0:e.playRemote())}catch(e){this.player.emit("error",null!=e?e:{fatal:!1}),setTimeout(()=>{0==this.player.reaper||this.player.currentSrc||(this.player.emit("recover"),this.playRemote())},3e3)}}async stop(){var e;await(null===(e=this.engine)||void 0===e?void 0:e.stop())}}WowzaWebRTCAdapter.Events={ACTIVE:"rts/wowza-webrtc/active",INACTIVE:"rts/webrtc/inactive"},WowzaWebRTCAdapter.Type="wowza/webrtc";class RTSLoader{constructor(){this.log=t("rts")}init(e,t,r){r.on("reap",()=>{var e;return null===(e=this.engine)||void 0===e?void 0:e.stop()})}onload(e,t,r,n){var i;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(i=this.engine)||void 0===i||i.load()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}return RTSLoader.events=Lf,RTSLoader.state=Of,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;"function"==typeof r?r(t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t))}(window,RTSLoader),RTSLoader}));
|
|
7
|
+
function Df(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Mf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Df(Object(r),!0).forEach((function(t){_f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Df(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Nf(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function jf(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){Nf(o,n,i,s,a,"next",e)}function a(e){Nf(o,n,i,s,a,"throw",e)}s(void 0)}))}}function _f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bf(){}function Uf(){Uf.init.call(this)}function Vf(e){return void 0===e._maxListeners?Uf.defaultMaxListeners:e._maxListeners}function Ff(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Yf(e,n),o=0;o<n;++o)i[o].call(r)}function zf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].call(r,n)}function $f(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=Yf(e,o),a=0;a<o;++a)s[a].call(r,n,i)}function Gf(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=Yf(e,s),c=0;c<s;++c)a[c].call(r,n,i,o)}function Wf(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].apply(r,n)}function qf(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new Bf,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=Vf(e))&&i>0&&s.length>i){s.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function Hf(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Xf(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Yf(e,t){for(var r=Array(t);t--;)r[t]=e[t];return r}MillicastAdapter.Events={ACTIVE:"rts/millicast/active",INACTIVE:"rts/millicast/inactive"},MillicastAdapter.Type="wowza/rts",MillicastAdapter.Options={events:["active","inactive","viewercount"]},MillicastAdapter.WOWZA_DIRECTOR_ENDPOINT="https://realtime1.wowza.com",Bf.prototype=Object.create(null),Uf.EventEmitter=Uf,Uf.usingDomains=!1,Uf.prototype.domain=void 0,Uf.prototype._events=void 0,Uf.prototype._maxListeners=void 0,Uf.defaultMaxListeners=10,Uf.init=function(){this.domain=null,Uf.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Bf,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Uf.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Uf.prototype.getMaxListeners=function(){return Vf(this)},Uf.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:Ff(r,l,this);break;case 2:zf(r,l,this,arguments[1]);break;case 3:$f(r,l,this,arguments[1],arguments[2]);break;case 4:Gf(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];Wf(r,l,this,i)}return!0},Uf.prototype.addListener=function(e,t){return qf(this,e,t,!1)},Uf.prototype.on=Uf.prototype.addListener,Uf.prototype.prependListener=function(e,t){return qf(this,e,t,!0)},Uf.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Hf(this,e,t)),this},Uf.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Hf(this,e,t)),this},Uf.prototype.removeListener=function(e,t){var r,n,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Bf:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Bf,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},Uf.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Bf,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Bf:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Bf,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Uf.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Uf.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Xf.call(e,t)},Uf.prototype.listenerCount=Xf,Uf.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Jf=window.RTCPeerConnection,Kf=window.RTCIceCandidate,Zf=window.RTCSessionDescription;class b extends Uf{constructor(e){super(),_f(this,"pc",void 0),this.pc=new Jf({iceServers:e}),"ontrack"in this.pc?this.pc.ontrack=this.handleTrackEvent.bind(this):this.pc.onaddstream=this.handleNewStreamEvent.bind(this)}getPeerConnection(){return this.pc}close(){this.pc.close()}setRemoteDescription(e){return this.pc.setRemoteDescription(new Zf(e))}setLocalDescription(e){return this.pc.setLocalDescription(new Zf(e))}createAnswer(){var e=this;return jf((function*(){return e.pc.createAnswer()}))()}createOffer(){var e=this;return jf((function*(){return e.pc.createOffer()}))()}attachIceCandidate(e){return this.pc.addIceCandidate(new Kf(e))}attachMediaStream(e){var t=this.pc,r=t.getSenders(),n=e.getTracks();r.length?n.forEach(e=>{r.filter(t=>{var r;return(null===(r=t.track)||void 0===r?void 0:r.kind)===e.kind}).forEach(t=>{t.replaceTrack(e)})}):n.forEach(r=>{t.addTrack(r,e)})}handleNewStreamEvent(e){var{stream:t}=e;this.emit("addstream",t)}handleTrackEvent(e){e.streams.forEach(e=>{this.emit("addstream",e)})}}class C{constructor(e,t,r){this.url=e,this.streamInfo=t,this.userData=r,_f(this,"ws",null),_f(this,"pendingCommands",new Map)}connect(){return this.ws?Promise.resolve(this.ws):new Promise((e,t)=>{var r=new WebSocket(this.url);r.binaryType="arraybuffer",r.onopen=()=>e(r),r.onerror=()=>t(),r.onclose=()=>t(),r.onmessage=this.handleSocketData.bind(this),this.ws=r})}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}getOffer(){var e={direction:"play",command:"getOffer"};return this.streamInfo.secureToken&&(e.secureToken=this.streamInfo.secureToken),this.send(e)}sendOffer(e){return this.send({direction:"publish",command:"sendOffer",sdp:e})}sendResponse(e){return this.send({direction:"play",command:"sendResponse",sdp:e})}getAvailableStreams(){return this.send({direction:"play",command:"getAvailableStreams"})}send(e){var t=this;return jf((function*(){var r,n=t.ws||(yield t.connect());return t.pendingCommands.has(e.command)||t.pendingCommands.set(e.command,((r={}).promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r)),n.send(JSON.stringify(Mf(Mf({},e),{},{streamInfo:t.streamInfo,userData:t.userData}))),t.pendingCommands.get(e.command).promise}))()}handleSocketData(e){var t,r=JSON.parse(e.data);200===r.status?(null!==(t=r.streamInfo)&&void 0!==t&&t.sessionId&&(this.streamInfo.sessionId=r.streamInfo.sessionId),this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).resolve(r),this.pendingCommands.delete(r.command))):this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).reject(r),this.pendingCommands.delete(r.command))}}var Qf="mozGetUserMedia"in navigator?"firefox":"webkitGetUserMedia"in navigator||!1===window.isSecureContext&&"webkitRTCPeerConnection"in window&&!("RTCIceGatherer"in window)?"chrome":navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?"edge":window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?"safari":"unknown",ep=["vp9","vp8","h264","red","ulpfec","rtx"],tp=["opus","isac","g722","pcmu","pcma","cn"];class S{constructor(e,t){this.videoOptions=e,this.audioOptions=t,_f(this,"audioIndex",-1),_f(this,"videoIndex",-1)}transformPlay(e){return e.sdp?(e.sdp=e.sdp.replace(/profile-level-id=(\w+)/gi,(e,t)=>{var r=parseInt(t,16),n=r>>16&255,i=r>>8&255,o=255&r;return n>66?(n=66,i=224,o=31):0===i&&(i=224),"profile-level-id=".concat((n<<16|i<<8|o).toString(16))}),e):e}transformPublish(e){var t=this.prepareSDP(e),r=this.videoOptions,n=this.audioOptions,i=null,o=()=>"m=audio"===i?n:"m=video"===i?r:null,s=t.filter(Boolean).map(e=>{var[t]=e.split(/\s|:/,1);switch(t){case"m=audio":case"m=video":var s="m=audio"===t?this.audioIndex:this.videoIndex;if(-1!==s&&"chrome"===Qf){var[a,c,u]=e.split(" ");return"".concat(a," ").concat(c," ").concat(u," ").concat(s)}i=t;break;case"a=rtpmap":var l=/^a=rtpmap:(\d+)\s+(\w+)\/(\d+)/.exec(e);if(!l||"chrome"!==Qf)break;var d=l[2].toLowerCase();r.bitRate&&ep.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(r.bitRate,";x-google-max-bitrate=").concat(r.bitRate)),n.bitRate&&tp.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(n.bitRate,";x-google-max-bitrate=").concat(n.bitRate));break;case"c=IN":var f=o();if(null!=f&&f.bitRate&&["firefox","safari"].includes(Qf)){var p=1e3*f.bitRate;e+="\r\nb=TIAS:".concat(.95*p-16e3),e+="\r\nb=AS:".concat(p),e+="\r\nb=CT:".concat(p)}break;case"a=mid":var h=o();h&&"chrome"===Qf&&(h.bitRate&&(e+="\r\nb=CT:".concat(h.bitRate),e+="\r\nb=AS:".concat(h.bitRate),"frameRate"in h&&h.frameRate&&(e+="\r\na=framerate:".concat(h.frameRate.toFixed(2)))),i=null)}return e}).join("\r\n")+"\r\n";return{type:e.type,sdp:s}}checkLine(e,t){if(/^a=(rtpmap|rtcp-fb|fmtp)/.test(e)){var r=e.split(":");if(r.length>1){var[n,i]=r[1].split(" ");if(!i.startsWith("http")&&!i.startsWith("ur")){var o=parseInt(n,10),s=t.get(o)||[];return s.push(e),t.set(o,s),!1}}}return!0}deliverCheckLine(e,t,r){var n=Array.from(r).find(t=>{var[,r]=t;return r.join("\r\n").includes(e)});if(!n)return[];var[i,o]=n;return"audio"===t?this.audioIndex=i:this.videoIndex=i,"VP8"!==e&&"VP9"!==e?o:o.filter(e=>!e.includes("transport-cc")&&!e.includes("goog-remb")&&!e.includes("nack"))}addAudio(e,t){for(var r="",n=0,i=e.length;n<i;++n){var o=e[n];if(o.startsWith("m=audio"))r="audio";else if(o.startsWith("m=video"))r="video";else if("a=rtcp-mux"===o&&"audio"===r){var s=this.deliverCheckLine(this.audioOptions.codec,"audio",t);e.splice(n+1,0,...s);break}}return e}addVideo(e,t){var r=e.includes("a=rtcp-rsize"),n=e.includes("a=rtcp-mux"),i=!1;if(!r&&!n)return e;var o=this.deliverCheckLine(this.videoOptions.codec,"video",t);return e.map(e=>{if(r){if(!i&&"a=rtcp-rsize"===e)return i=!0,[e].concat(o).join("\r\n")}else if("a=rtcp-mux"===e){if(i)return[e].concat(o).join("\r\n");i=!0}return e})}flattenLines(e){return e.join("\r\n").split("\r\n")}prepareSDP(e){var t=new Map,r=(e.sdp||"").split(/\r\n/);return r=r.filter(e=>e&&this.checkLine(e,t)),r=this.flattenLines(this.addAudio(r,t)),this.flattenLines(this.addVideo(r,t))}}class x extends Uf{constructor(e,t){super(),this.video=e,_f(this,"sdpUrl",""),_f(this,"applicationName",""),_f(this,"streamName",""),_f(this,"userData",null),_f(this,"sdpHandler",void 0),_f(this,"secureToken",void 0),_f(this,"constraints",{audio:!0,video:!0}),_f(this,"videoConfigs",{bitRate:360,codec:"42e01f",frameRate:29.97}),_f(this,"audioConfigs",{codec:"opus",bitRate:64}),_f(this,"iceServers",[]),_f(this,"mediaStream",null),_f(this,"pc",null),t&&this.setConfigurations(t)}setConfigurations(e){e.constraints&&(this.constraints=e.constraints),e.videoConfigs&&(this.videoConfigs=e.videoConfigs),e.audioConfigs&&(this.audioConfigs=e.audioConfigs),e.applicationName&&(this.applicationName=e.applicationName),e.streamName&&(this.streamName=e.streamName),e.sdpUrl&&(this.sdpUrl=e.sdpUrl),void 0!==e.userData&&(this.userData=e.userData),e.iceServers&&(this.iceServers=e.iceServers),e.sdpHandler&&(this.sdpHandler=e.sdpHandler),e.secureToken&&(this.secureToken=e.secureToken)}stop(){this.pc&&(this.pc.close(),this.pc=null)}getMediaStream(){return this.mediaStream}getPeerConnection(){return this.pc?this.pc.getPeerConnection():null}playLocal(e){var t=this;return jf((function*(){e&&(t.constraints=e);var r=yield function(e){var t;return null!==(t=navigator.mediaDevices)&&void 0!==t&&t.getUserMedia?navigator.mediaDevices.getUserMedia(e):"getUserMedia"in navigator?new Promise((t,r)=>{navigator.getUserMedia(e,t,r)}):Promise.reject("Your browser does not support getUserMedia API")}(t.constraints);return t.attachStream(r),r}))()}stopLocal(){this.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>{e.stop()}),this.mediaStream=null)}playRemote(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var{sdp:n}=yield r.getOffer(),i=t.createPeerConnection();i.on("addstream",t.attachStream.bind(t)),yield i.setRemoteDescription(n);var o=yield i.createAnswer(),s=new S(t.videoConfigs,t.audioConfigs),a=t.sdpHandler?t.sdpHandler(o,e=>s.transformPlay(e),"play"):s.transformPlay(o);yield i.setLocalDescription(a);var{iceCandidates:c}=yield r.sendResponse(a);c.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}publish(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var n=t.mediaStream||(yield t.playLocal()),i=t.createPeerConnection();i.attachMediaStream(n);var o=new S(t.videoConfigs,t.audioConfigs),s=yield i.createOffer(),a=t.sdpHandler?t.sdpHandler(s,e=>o.transformPublish(e),"publish"):o.transformPublish(s);yield i.setLocalDescription(a);var{sdp:c,iceCandidates:u}=yield r.sendOffer(a);yield i.setRemoteDescription(c),u.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}getAvailableStreams(){var e=this;return jf((function*(){var t=e.createWowzaInstance();try{var{availableStreams:r}=yield t.getAvailableStreams();return r||[]}catch(e){return[]}finally{t.disconnect()}}))()}createWowzaInstance(){return new C(this.sdpUrl,{applicationName:this.applicationName,sessionId:"[empty]",streamName:this.streamName,secureToken:this.secureToken},this.userData)}createPeerConnection(){return this.pc=new b(this.iceServers),this.pc}attachStream(e){this.mediaStream=e;try{var t=this.video.srcObject instanceof MediaStream&&this.video.srcObject;t&&t.id===e.id||(this.video.srcObject=e)}catch(t){this.video.src=window.URL.createObjectURL(e)}this.pc&&this.pc.attachMediaStream(e),this.video.play()}}class WowzaWebRTCAdapter{constructor(e,r,n=t("rts/webrtc")){this.player=e,this.src=r,this.log=n}static wants(e){return e.type==WowzaWebRTCAdapter.Type}async load(){this.log("loading",this.src.streamName),this.player.original_src=this.src.sdpUrl,this.engine=new x(this.player,this.src),await this.playRemote()}async playRemote(){var e;try{await(null===(e=this.engine)||void 0===e?void 0:e.playRemote())}catch(e){this.player.emit("error",null!=e?e:{fatal:!1}),setTimeout(()=>{0==this.player.reaper||this.player.currentSrc||(this.player.emit("recover"),this.playRemote())},3e3)}}async stop(){var e;await(null===(e=this.engine)||void 0===e?void 0:e.stop())}}WowzaWebRTCAdapter.Events={ACTIVE:"rts/wowza-webrtc/active",INACTIVE:"rts/webrtc/inactive"},WowzaWebRTCAdapter.Type="wowza/webrtc";class RTSLoader{constructor(){this.log=t("rts")}init(e,t,r){r.on("reap",()=>{var e;return null===(e=this.engine)||void 0===e?void 0:e.stop()})}onload(e,t,r,n){var i;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(i=this.engine)||void 0===i||i.load()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}return RTSLoader.events=Lf,RTSLoader.state=Of,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}(window,RTSLoader)}));
|