-
Notifications
You must be signed in to change notification settings - Fork 10
/
streaming-plugin.ts
71 lines (56 loc) · 1.91 KB
/
streaming-plugin.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
import Promise from 'bluebird';
import Plugin from '../client/plugin';
import MediaStreamPlugin from './base/media-stream-plugin';
import JanusPluginMessage from '../client/misc/plugin-message';
/**
* Original documentation of the plugin here:
* https://janus.conf.meetecho.com/docs/streaming.html
*/
class StreamingPlugin extends MediaStreamPlugin {
static NAME = 'janus.plugin.streaming';
create(id: number, options: any) {
return this._create(id, options);
}
destroy(id: number, options: any): Promise<JanusPluginMessage> {
return this._destroy(id, options);
}
list(): Promise<JanusPluginMessage> {
return this._list();
}
watch(id: number, watchOptions: any, answerOptions: any): Promise<JanusPluginMessage> {
return this._watch(id, watchOptions, answerOptions);
}
start(jsep: RTCSessionDescription): Promise<JanusPluginMessage> {
return this._start(jsep);
}
stop(): Promise<JanusPluginMessage> {
return this._stop();
}
pause(): Promise<JanusPluginMessage> {
return this._pause();
}
switch(id: number, options: any): Promise<JanusPluginMessage> {
return this._switch(id, options);
}
enable(id: number, options: any): Promise<JanusPluginMessage> {
let body = Object.assign({ request: 'enable', id }, options);
return this.sendWithTransaction({ body });
}
disable(id: number, options: any): Promise<any> {
let body = Object.assign({ request: 'disable', id }, options);
return this.sendWithTransaction({ body }).then(() => {
if (this.hasCurrentEntity(id)) {
this.resetCurrentEntity();
}
});
}
recording(id: number, options: any): Promise<JanusPluginMessage> {
let body = Object.assign({ request: 'recording', id }, options);
return this.sendWithTransaction({ body });
}
getResponseAlias() {
return 'streaming';
}
}
Plugin.register(StreamingPlugin.NAME, StreamingPlugin);
export default StreamingPlugin;