diff --git a/src/samples/conference/samplertcservice.js b/src/samples/conference/samplertcservice.js index c21ac622..45ca3bec 100644 --- a/src/samples/conference/samplertcservice.js +++ b/src/samples/conference/samplertcservice.js @@ -376,6 +376,31 @@ app.delete('/rooms/:room/streaming-ins/:id', function(req, res) { }); }); +app.post('/rooms/:room/streaming-ins-srt', function(req, res) { + 'use strict'; + var room = req.params.room, + url = req.body.url, + transport = req.body.transport, + media = req.body.media; + + icsREST.API.startStreamingInSRT(room, url, transport, media, function(result) { + res.send(result); + }, function(err) { + res.send(err); + }); +}); + +app.delete('/rooms/:room/streaming-ins-srt/:id', function(req, res) { + 'use strict'; + var room = req.params.room, + stream_id = req.params.id; + icsREST.API.stopStreamingInSRT(room, stream_id, function(result) { + res.send(result); + }, function(err) { + res.send(err); + }); +}); + app.get('/rooms/:room/streaming-outs', function(req, res) { 'use strict'; var room = req.params.room; diff --git a/src/sdk/rest/API.js b/src/sdk/rest/API.js index 30160b28..075bede3 100644 --- a/src/sdk/rest/API.js +++ b/src/sdk/rest/API.js @@ -855,6 +855,86 @@ OWT_REST.API = (function(OWT_REST) { }, callbackError); }; + /** + *** + * @function startStreamingInSRT + * @desc This function adds an external SRT stream to the specified room. + * @memberOf OWT_REST.API + * @param {string} room -Room ID + * @param {Object} connection -Transport parameters. + * @param {string} connection.url -URL of the streaming source, e.g. the source URL of IPCamera. + * @param {string} connection.mode -SRT connection mode, "listener" or "caller", "listener" by default. + * @param {number} connection.latency -The SRT latency with microseconds. + * @param {Object} media Media requirements. + * @param {string='auto' | boolean} media.video -If video is required, "auto" or true or false, "auto" by default. + * @param {string='auto' | boolean} media.audio -If audio is required, "auto" or true or false, "auto" by default. + * @param {onStartingStreamingInOK} callback -Callback function on success + * @param {function} callbackError -Callback function on error + * @example + var roomId = '51c10d86909ad1f939000001'; + var url = 'rtsp://10.239.44.7:554/rtsp_tunnel%3Fh26x=4%26line=1'; + var transport = { + url = 'srt://10.239.44.7:1234', + mode: 'listener', + latency: 100 + }; + var media = { + audio: 'auto', + video: true + }; + + OWT_REST.API.startStreamingIn(roomId, url, transport, media, function(stream) { + console.log('Streaming-In:', stream); + }, function(status, error) { + // HTTP status and error + console.log(status, error); + }); + */ +var startStreamingInSRT = function(room, url, options, media, callback, callbackError) { + console.log("Send streaming in srt request"); + var pub_req = { + connection: { + url: url, + mode: options.mode, + latency: options.latency + }, + media: media + }; + send('POST', 'rooms/' + room + '/streaming-ins-srt/', pub_req, function(streamRtn) { + var st = JSON.parse(streamRtn); + callback(st); + }, callbackError); + }; + + +/** + * @function stopStreamingInSRT + * @desc This function stops the specified external streaming-in in the specified room. + * @memberOf OWT_REST.API + * @param {string} room -Room ID + * @param {string} stream -Stream ID + * @param {function} callback -Callback function on success + * @param {function} callbackError -Callback function on error + * @example + var roomId = '51c10d86909ad1f939000001'; + var streamID = '878889273471677'; + OWT_REST.API.stopStreamingIn(roomId, streamID, function(result) { + console.log('External streaming-in:', streamID, 'in room:', roomId, 'stopped'); + }, function(status, error) { + // HTTP status and error + console.log(status, error); + }); + */ + var stopStreamingInSRT = function(room, stream, callback, callbackError) { + if (typeof stream !== 'string' || stream.trim().length === 0) { + return callbackError('Invalid stream ID'); + } + send('DELETE', 'rooms/' + room + '/streaming-ins-srt/' + stream, undefined, function(result) { + callback(result); + }, callbackError); + }; + + /* * * @callback onStreamingOutList * * @param {Array.} streamingOutList -The list of streaming-outs. @@ -1476,6 +1556,8 @@ OWT_REST.API = (function(OWT_REST) { //Streaming-ins management. startStreamingIn: startStreamingIn, stopStreamingIn: stopStreamingIn, + startStreamingInSRT: startStreamingInSRT, + stopStreamingInSRT: stopStreamingInSRT, //Streaming-outs management getStreamingOuts: getStreamingOuts,