forked from kedacomresearch/webstreamer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
136 lines (116 loc) · 4.11 KB
/
index.js
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
const WebStreamer = require('./lib/webstreamer').WebStreamer;
var webstreamer_ = null;
var tesseract = require('./lib/tesseract.js');
function Initialize(options) {
if (webstreamer_) {
throw new Error('Webstreamer has been initialized once!');
}
webstreamer_ = new WebStreamer();
if (options) {
for (var key in options) {
if (webstreamer_.option[key]) {
if (typeof webstreamer_.option[key] == 'object')
webstreamer_.option[key] = Object.assign(webstreamer_.option[key], options[key]);
else
webstreamer_.option[key] = options[key];
}
}
}
return webstreamer_.initialize();
}
function Terminate() {
if (!webstreamer_) {
return;
}
return new Promise(function (resolve, reject) {
webstreamer_.terminate()
.then(data => {
// webstreamer_=null;
resolve(data);
}).catch(err => {
// webstreamer_=null;
reject(err);
});
});
}
function Version() {
return webstreamer_.version();
}
var default_option = require('./lib/analyzesource.js').option;
var _RTSPTestServer = require('./lib/rtsptestserver').RTSPTestServer;
class RTSPTestServer extends _RTSPTestServer {
constructor(name, option = undefined) {
if (!option) {
super(webstreamer_, name, default_option);
}
else {
super(webstreamer_, name, option);
}
webstreamer_.apps_[`${this.name}@${this.type}`] = this;
}
}
var _RTSPAnalyzer = require('./lib/rtspanalyzer').RTSPAnalyzer;
class RTSPAnalyzer extends _RTSPAnalyzer {
constructor(name, url, option = undefined) {
if (!option)
super(webstreamer_, name, url, default_option);
else
super(webstreamer_, name, url, option);
webstreamer_.apps_[`${this.name}@${this.type}`] = this;
}
}
var _WebRTCAnalyzer = require('./lib/rtspanalyzer').WebRTCAnalyzer;
class WebRTCAnalyzer extends _WebRTCAnalyzer {
constructor(name, signal_bridge, role, id = 1234, option = undefined) {
if (!option)
super(webstreamer_, name, signal_bridge, id, default_option, role);
else
super(webstreamer_, name, signal_bridge, id, option, role);
webstreamer_.apps_[`${this.name}@${this.type}`] = this;
}
}
const _GStreamerVideoTestSrcAnalyzer = require('./lib/gsttestsrcanalyzer').GStreamerVideoTestSrcAnalyzer;
class GStreamerVideoTestSrcAnalyzer extends _GStreamerVideoTestSrcAnalyzer {
constructor(name) {
super(webstreamer_, name);
webstreamer_.apps_[`${this.name}@${this.type}`] = this;
}
}
const _GStreamerAudioTestSrcAnalyzer = require('./lib/gsttestsrcanalyzer').GStreamerAudioTestSrcAnalyzer;
class GStreamerAudioTestSrcAnalyzer extends _GStreamerAudioTestSrcAnalyzer {
constructor(name) {
super(webstreamer_, name);
webstreamer_.apps_[`${this.name}@${this.type}`] = this;
}
}
const _LiveStream = require('./lib/livestream').LiveStream;
class LiveStream extends _LiveStream {
constructor(name) {
super(webstreamer_, name);
webstreamer_.apps_[`${this.name}@${this.type}`] = this;
}
}
const _MultiPoints = require('./lib/multipoints').MultiPoints;
class MultiPoints extends _MultiPoints {
constructor(name) {
super(webstreamer_, name);
webstreamer_.apps_[`${this.name}@${this.type}`] = this;
}
}
const utils = require('./lib/utils');
module.exports = {
option: default_option,
utils: utils,
WebStreamer: WebStreamer,
Initialize: Initialize,
Terminate: Terminate,
Version: Version,
RTSPTestServer: RTSPTestServer,
RTSPAnalyzer: RTSPAnalyzer,
GStreamerVideoTestSrcAnalyzer: GStreamerVideoTestSrcAnalyzer,
GStreamerAudioTestSrcAnalyzer: GStreamerAudioTestSrcAnalyzer,
LiveStream: LiveStream,
MultiPoints: MultiPoints,
WebRTCAnalyzer: WebRTCAnalyzer,
tesseract: tesseract
};