Created
December 5, 2016 12:06
-
-
Save iizukanao/4a7d0ab3aee5bda4d32025ef18467ff3 to your computer and use it in GitHub Desktop.
Accept streaming if ?stream_key=xxxx is present
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) -> | |
uriInfo = url.parse uri, true | |
if uriInfo.query.stream_key is 'xxxx' | |
return callback null # Accept access | |
else | |
return callback new Error 'Unauthorized' # 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment