forked from iizukanao/node-rtsp-rtmp-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
39 lines (30 loc) · 895 Bytes
/
server.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
import url from 'url';
import config from './config';
import StreamServer from './stream_server';
import Bits from './bits';
import logger from './logger';
Bits.set_warning_fatal(true);
logger.setLevel(logger.LEVEL_INFO);
let streamServer = new StreamServer;
streamServer.setLivePathConsumer(function(uri, callback) {
let pathname = url.parse(uri).pathname.slice(1);
let isAuthorized = true;
if (isAuthorized) {
return callback(null); // Accept access
} else {
return callback(new Error('Unauthorized access'));
}
}); // Deny access
if (config.recordedDir != null) {
streamServer.attachRecordedDir(config.recordedDir);
}
process.on('SIGINT', () => {
console.log('Got SIGINT');
return streamServer.stop(() => process.kill(process.pid, 'SIGTERM'));
}
);
process.on('uncaughtException', function(err) {
streamServer.stop();
throw err;
});
streamServer.start();