-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
50 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
const app = require('express')() | ||
, server = require('http').Server(app) | ||
, io = require('socket.io')(server) | ||
, rtsp = require('../lib/rtsp-ffmpeg') | ||
; | ||
// use rtsp = require('rtsp-ffmpeg') instead if you have install the package | ||
server.listen(6147, function(){ | ||
console.log('Listening on localhost:6147'); | ||
}); | ||
|
||
|
||
var cams = [ | ||
'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov' | ||
, 'rtsp://192.168.1.168/h264main' | ||
, 'udp://localhost:1234' | ||
].map(function(uri, i) { | ||
var stream = new rtsp.FFMpeg({input: uri, resolution: '320x240', quality: 3}); | ||
stream.on('start', function() { | ||
console.log('stream ' + i + ' started'); | ||
}); | ||
stream.on('stop', function() { | ||
console.log('stream ' + i + ' stopped'); | ||
}); | ||
return stream; | ||
}); | ||
|
||
cams.forEach(function(camStream, i) { | ||
var ns = io.of('/cam' + i); | ||
ns.on('connection', function(wsocket) { | ||
console.log('connected to /cam' + i); | ||
var pipeStream = function(data) { | ||
wsocket.emit('data', data); | ||
}; | ||
camStream.on('data', pipeStream); | ||
|
||
wsocket.on('disconnect', function() { | ||
console.log('disconnected from /cam' + i); | ||
camStream.removeListener('data', pipeStream); | ||
}); | ||
}); | ||
}); | ||
|
||
io.on('connection', function(socket) { | ||
socket.emit('start', cams.length); | ||
}); | ||
|
||
app.get('/', function (req, res) { | ||
res.sendFile(__dirname + '/index-canvas.html'); | ||
}); | ||
const app = require('express')() | ||
, server = require('http').Server(app) | ||
, io = require('socket.io')(server) | ||
, rtsp = require('../lib/rtsp-ffmpeg') | ||
; | ||
// use rtsp = require('rtsp-ffmpeg') instead if you have install the package | ||
server.listen(6147, function(){ | ||
console.log('Listening on localhost:6147'); | ||
}); | ||
|
||
|
||
var cams = [ | ||
'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov' | ||
, 'rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream' | ||
, 'udp://localhost:1234' | ||
].map(function(uri, i) { | ||
var stream = new rtsp.FFMpeg({input: uri, resolution: '320x240', quality: 3}); | ||
stream.on('start', function() { | ||
console.log('stream ' + i + ' started'); | ||
}); | ||
stream.on('stop', function() { | ||
console.log('stream ' + i + ' stopped'); | ||
}); | ||
return stream; | ||
}); | ||
|
||
cams.forEach(function(camStream, i) { | ||
var ns = io.of('/cam' + i); | ||
ns.on('connection', function(wsocket) { | ||
console.log('connected to /cam' + i); | ||
var pipeStream = function(data) { | ||
wsocket.emit('data', data); | ||
}; | ||
camStream.on('data', pipeStream); | ||
|
||
wsocket.on('disconnect', function() { | ||
console.log('disconnected from /cam' + i); | ||
camStream.removeListener('data', pipeStream); | ||
}); | ||
}); | ||
}); | ||
|
||
io.on('connection', function(socket) { | ||
socket.emit('start', cams.length); | ||
}); | ||
|
||
app.get('/', function (req, res) { | ||
res.sendFile(__dirname + '/index-canvas.html'); | ||
}); |
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