forked from iizukanao/node-rtsp-rtmp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.coffee
More file actions
34 lines (25 loc) · 763 Bytes
/
server.coffee
File metadata and controls
34 lines (25 loc) · 763 Bytes
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
url = require 'url'
config = require './config'
StreamServer = require './stream_server'
Bits = require './bits'
logger = require './logger'
Bits.set_warning_fatal true
logger.setLevel logger.LEVEL_INFO
streamServer = new StreamServer
streamServer.setLivePathConsumer (uri, callback) ->
pathname = url.parse(uri).pathname[1..]
isAuthorized = true
if isAuthorized
callback null # Accept access
else
callback new Error 'Unauthorized access' # Deny access
if config.recordedDir?
streamServer.attachRecordedDir config.recordedDir
process.on 'SIGINT', =>
console.log 'Got SIGINT'
streamServer.stop ->
process.kill process.pid, 'SIGTERM'
process.on 'uncaughtException', (err) ->
streamServer.stop()
throw err
streamServer.start()