Class: WebRTC2

WebRTC2


new WebRTC2()

WebRTC2
sdk的WebRTC2公共对象.

Methods


createClient(options)

创建客户端,开始通话前调用一次即可

Parameters:
Name Type Description
options Object

配置参数

Properties
Name Type Argument Default Description
appkey String <optional>

实例的应用ID

debug Boolean <optional>
false

是否开启debug模式,默认不开启,debug模式下浏览器会打印log日志

Returns:

Client对象

Type
Client

createStream(options)

该方法创建并返回音视频流对象。
注意:自 V4.1.0 版本起,摄像头与屏幕共享的视频流可以同时发送,其中,屏幕共享流会以辅流形式发送。

Parameters:
Name Type Description
options Object

配置参数

Properties
Name Type Argument Description
audio String

是否从麦克风采集音频

uid String

用户uid

microphoneId String <optional>

麦克风设备 deviceId,通过 getMicrophones() 获取

video Object

是否从摄像头采集视频

cameraId String <optional>

摄像头设备 deviceId,通过 getCameras() 获取

screen Object <optional>

是否采集屏幕共享流(辅流)

audioSource MeidaTrack <optional>

自定义的音频的track

videoSource MeidaTrack <optional>

自定义的视频的track

client client <optional>

和要Stream绑定的client实例对象,默认是最初使用用createClient创建的client实例(多实例场景使用)

Returns:

Stream对象

Type
Stream

destroy(client)

销毁Client对象

Parameters:
Name Type Description
client Client

要销毁的client实例,不传递则销毁最初使用用createClient创建的client实例(一般多实例场景使用)

Returns:
Type
Promise

getCameras()

获取可用的视频输入设备。

Returns:
Type
DeviceInfo
Example
//接口使用示例
     WebRTC2.getCameras().then(data => {
        data.forEach(item=>{
          console.log('video label: ', item.label, 'deviceId: ', item.deviceId)
        })
      })

getDevices()

该方法枚举可用的媒体输入/输出设备,比如麦克风、摄像头、耳机等。

Returns:
  • deviceInfo 完整的设备信息

    Type
    Promise.<Object>
  • deviceInfo.audioIn 可用的音频输入设备

    Type
    Array.<DeviceInfo>
  • deviceInfo.audioOut 可用的音频输出设备。

    Type
    Array.<DeviceInfo>
  • deviceInfo.video 可用的视频输入设备。

    Type
    Array.<DeviceInfo>
Example
//接口使用示例
WebRTC2.getDevices().then(data => {
  const {audioIn, audioOut, video} = data
  audioIn.forEach(item=>{
    console.log('mic label: ', item.label, 'deviceId: ', item.deviceId)
  })
  video.forEach(item=>{
    console.log('video label: ', item.label, 'deviceId: ', item.deviceId)
  })
  //...
})

getMicrophones()

获取可用的音频输入设备。

Returns:
Type
Promise

getSpeakers()

获取可用的音频输出设备。

Returns:
Type
Promise

<static> constructor()

WebRTC2 是 云信 Web SDK 中所有可调用方法的入口