Callback interfaces

更新时间:
复制 MD 格式

This topic describes the callback interfaces for the web audio and video call API.

OnMediaCallSucc(sid)

The audio and video initialization is complete.

OnMediaCallFail(err_code, err_msg)

Failed to initialize audio and video.

Parameters:

Callback parameter

Type

Description

err_code

int

Returned when the audio and video call fails to initialize:

  • 5101: Failed to start the video.

  • 5102: Failed to start the audio.

  • 5103: The browser is not supported.

  • 5104: The channel state is incorrect.

  • 5105: Failed to start screen sharing.

  • 5106: Failed to get the file stream for publishing.

  • 5107: The file to be published does not exist.

  • 5108: The publishing area does not exist.

  • 5109: The background blur image is not provided.

  • 5110: The custom stream is not provided.

  • 5111: The custom resolution, frame rate, or bitrate parameters are not provided.

err_msg

String

The status message.

OnInviteRequest(roomId, rtoken, inviter, extra)

The invitee receives an invitation message titled "Join Channel".

Parameters:

Callback parameter

Type

Description

roomId

String

The channel ID.

rtoken

String

The channel token.

inviter

String

The UID of the inviter.

extra

String

The pass-through field for business data.

OnInviteReply(invitee, reply)

The inviter receives a reply to the channel invitation.

Parameters:

Callback parameter

Type

Description

invitee

String

The UID of the invitee.

reply

int

  • 0: Accept

  • 1: Offline

  • 2: Reject

OnRoomAttendanceList(participants)

Pushes the channel participant list to a new participant.

Parameters:

Callback parameter

Type

Value

Value type

Description

participants

jsonarray

uid

String

The UID of the channel participant.

userType

int

The user type of the participant:

  • 0: Regular user

  • 101: RTCVOD video-on-demand server

publish

jsonarray

The published stream.

feedId

String

The ID of the stream published by the channel participant.

tag

String

The tag that corresponds to the feedId.

OnNewJoinerIn(participant)

Push a notification about the new channel member to the participants.

Parameters:

Callback parameter

Type

Description

participant

String

The UID of the new joiner.

OnNewPublish(feed)

Notify the attendees that a new publication is available.

Parameters:

Callback parameter

Type

Description

feed

JSON

Information about the new published stream:

  • uid: The user who owns the stream.

  • feedId: The published stream.

  • tag: The tag.

  • mediaSource: The media source.

OnNewSubscribe(subscriber,feed)

Pushes a 'new subscription' message to participants.

Parameters:

Callback parameter

Type

Description

subscriber

String

The ID of the new subscriber.

feed

JSON

Information about the new subscribed stream:

  • uid: The ID of the user who owns the stream.

  • feedId: The ID of the subscribed stream.

OnUnSubscribe(unsubscriber,feed)

You can send "unsubscribe" to attendees.

Parameters:

Callback parameter

Type

Description

unsubscriber

String

Unsubscriber ID

feed

JSON

Information about the unsubscribed stream:

  • uid: The ID of the user who owns the stream.

  • feedId: The ID of the subscribed stream.

OnMediaClose(code, sid)

Audio and video shutdown notifications.

Parameters:

Callback parameter

Type

Description

code

int

Normal states:

  • 5001: The stream is closed because a user unsubscribed from or unpublished the stream.

  • 5002: The stream is closed because the remote user left the channel.

  • 5006: The stream is closed because the remote user unpublished the stream.

  • 5008: The stream is closed because the user left the channel.

Abnormal states:

  • 5003: Failed to start the stream during the signaling phase.

  • 5004: The stream connection timed out.

  • 5005: The stream is connected, but the channel state is abnormal.

  • 5007: The media link is closed.

  • 5009: The media server sent a close instruction through the signaling channel.

  • 5010: The media link disconnection timed out.

  • 5011: The media link failed to connect.

  • 5012: Failed to initialize the media source for publishing.

sid

int

The stream ID.

OnReceiveTextMsg(uid, msg)

Send a text message.

Parameters:

Callback parameter

Type

Description

uid

String

The sender of the text message.

msg

String

The text of the message.

OnParticipantLeaveRoom(participant, exitType)

A callback that notifies the remaining participants when another participant leaves the channel.

Parameters:

Callback parameter

Type

Description

participant

String

The ID of the participant who left.

exitType

int

The exit type:

  • 1: Normal exit

  • 2: Abnormal exit

OnNetworkWeak(bpsSend, bpsRecv, sid)

A callback for a weak network connection.

Parameters:

Callback parameter

Type

Description

bpsSend

String

The data sent per second, in bits.

bpsRecv

String

The data received per second, in bits.

sid

int

The stream ID. This helps identify which stream has a weak network connection.

OnVodOver(vod_id)

Notification of audio-on-demand completion.

Parameters:

Callback parameter

Type

Description

vod_id

String

The video-on-demand ID.

OnVolumeAnalyser(sid, analyser)

A callback for real-time volume data.

Parameters:

Callback parameter

Type

Description

sid

String

The stream ID.

analyser

AnalyserNode

Returns an AnalyserNode object.

OnClientRecordBlob(clientRecordId, blob)

Browser recording pushes data as BLOBs.

Parameters:

Callback parameter

Type

Description

clientRecordId

String

The browser recording ID.

blob

Blob

Saves the data as a multimedia file using a BLOB object.

OnRemoteRecordOver(record_id)

A callback for when the server-side recording ends.

Parameters:

Callback parameter

Type

Description

record_id

String

The recording ID.

OnRemoteRecordingFailed(recordId, feedId, code, msg)

A callback for when the server-side recording fails.

Parameters:

Callback parameter

Type

Description

recordId

String

The recording ID.

feedId

String

The ID of the stream related to the event.

code

int

Returned when the server-side recording fails:

  • -12481: The eventCode value is 1.

  • -12482: The eventCode value is 2.

msg

String

The status message.

OnReceiveData

Accepts channel data.

Parameters:

Callback parameter

Type

Description

data

String

The information received by the callback parameter.

StreamFilterHandler

A handler that processes a stream based on custom business logic.

Note

The StreamFilterHandler must be an asynchronous function or return a Promise object. The SDK uses then() to handle the processed stream.

Parameters:

Callback parameter

Type

Description

publish_tag

String

The custom tag content.

stream

MediaStream

The stream to be processed.

stream_type

String

The publishing type: publish (publish a stream) or subscribe (subscribe to a stream).

publish_device

int

This parameter is used only when stream_type is set to publish. For more information, see InitRoomConfig.

media_type

String

The information received by the callback parameter.

OnDesktopDisplayClosed

A callback for when screen sharing stops.

Callback parameters: None.

OnFileStreamClosed

The shared file is closed in the OnFileStreamClosed callback.

Callback parameters: None.

OnParticipantEvent

A callback for an event sent by a remote user.

Parameters:

Callback parameter

Type

Description

uid

String

The remote user.

eventType

int

The event type.

eventDescription

String

The event description.

eventExtra

Object

The event data (optional).