Web JS SDK API 文档

更新时间:2020-12-03

OctopusRTC

Kind: global class

创建OctopusRTC实例

new OctopusRTC(appId, userId, [env], [type], [logLevel], [userName])

ParamTypeDefaultDescription
appIdstringappId
userIdstring用户的userId
[env]string"prod"SDK环境选择
[type]string"international"节点环境选择
[logLevel]number日志级别
[userName]string用户名称

初始化SDK

octopusRTC.init()

Kind: instance method of OctopusRTC

登录房间

octopusRTC.login(roomId, role, auth, expire) ⇒ Array | errMsg

Kind: instance method of OctopusRTC
Returns: Array | errMsg - {(Promise<streamList[] | errMsg>)}

ParamTypeDescription
roomIdstring房间id
role1 | 2角色
authstring鉴权签名值
expirestring过期时间戳

登出房间

octopusRTC.logout()

Kind: instance method of OctopusRTC

创建流

octopusRTC.createStream([source]) ⇒ mediastream

Kind: instance method of OctopusRTC
Returns: mediastream - {Promise}

ParamTypeDescription
[source]object视频源类型
[source.camera]object摄像头
[source.screen]object屏幕共享
[source.custom]object自定义流
[source.camera.audio]boolean是否开启音频
[source.camera.video]boolean是否开启视频
[source.camera.audioInput]string音频输入设备
[source.camera.audioBitrate]number音频码率
[source.camera.videoInput]string视频输入设备
[source.camera.videoQuality]1 | 2 | 3 | 4视频质量
[source.camera.facingMode]string切换摄像头(移动端)
[source.camera.width]number
[source.camera.height]number
[source.camera.frameRate]number帧率
[source.camera.bitrate]number码率
[source.camera.AGC]boolean自动增益
[source.camera.ANS]boolean回声消除
[source.camera.AEC]boolean降噪
[source.screen.audio]boolean(共享屏幕)是否开启音频
[source.screen.videoQuality]1 | 2 | 3 | 4视频质量设置
[source.screen.frameRate]number帧率
[source.screen.bitrate]number码率
source.custom.sourceMediaStream视频流
[source.custom.bitrate]number码率

删除流

octopusRTC.destroyStream(mediastream)

Kind: instance method of OctopusRTC

ParamType
mediastreamMediaStream

开始推流

octopusRTC.startPublishingStream(streamId, mediaElement) ⇒ void

Kind: instance method of OctopusRTC
Returns: void - {Promise}

ParamTypeDescription
streamIdstring流id
mediaElementMediaStream

停止推流

octopusRTC.stopPublishingStream(streamId)

Kind: instance method of OctopusRTC

ParamTypeDescription
streamIdstring流id

开始拉流

octopusRTC.startPlayingStream(streamId) ⇒ void

Kind: instance method of OctopusRTC
Returns: void - {(Promise<MediaStream | void>)}

ParamTypeDescription
streamIdstring流id

停止拉流

octopusRTC.stopPlayingStream(streamId)

Kind: instance method of OctopusRTC

ParamTypeDescription
streamIdstring流id

混流

octopusRTC.updateMixStream(mixStreamConfig) ⇒ *

Kind: instance method of OctopusRTC
Returns: * - {Promise}

ParamType
mixStreamConfigmixStreamConfig

更改流track

octopusRTC.replaceTrack(currentStream, track, [streamId])

Kind: instance method of OctopusRTC

ParamType
currentStreamMediaStream
trackMediaStreamTrack
[streamId]string

更改约束、设备

octopusRTC.changeConstraints(currentStream, type, @type, [streamId]) ⇒ Promise

Kind: instance method of OctopusRTC
Returns: Promise - {(Promise<errMsg | void>)}

ParamTypeDescription
currentStreamMediaStream
type'audio' | 'video'
@typeMediaTrackConstraints | sourceCameraconstrains
[streamId]string

开启静音

octopusRTC.muteSwitch(streamId, mute)

Kind: instance method of OctopusRTC

ParamTypeDescription
streamIdstring流id
muteboolean是否静音

切换摄像头

octopusRTC.cameraSwitch(streamId, state)

Kind: instance method of OctopusRTC

ParamTypeDescription
streamIdstring流id
state'close' | 'open'摄像头状态

流变化通知 event

"stream-update" ⇒ stramUpdateResult

Kind: event emitted by OctopusRTC
Since: 2.0

websocket 断开通知 event.

"disconnect" ⇒ errMsg

Kind: event emitted by OctopusRTC
Since: 2.0

踢人通知 event.

"kick-out" ⇒ kickResult

Kind: event emitted by OctopusRTC
Since: 2.0

判断浏览器是否支持WebRTC

OctopusRTC.isSupported() ⇒ boolean

Kind: static method of OctopusRTC

自定义类型

errMsg : Object
sourceCamera : Object
videoQuality : 1 | 2 | 3 | 4
stramUpdateResult
kickResult

errMsg : Object

Kind: global typedef
Properties

NameType
codenumber
msgstring

sourceCamera : Object

Kind: global typedef
Properties

NameTypeDescription
audioboolean是否开启音频
videoboolean是否开启视频
audioInputstring音频输入设备
videoInputstring视频输入设备
videoQualitynumber视频质量
facingModestring摄像头朝向,"user"表示前置摄像头,"environment"表示后置摄像头
widthnumber
heightnumber
frameRatenumber帧率
bitratenumber码率
AGCboolean自动增益
ANSboolean回声消除
AECboolean降噪

videoQuality : 1 | 2 | 3 | 4

Kind: global typedef
Properties

NameTypeDescription
1number分辨率: 320 * 240, 帧率: 15, 码率: 300
2number分辨率: 640 * 480, 帧率: 15, 码率: 800
3number分辨率: 1280 * 720, 帧率: 20, 码率: 1500
4number分辨率: width * height, 帧率: frameRate, 码率: bitRate(k)

stramUpdateResult

Kind: global typedef
Properties

NameTypeDescription
codenumber标识码 1 为增加 0为减少
streamList[ 'Array' ].<{streamId: string, userId: string, roomId: string}>流列表

kickResult

Kind: global typedef
Properties

NameTypeDescription
userIdstring用户Id
roomIdstring房间Id
reasonnumber错误码