new AVDEngine()
AVDEngine构造函数。
初始默认值:
日志显示 - Appender.browserConsole
日志级别 - LogLevel.error
- Source:
Example
var avdEngine = new AVDEngine();
Methods
checkBrowserPluginSupport()
检测当前浏览器是否通过插件支持open-avd相应的webrtc等
- Source:
Example
var browserPluginSupport = avdEngine.checkBrowserPluginSupport();
checkBrowserSupport()
检测当前浏览器是否支持open-avd相应的webrtc等,目前仅支持chrome内核的浏览器和firefox
- Source:
Example
var browserSupport = avdEngine.checkBrowserSupport();
checkCloseAudio() → {Object}
检查关闭麦克风
- Source:
Returns:
- stream
- Type
- Object
Example
avdEngine.checkCloseAudio();
checkCloseVideo() → {Object}
检查关闭摄像头
- Source:
Returns:
- stream
- Type
- Object
Example
avdEngine.checkCloseVideo();
checkDevice() → {Object}
检查设备是否存在
- Source:
Returns:
- deviceResult = {video: false,audio: false,speaker: false};
- Type
- Object
Example
avdEngine.checkDevice().then(checkResult).otherwise(checkError);
function checkResult(result) {
console.log("has video:" + result.video);
console.log("has audio:" + result.audio);
console.log("has speaker:" + result.speaker);
}
checkOpenAudio(microphoneId) → {Object}
检查打开麦克风
Parameters:
Name | Type | Description |
---|---|---|
microphoneId |
String | 麦克风ID,不输入则自动打开麦克风 |
- Source:
Returns:
- stream
- Type
- Object
Example
avdEngine.checkOpenAudio().then(showAudio).otherwise(alertError);
function showAudio(stream) {
checkAudio.srcObject = stream;
}
checkOpenVideo(cameraId, resolution, framerate) → {Object}
检查打开摄像头
Parameters:
Name | Type | Description |
---|---|---|
cameraId |
String | 摄像头ID,不输入则自动打开摄像头 |
resolution |
Int | 分辨率 |
framerate |
Int | 帧率 |
- Source:
Returns:
- stream
- Type
- Object
Example
avdEngine.checkOpenVideo(cameraId, resolution, framerate).then(showVideo).otherwise(alertError);
function showVideo(stream) {
checkVideo.srcObject = stream;
}
getAllDevices() → {Object}
获取当前所有设备
- Source:
Returns:
- devices
- Type
- Object
Example
avdEngine.getAllDevices().then(onAllDevices).otherwise(showError);
function onAllDevices(devices) {
devices.forEach(function(device){
if (device.kind === 'audioinput') {}
}
}
getBrowserDetect() → {Object}
获取浏览器检测结果
- Source:
Returns:
- 浏览器检测结果对象
- Type
- Object
Example
var AVDEngine = ModuleBase.use(ModulesEnum.avdEngine);
var avdEngine = new AVDEngine();
var detect = avdEngine.getBrowserDetect();
detect.browser.name : 浏览器内核名称
detect.browser.fullVersion: 内核版本
detect.osName: 操作系统名称
detect.getUserMediaSupport:是否支持webrtc的GetUserMedia
detect.RTCPeerConnectionSupport:是否支持webrtc的RTCPeerConnection
detect.dataChannelSupport: 是否支持webrtc的DataChannel
detect.WebSocketSupport: 是否支持WebSocket
detect.screenSharingSupport: 是否支持屏幕共享(chrome42以上及https访问)
detect.h264Support: 是否支持H264(chrome52及以上)
getDeviceObject() → {Object}
获取所有设备对象
- Source:
Returns:
- deviceObject = {video: video,audio: audio,speaker: speaker};
- Type
- Object
Example
avdEngine.getDeviceObject().then(showDevices).otherwise(alertError);
getResolutionEnum()
获取摄像头分辨率枚举
- Source:
Example
avdEngine.getResolutionEnum().then(fillResolutionElement);
function fillResolutionElement(resolutionEnum){
for(var key in resolutionEnum){
var resolutionObject = resolutionEnum[key];
var value =resolutionObject.width +" X " + resolutionObject.height;
}
}
getVersion() → {String}
获取avdEngine的版本号
- Source:
Returns:
- 版本号
- Type
- String
getVideoCoding()
获取当前的视频编码格式
- Source:
Example
avdEngine.getVideoCoding();
init(serverURI, accessToken)
avdEngine初始化
Parameters:
Name | Type | Description |
---|---|---|
serverURI |
String | MCU服务器地址 |
accessToken |
String | Access Token |
- Source:
initWithOEM(serverURI, oemName)
avdEngine OEM初始化
Parameters:
Name | Type | Description |
---|---|---|
serverURI |
String | MCU服务器地址 |
oemName |
String | oem名称 |
- Source:
obtainLive(restServerURI) → {Object}
获取直播。
Parameters:
Name | Type | Description |
---|---|---|
restServerURI |
String | 直播服务REST API 的服务器地址 |
- Source:
Returns:
live - 直播对象
- Type
- Object
obtainOutgoing(restServerURI) → {Object}
获取外部设备,包括rtsp和h323。
Parameters:
Name | Type | Description |
---|---|---|
restServerURI |
String | 外部设备服务REST API 的服务器地址 |
- Source:
Returns:
live - 直播对象
- Type
- Object
obtainRecord(restServerURI) → {Object}
获取录制。
Parameters:
Name | Type | Description |
---|---|---|
restServerURI |
String | 录制服务REST API 的服务器地址 |
- Source:
Returns:
recode - 录制对象
- Type
- Object
obtainRoom(roomId) → {Object}
获取房间。如房间存在,直接返回;不存在时创建房间后返回
Parameters:
Name | Type | Description |
---|---|---|
roomId |
String | 房间ID |
- Source:
Returns:
room - 房间对象
- Type
- Object
refreshDevice()
设备热插拔时,更新设备资源
逻辑:摄像头设备会全部初始化,麦克风设备只只初始化默认的一个
- Source:
setLog(appenderModel, logLevel)
设置日志显示方式和日志级别
Parameters:
Name | Type | Description |
---|---|---|
appenderModel |
Appender | 日志显示方式,枚举型 |
logLevel |
LogLevel | 日志级别,枚举型 |
- Source:
Example
avdEngine.setLog(Appender.browserConsole, LogLevel.debug);
setMcuClusterRouteParams(mcuClusterRouteParams,参数值格式参考如:{ip_tag":"local","idc_code":"idc_code"})
设置分布式集群部署中,加入房间时mcu服务器的分配路由参数
Parameters:
Name | Type | Description |
---|---|---|
mcuClusterRouteParams,参数值格式参考如:{ip_tag":"local","idc_code":"idc_code"} |
Object | ip_tag 对应于 rtc_node_addr 中的tag标志,用于区分同一台服务器的多网卡地址,可以自定义,然后在参数中传入。举例的话,比如 'local','internal','dianxin','liantong' idc_code 对应于 rtc_node 中的 idc_code标志,用于区分不同的服务器,唯一,可以自定义。比如北京服务器设置为'beijing',杭州的设置为'hangzhou',然后在参数中传入,用于定位到服务器。 |
- Source:
setVideoCoding(videoCodingType)
设置视频编码格式
Parameters:
Name | Type | Description |
---|---|---|
videoCodingType |
VideoCodingType | 视频编码格式,枚举型 |
- Source:
Example
avdEngine.setVideoCoding(VideoCodingType.h264);