一对一视频通话

LVCEngine JS SDK API 文档

更新时间:2020-06-03

LVCEngine

创建LVCEngine实例

new LVCEngine(userId, imAppId, rtcAppId, appKey, socketUrl, env, appPackageName, type)

ParamTypeDefaultDescription
userIdstring用户的userId
imAppIdstringim appId
rtcAppIdstringrtc appId
appKeystringim appKey
socketUrlstringsocketUrl
socketUrlstringsocketUrl
appPackageNamestring包名
envstring"prod" | "test"SDK环境选择
[type]string"international" | "china"节点环境选择

登录房间

LVCEngine.joinRoom(userId, roomId, role, token, auth, expire) ⇒ Array | errMsg

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

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

登出房间

LVCEngine.logout() ⇒ void

Kind: instance method of LVCEngine
Returns: void

RTC部分

创建流

LVCEngine.createStream([source]) ⇒ mediastream

Kind: instance method of LVCEngine
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码率

删除流

LVCEngine.destroyStream(mediastream)

Kind: instance method of LVCEngine

ParamType
mediastreamMediaStream

开始推流

LVCEngine.startPublishingStream(streamId, mediaElement) ⇒ void

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

ParamTypeDescription
streamIdstring流id
mediaElementMediaStream

停止推流

LVCEngine.stopPublishingStream(streamId)

Kind: instance method of LVCEngine

ParamTypeDescription
streamIdstring流id

开始拉流

LVCEngine.startPlayingStream(streamId) ⇒ void

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

ParamTypeDescription
streamIdstring流id

停止拉流

LVCEngine.stopPlayingStream(streamId)

Kind: instance method of LVCEngine

ParamTypeDescription
streamIdstring流id

开启静音

LVCEngine.muteSwitch(streamId, mute)

Kind: instance method of LVCEngine

ParamTypeDescription
streamIdstring流id
muteboolean是否静音

切换摄像头

LVCEngine.cameraSwitch(streamId, state)

Kind: instance method of LVCEngine

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

流变化通知 event

"stream-update" ⇒ stramUpdateResult

Kind: event emitted by LVCEngine
Since: 2.0

websocket 断开通知 event.

"disconnect" ⇒ errMsg

Kind: event emitted by LVCEngine
Since: 2.0

踢人通知 event.

"kick-out" ⇒ kickResult

Kind: event emitted by LVCEngine
Since: 2.0

推流状态通知 event.

"publish-state-update" ⇒ streamStateResult

Kind: event emitted by LVCEngine
Since: 2.0

拉流状态通知 event.

"play-state-update" ⇒ streamStateResult

Kind: event emitted by LVCEngine
Since: 2.0

自定义类型

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

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错误码

streamStateResult

Kind: global typedef
Properties

NameTypeDescription
codenumber错误码
statestring当前状态
reasonstring原因

直播间部分

LVCEngine.liveroomManager Kind: global class

创建房间

liveroomManager.create(roomId) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID

加入房间

liveroomManager.join(roomId) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID

离开房间

liveroomManager.leave(roomId) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID

用户静音

liveroomManager.mute(roomId, userId) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID
userIdstring用户ID

用户取消静音

liveroomManager.unmute(roomId, userId) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID
userIdstring用户ID

房间静音

liveroomManager.muteAll(roomId) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID

房间取消静音

liveroomManager.unmuteAll(roomId) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID

发送直播间消息

liveroomManager.sendMessage(roomId, content) ⇒ void

Kind: instance method of LiveroomManager
Returns: void - {Promise\<void>}

ParamTypeDescription
roomIdstring房间ID
contentstring消息内容

获取创建直播间消息 event

"create" ⇒ object

Kind: event emitted by LiveroomManager
Returns: object - {{roomId: string, userId: string}}

获取加入直播间消息 event

"join" ⇒ object

Kind: event emitted by LiveroomManager
Returns: object - {{roomId: string, userId: string}}

获取离开直播间消息 event

"leave" ⇒ object

Kind: event emitted by LiveroomManager
Returns: object - {{roomId: string, userId: string}}

获取直播间实时消息 event

"message" ⇒ object

Kind: event emitted by LiveroomManager
Returns: object - {{from: string, to: string, content: string}}

私信部分

LVCEngine.personalManager Kind: global class

发送私信

personalManager.sendMessage(userId, content) ⇒ void

Kind: instance method of PersonalManager
Returns: void - {Promise\<void>}

ParamTypeDescription
userIdstring用户ID
contentstring消息内容

发送接收反馈

personalManager.sendAck(received) ⇒ void

Kind: instance method of PersonalManager
Returns: void - {Promise\<void>}

ParamType
receivedArray.<TextMsgDataWrapper>

获取私信消息 event

"message" ⇒ object

Kind: event emitted by PersonalManager
Returns: object - {{from: string, to: string, content: string}}

获取未读消息列表

pullManager.getUnreadMessageList([sequenceId], [totalSize]) ⇒ object

Kind: instance method of PullManager
Returns: object - {Promise<[type: string, message: string]>}

ParamTypeDefault
[sequenceId]number | Long0
[totalSize]number-1

获取错误消息 event

"error" ⇒ object

Kind: event emitted
Returns: object - {type: number, data: any, error: string}