-
Notifications
You must be signed in to change notification settings - Fork 0
IC.Video.Stream client js
Shun-Yun Hu edited this page Oct 18, 2015
·
19 revisions
TOC
新增移除 Stream 來源
- new ( args, onDone ) -- 新增影音串流來源 (目前前端不使用)
-
delete ( streamID, onDone ) -- 刪除影音串流來源 (目前前端不使用)
啟用、停用串流 - enable ( streamID, onDone ) -- 啟用影音串流 (目前前端不使用)
-
disable ( streamID, onDone ) -- 停用影音串流 (目前前端不使用)
開始播放、停止播放串流 - start ( streamID, player, onDone ) -- 開始播放串流
-
stop ( streamID, onDone ) -- 停止播放串流 (並釋放針對此 client 的 WebRTC 資源)
其他功能 - info ( streamIDs ) -- 取得串流資訊
Client side (Viewer / Web) 使用的 Stream 函式庫
var streamID = document.getElementById('vid').value;
var videoTagPlayer = document.getElementById('video');
// Stream should already been added and enabled by server.
IC.Video.Stream.start(
streamID,
videoTagPlayer,
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'streaming'}
}
);
IC.Video.Stream.stop(
streamID,
videoTagPlayer,
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'enabled'}
}
);
The returned status is Not a Must Have.
None.
新增影音串流來源 (目前前端不使用)
new( args, onDone )
var originSource = document.getElementById('address').value;
// 'rtsp://10.20.30.40:554/video1.sdp';
IC.Video.Stream.new(
{ type: 'rtsp', source: originSource},
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'disabled' }
}
);
- input
args should contain at least type and source.
type currently supports rtsp and custom.
If type: 'custom', you must add format: {} in args. - callback
If the stream already exists (identified by originSource), return the existing data. Newly added stream will have the status: 'disabled' by default. - return
None.
移除影音串流來源 (目前前端不使用)
delete( streamID, onDone )
var streamID = document.getElementById('vid').value; // string
IC.Video.Stream.delete(
streamID,
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'enabled'}
}
);
- input
- callback
status will be the last status before it's been deleted. If some clients are still streaming from this stream before the operation, they should be stopped and stream should be disabled by server. - return
None.
啟用影音串流 (目前前端不使用)
enable( streamID, onDone )
var streamID = 'an ID of an stream';
IC.Video.Stream.enable(
streamID,
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'enabled' }
}
);
- input
- callback
- return
None.
停用影音串流 (目前前端不使用)
disable( streamID, onDone )
var streamID = 'an ID of an stream';
IC.Video.Stream.disable(
streamID,
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'disabled' }
}
);
- input
- callback
- return
None.
開始播放串流
start( streamID, player, onDone )
var streamID = document.getElementById('vid').value; // string
var player = document.getElementById('video'); // video tag object
IC.Video.Stream.start(
streamID,
player,
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'streaming' }
}
);
You must have a video object.
- input
- callback
- return
None.
停止播放串流 (並釋放針對此 client 的 WebRTC 資源)
stop( streamID, onDone )
var streamID = document.getElementById('vid').value; // string
var player = document.getElementById('video'); // video tag object
IC.Video.Stream.stop(
streamID,
player,
function ( err, ret ) {
// ret === { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'enabled' }
}
);
You must have a video object currently streaming.
- input
- callback
If there's anyone using the stream after this operation, status shows 'streaming', otherwise 'enabled'. - return
None.
取得串流列表
info(streamIDs, onDone);
var streamID_1 = [document.getElementById('vid').value];
var streamIDs = ['streamID_1', 'streamID_2', 'streamID_3'];
IC.Video.Stream.info( [], function () {} ); // return all streams
IC.Video.Stream.info(
streamIDs,
function ( err, ret ) {
// ret === [
// { type: 'xxx', originSource: 'xxx', streamID: 'xxx', status: 'streaming' },
// { type: 'yyy', originSource: 'yyy', streamID: 'yyy', status: 'enabled' },
// { type: 'zzz', originSource: 'zzz', streamID: 'zzz', status: 'disabled' },
//]
}
);
- input
If streamIDs is an empty array, return all streams info. Otherwise return specified streams. - callback
- return
None.