Skip to content

Instantly share code, notes, and snippets.

@iizukanao
Created December 5, 2016 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iizukanao/4a7d0ab3aee5bda4d32025ef18467ff3 to your computer and use it in GitHub Desktop.
Save iizukanao/4a7d0ab3aee5bda4d32025ef18467ff3 to your computer and use it in GitHub Desktop.
Accept streaming if ?stream_key=xxxx is present
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