Class: AVDEngine

AVDEngine


new AVDEngine()

AVDEngine构造函数

Example
var avdEngine = new AVDEngine();

Methods


checkAudioLevel(intervalMilis, showAudioLevel)

设备检测,麦克风音量的检测回调

Parameters:
Name Type Description
intervalMilis int

音量采购频率,毫秒

showAudioLevel Object

音量值回调方法

Example
avdEngine.checkAudioLevel(1000,showAudioLevel);
function showAudioLevelm(audioLevel) {}

checkBrowserPluginSupport()

检测当前浏览器是否通过插件支持open-avd相应的webrtc等

Example
var browserPluginSupport = avdEngine.checkBrowserPluginSupport();

checkBrowserSupport()

检测当前浏览器是否支持open-avd相应的webrtc等,目前仅支持Chrome内核的浏览器和firefox

Example
var browserSupport = avdEngine.checkBrowserSupport();

checkCloseAudio()

设备检测,关闭麦克风

Example
avdEngine.checkCloseAudio();

checkCloseVideo()

设备检测,关闭摄像头

Example
avdEngine.checkCloseVideo();

checkOpenAudio(microphoneId)

设备检测,打开麦克风

Parameters:
Name Type Description
microphoneId String

麦克风ID,空字符串时则默认选择打开一个麦克风

Returns:
  • 音频流对象
Type
Object
Example
avdEngine.checkOpenAudio().then(showAudio).otherwise(alertError);

function showAudio(stream) {
   checkAudio.srcObject = stream;
}

checkOpenVideo(cameraId, resolution, framerate)

设备检测,打开摄像头

Parameters:
Name Type Description
cameraId String

摄像头ID,空字符串时则默认选择打开一个摄像头

resolution Int

视频分辨率

framerate Int

视频帧率

Returns:
  • 视频流对象
Type
Object
Example
avdEngine.checkOpenVideo(cameraId, resolution, framerate).then(showVideo).otherwise(alertError);

function showVideo(stream) {
   checkVideo.srcObject = stream;
}

checkOpenVideoAndAudio(cameraId, microphoneId, resolution, framerate)

设备检测,打开摄像头和麦克风

Parameters:
Name Type Description
cameraId String

摄像头ID,空字符串时则默认选择打开一个摄像头

microphoneId String

麦克风ID,空字符串时则默认选择打开一个麦克风

resolution Int

视频分辨率

framerate Int

视频帧率

Returns:
  • 音视频流对象
Type
Object
Example
avdEngine.checkOpenVideoAndAudio().then(showVideoAndAudio).otherwise(alertError);

function showVideoAndAudio(stream) {
   checkVideo.srcObject = stream.videoStream;
   checkAudio.srcObject = stream.audioStream;
}

getAllDevices()

获取当前所有设备的原始对象,需要应用层自己去疏理摄像头,麦克风等。

Returns:
  • devices - 所有设备的原始对象
Type
Object
Example
avdEngine.getAllDevices().then(onAllDevices).otherwise(showError);

function onAllDevices(devices) {
   devices.forEach(function(device){
	     if (device.kind === 'videoinput' || device.kind === 'video') {
	           console.log("camera:",device);
      }else if(device.kind === 'audioinput' || device.kind === 'audio'){
	           console.log("microphone:",device);
      }else if(device.kind === 'audiooutput'){
	           console.log("speaker:",device);
      }
   }
}

getAudioAutoSub()

获取当前的音频的订阅方式,true为自动订阅,flase为手动订阅

Example
avdEngine.getAudioAutoSub();

getAudioCoding()

获取当前的音频编码格式

Example
avdEngine.getAudioCoding();

getBrowserDetect()

获取浏览器检测结果

Returns:
  • 浏览器检测结果对象
Type
Object
Example
var detect = avdEngine.getBrowserDetect();

detect.browser.name:  浏览器内核名称
detect.browser.fullVersion: 内核版本
detect.browser.is3Tee: 是否是叁体定制外壳
detect.browser.shellFullVersion:外壳版本
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及以上)

getDataCryptoType()

获取当前的数据加密类型

Example
avdEngine.getDataCryptoType();

getElectronManager()

获取ElectronManager对象

Example
var electronManager = avdEngine.getElectronManager();

getMediaConnectType()

获取媒体通道协议,0 表示udp优先; 1表示 tcp优先,默认为0

Example
avdEngine.getMediaConnectType();

getResolutionEnum()

获取摄像头分辨率枚举,该枚举值只是罗列了主流的分辨率,而非真实的当前摄像头支持的分辨率集。

Example
avdEngine.getResolutionEnum().then(fillResolutionElement);

function fillResolutionElement(resolutionEnum){
	    for(var key in resolutionEnum){
			 	var resolutionObject = resolutionEnum[key];
			 	var value = resolutionObject.width +" X " + resolutionObject.height;
	     }
}

getStreamExporterManager()

获取流导出对象

Returns:

streamExporterManager - 流导出对象

Type
Object

getVersion()

获取avdEngine的版本号

Returns:
  • 版本号
Type
String
Example
var Version = avdEngine.getVersion();

getVideoCoding()

获取当前的视频编码格式

Example
avdEngine.getVideoCoding();

init(serverURI, accessToken, isUseCascade)

引擎初始化

Parameters:
Name Type Description
serverURI String

MCU服务器地址

accessToken String

访问令牌

isUseCascade Boolean

是否级联加入会议,可以不传,默认为false


initDevice()

初始化摄像头、麦克风设备

逻辑:摄像头设备会全部初始化到服务器,麦克风设备只会初始化默认的一个到服务器

Returns:
  • 返回初始化完成状态。1:代表完成
Type
int
Example
avdEngine.initDevice().then(function(result){
	   if(result == 1){
	      console.log('设备初始化完成');
    }
});

initWithOEM(serverURI, oemName)

avdEngine OEM初始化

Parameters:
Name Type Description
serverURI String

MCU服务器地址

oemName String

oem名称


obtainLive(restServerURI)

获取直播对象,走Restful API实现。

Parameters:
Name Type Description
restServerURI String

直播服务REST API 的服务器地址

Returns:

live - 直播对象

Type
Object

obtainOutgoing(restServerURI)

获取外部设备对象,包括rtsp和h323。走Restful API实现。

Parameters:
Name Type Description
restServerURI String

外部设备服务REST API 的服务器地址

Returns:

outgoing - 外部设备对象

Type
Object

obtainRecord(restServerURI)

获取录制对象,走Restful API实现。

Parameters:
Name Type Description
restServerURI String

录制服务REST API的服务器地址

Returns:

record - 录制对象

Type
Object

obtainRoom(roomId)

获取房间。如房间存在,直接返回,不存在时创建房间后返回

Parameters:
Name Type Description
roomId String

房间ID

Returns:

room - 房间对象

Type
Object
Example
var roomId = '13124323454';
room = avdEngine.obtainRoom(roomId);

refreshDevice()

设备热插拔时,通过该方法可以更新设备资源。

逻辑:摄像头设备会全部初始化到服务器,麦克风设备只会初始化默认的一个到服务器


setApplyToElectron(islectron, protocolStr)

Electron开发应用时,设置应用的协议

Parameters:
Name Type Description
islectron Boolean

islectron true为应用于Electron

protocolStr String

protocolStr Electron应用时的协议,可不填,默认为http:


setAudioAutoSub(isAudioAutodSub)

设置音频订阅方式是否为自动订阅,默认值为true

Parameters:
Name Type Description
isAudioAutodSub Boolean

true为自动订阅,flase为手动订阅

Example
avdEngine.setAudioAutoSub(false);

setAudioBatchEnabled(isAudioBatch)

音频自动订阅时,设置对多路音频批量订阅处理,这样可以只进行一次SDP交互以提高性能,默认值为false,

Parameters:
Name Type Description
isAudioBatch Boolean

false为不开启,true为开启

Example
avdEngine.setAudioBatchEnabled(true);

setAudioCoding(audioCodingType)

设置音频编码格式

Parameters:
Name Type Description
audioCodingType AudioCodingType

音频编码格式(枚举型),默认值为AudioCodingType.PCMU

Example
avdEngine.setAudioCoding(AudioCodingType.opus);

setBugout(logFilename)

设置日志的可输出下载地址

Parameters:
Name Type Description
logFilename String

输出下载地址

Example
avdEngine.setBugout(avdlog.txt);

setDataCryptoType(dataCryptoType)

设置数据加密类型

Parameters:
Name Type Description
dataCryptoType DataCryptoType

数据加密类型(枚举型),默认值为DataCryptoType.AES128

Example
avdEngine.setDataCryptoType(DataCryptoType.AES256);

setDefaultScreenParams(maxWidth, maxHeight, minFrameRate, maxFrameRate)

设置桌面共享相关的默认参数值

Parameters:
Name Type Description
maxWidth int

分辨率最大宽度,默认值为1920

maxHeight int

分辨率最大高度,默认值为1080

minFrameRate int

最小帧率, 默认值为5

maxFrameRate int

最大帧率, 默认值为10

Example
avdEngine.setDefaultScreenParams(1080,720,5,10);

setDefaultVideoParams(width, height, resolutionSetType, frameRate)

设置视频相关的默认参数值

Parameters:
Name Type Description
width int

分辨率宽,默认值为640

height int

分辨率高,默认值为480

resolutionSetType Object

分辨率设置类型枚举,默认值为强制即ResolutionSetType.ideal

frameRate int

视频帧率,默认值为20

Example
avdEngine.setDefaultVideoParams(1080,720,ResolutionSetType.ideal,25);

setLog(appenderModel, logLevel)

设置日志显示方式和日志级别

Parameters:
Name Type Description
appenderModel Appender

日志显示方式(枚举型), 默认值为Appender.browserConsole

logLevel LogLevel

日志级别(枚举型),默认值为LogLevel.error

Example
avdEngine.setLog(Appender.browserConsole, LogLevel.debug);

setMcuClusterRouteParams(mcuClusterRouteParams)

在分布式集群部署中,设置加入房间时mcu服务器的路由参数分配

Parameters:
Name Type Description
mcuClusterRouteParams Object

参数值格式参考如:{ip_tag":"local","idc_code":"idc_code"} ip_tag:对应于 rtc_node_addr 中的tag标志,用于区分同一台服务器的多网卡地址,可以自定义,然后在参数中传入。 举例的话,比如 'local','internal','dianxin','liantong' idc_code:对应于 rtc_node 中的 idc_code标志,用于区分不同的服务器,唯一,可以自定义。 比如北京服务器设置为'beijing',杭州的设置为'hangzhou',然后在参数中传入,用于定位到服务器。


setMediaConnectType(mediaType,)

设置媒体通道协议

Parameters:
Name Type Description
mediaType, int

0 表示udp优先; 1表示 tcp优先,默认为0

Example
avdEngine.setMediaConnectType(1);

setRecordingMicrophone(microphoneId)

设置成当前使用的麦克风

Parameters:
Name Type Description
microphoneId String

麦克风设备Id


setSimulcastEnabled(isSimulcast)

设置视频是否开启多流,默认值为false

Parameters:
Name Type Description
isSimulcast Boolean

false为不开启,true为开启

Example
avdEngine.setSimulcastEnabled(true);

setVideoCoding(videoCodingType)

设置视频编码格式

Parameters:
Name Type Description
videoCodingType VideoCodingType

视频编码格式(枚举型),默认值为videoCodingType.VP8

Example
avdEngine.setVideoCoding(VideoCodingType.H264);