跳转至
400-881-9892

文档中心

官方文档,可查阅产品介绍、快速入门、用户指南、开发指南、API参考、SDK参考、帮助等信息。

文档中心 互动课堂

TKRoomManagerObserver Interface

TKRoomManagerObserver

TKRoomManagerObserver is the main signaling callback of TKRoomSDK regarding rooms.

onRoomJoined
  • A brief description - The callback for successfully entering a room. When calling the joinRoom or [joinRoomEx][] interface to enter a room, this callback will be triggered upon success. If it fails, this callback will not be triggered.

  • Callback Name

- (void)onRoomJoined()

onRoomLeaved
  • A brief description - The callback for leaving a room. This callback will be triggered when calling the leaveRoom interface to leave a room.

  • Callback Name

- (void)onRoomLeaved()

onConnectionLost
  • A brief description - Disconnect callback

  • Callback Name

- (void)onConnectionLost()

onError
  • A brief description - The callback for all SDK errors(errorCode N)

  • Callback Name

- (void)onError(int errorCode, String errMsg)

  • Parameters
Parameter Name Type Description
errorCode int error code
errMsg String error message
onWarning
  • A brief description - The callback for SDK warnings

  • Callback Name

- (void)onWarning(int code)

  • Parameters
Parameter Name Type Description
code int warning code
onUserJoined
  • A brief description - The callback when a user enters the room

  • Callback Name

- (void)onUserJoined(RoomUser user, boolean inList)

  • Parameters
Parameter Name Type Description
peerID RoomUser user information
inList boolean true: Indicates that the user entered the room before me. false: Indicates that the user entered the room after me.
onUserLeft
  • A brief description - The callback when a user leaves the room

  • Callback Name

- (void)onUserLeft(RoomUser user)

  • Parameters
Parameter Name Type Description
user RoomUser user information
onKickout
  • A brief description - The callback when I am kicked out of the room

  • Callback Name

- (void)onKickout(JSONObject message)

  • Parameters
Parameter Name Type Description
message JSONObject detailed information of being kicked
onUserPropertyChanged
  • A brief description - The callback when a user’s attributes change

  • Callback Name

- (void)onUserPropertyChanged(RoomUser user, Map<String, Object> changedProperties, String fromId)

  • Parameters
Parameter Name Type Description
user RoomUser user information
changedProperties Map the changed user attributes
fromId String the user ID of the user who modified the attributes
onUserVideoStatus
  • A brief description - Single-stream mode: The callback when a user’s video status changes. Multi-stream mode: The callback when the video status of a specific video device of a user changes. The default mode is single-stream. Mobile devices do not support enabling multi-stream mode, meaning they cannot publish multiple video streams, but they can receive multiple video streams

  • Callback Name

1
2
 - (void)onUserVideoStatus(String peerID, int state)
 - (void)onUserVideoStatus(String peerID, int state, String cameraId)
  • Parameters
Parameter Name Type Description
peerID String User ID
cameraId String camera device ID. This parameter is valid if the user has multiple cameras and has enabled multi-stream mode
state int video status (0 for stopped publishing, 1 for publishing)
onUserAudioStatus
  • A brief description - The callback when a user’s audio status changes

  • Callback Name

- (void)onUserAudioStatus(String peerID, int state)

  • Parameters
Parameter Name Type Description
peerID String User ID
state int Audio status (0 for stopped publishing, 1 for publishing)
onRemotePubMsg
  • A brief description - When a user sends a publish signaling message (pubMsg), if I am the recipient of this signaling, I will receive the callback for the custom signaling published by the user

  • Callback Name

- (void)onRemotePubMsg(String msgID, String msgName, long ts, Object data, boolean inList, String fromId, String associatedMsgId, String associatedUserId);

  • Parameters
Parameter Name Type Description
msgID String signaling ID
msgName String signaling name
data Object signaling content
fromID String the sender ID of this signaling
associatedMsgId String the ID of the associated message (this message will be deleted when the associated message is deleted)
associatedUserId String the ID of the associated user (this message will be deleted when the associated user exits)
inlist boolean true: Indicates that the signaling was published before I entered the room. false: Indicates that the signaling was published after I entered the room.
ts long timestamp
onRemoteDelMsg
  • A brief description - When a user sends a delete signaling message (delMsg), if I am the recipient of this signaling, I will receive the callback for the custom signaling sent by the user

  • Callback Name

- (void)onRemoteDelMsg(String msgID, String msgName, long ts, Object data, boolean inList, String fromId, String associatedMsgId, String associatedUserId);

  • Parameters
Parameter Name Type Description
msgID String signaling ID
msgName String signaling name
data Object signaling content
fromID String the sender ID of this signaling
associatedMsgId String the ID of the associated message (this message will be deleted when the associated message is deleted)
associatedUserId the ID of the associated user (this message will be deleted when the associated user exits)
inlist boolean true: Indicates that the signaling was published before I entered the room. false: Indicates that the signaling was published after I entered the room.
ts long timestamp
onRoomServerRecordStateChange
  • A brief description - The callback for the recording status during playback. You can start server recording by calling the startServerRecord interface

  • Callback Name

- (void)onRoomServerRecordStateChange(TK_RECORD_STATE state, String userId, HashMap<String, Object> params)

  • Parameters
Parameter Name Type Description
state TK_RECORD_STATE status value
userId String sender ID
params Map if the parameter state is equal to TK_RecordState_Started (indicating the recording has started), the extension dictionary returns the regular recording piece ID and the mp4 recording piece ID for this recording session; params is nulll
onVideoStatsReport
  • A brief description - The callback for video data statistics, occurring once every 10 seconds

  • Callback Name

- (void)onVideoStatsReport(String peerId, TkVideoStatsReport statsReport)

  • Parameters
Parameter Name Type Description
peerId String user ID, indicating that the video data belongs to this user
statsReport TkVideoStatsReport video status data object
onAudioStatsReport
  • A brief description - The callback for audio data statistics, occurring once every 10 seconds

  • Callback Name

- (void)onAudioStatsReport(String peerId, TkAudioStatsReport statsReport)

  • Parameters
Parameter Name Type Description
peerId String user ID, indicating that the audio data belongs to this user
statsReport TkAudioStatsReport audio data object
onRtcStatsReport
  • A brief description - The callback for uplink and downlink audio and video data statistics, occurring once every 10 seconds

  • Callback Name

- (void)onRtcStatsReport(RtcStats rtcStats)

  • Parameters
Parameter Name Type Description
rtcStats RtcStats Audio and video data object
onAudioVolume
  • A brief description - The callback for changes in the volume of a user’s audio

  • Callback Name

- (void)onAudioVolume(String peerId, int volume)

  • Parameters
Parameter Name Type Description
peeID String User ID
volume int volume level
onAudioRoomSwitch
  • A brief description - The callback for changes in room mode, such as switching between audio-only and audio-video rooms

  • Callback Name

- (void)onAudioRoomSwitch(String fromId, boolean isSwitch)

  • Parameters
Parameter Name Type Description
fromId String the user ID of the person who switched the room mode, i.e., the signaling sender ID
isSwitch boolean true: Indicates an audio-only room. false: Indicates an audio-video room.
onFirstVideoFrame
  • A brief description - When playing a user’s video and rendering the first frame, a callback will be received. If a user’s video has not been unplayed and is played again, this callback will not be triggered again

single-stream mode: Callback when playing a user’s video and rendering the first frame.

multi-stream mode: Callback when playing a specific device’s video of a user and rendering the first frame.

default mode: Single-stream. Mobile devices do not support enabling multi-stream mode, meaning they cannot publish multiple video streams, but they can receive multiple video streams.

  • Callback Name
1
2
- (void)onFirstVideoFrame(String peerId, int mediaType, int width, int height)
- (void)onFirstVideoFrame(String peerId, int mediaType, int width, int height, String cameraId)
  • Parameters
Parameter Name Type Description
peerID String User ID
cameraId String camera device ID. This parameter is valid if the user has multiple cameras and has enabled multi-stream mode
width int video width
height int video height
mediaType int type
onVideoStateChange
  • A brief description - The callback for changes in video status during the playback of a user’s video

  • Callback Name

- (void)onVideoStateChange(String peerId, String deviceId, TK_VIDEO_STATE state)

  • Parameters
Parameter Name Type Description
peerID String User ID
deviceId NSString camera device ID,This parameter is null in single-stream mode and is valid in multi-stream mode
state TK_VIDEO_STATE status
onAudioStateChange
  • A brief description - The callback for changes in audio status during the playback of a user’s audio

  • Callback Name

- (void)onAudioStateChange(String peerId, TK_AUDIO_STATE state)

  • Parameters
Parameter Name Type Description
peerID String User ID
state TK_AUDIO_STATE status
onFirstAudioFrame
  • A brief description - The callback for receiving the first frame of audio data when playing a user’s audio and video. If a user’s audio has not been unplayed and is played again, this callback will not be triggered again.

  • Callback Name

- (void)onFirstAudioFrame(String peerId, int mediaType)

  • Parameters
Parameter Name Type Description
peerID String User ID
type int type
onShareMediaState
  • A brief description - The callback for changes in the status of a media stream when a user shares it. You can play this media stream by calling the playMediaFile interface

  • Callback Name

- (void)onShareMediaState(String peerId, int state, Map<String, Object> attrs)

  • Parameters
Parameter Name Type Description
peerID String User ID
state int status
attrs Map extended information
onUpdateAttributeStream
  • A brief description - The callback for updates to media stream information when a user shares a media stream. Note: Currently, only the initiator of the media stream will receive this callback

  • Callback Name

- (void)onUpdateAttributeStream(String peerId, long pos, boolean isPlay, HashMap<String, Object> attrMap);

  • Parameters
Parameter Name Type Description
peerId String User ID
pos int current progress
isPlay boolean whether it is in the playing state
onShareScreenState
  • A brief description - The callback for changes in status when a user shares their desktop. You can play the desktop sharing stream by calling the playScreen interface

  • Callback Name

- (void)onShareScreenState(String peerId, int state, Map<String, Object> attrs);

  • Parameters
Parameter Name Type Description
peerId String User ID
state int media sharing status: 0 for stopped  1 for started
onShareFileState
  • A brief description - The callback for changes in status when a user shares a movie file. You can play the movie file sharing stream by calling the playFile interface

  • Callback Name

- (void)onShareFileState(String peerId, int state, Map<String, Object> attrs);

  • Parameters
Parameter Name Type Description
peerId String User ID
state int media sharing status: 0 for stopped  1 for started

TKMediaFrameObserver

TKMediaFrameObserver is the delegate callback for local media data collection and remote media data. Note: These callback functions are not thread-safe.

Media typecorresponding value
1
2
3
4
5
6
7
    int TK_MEDIA_UNKNOW = -1;
    int TK_MEDIA_CAMERA = 0;
    int TK_MEDIA_MIC = 11;
    int TK_MEDIA_SPEAKER = 12;
    int TK_MEDIA_FILE = 101;
    int TK_MEDIA_SCREEN = 102;
    int TK_MEDIA_MEDIA = 103;
onCaptureVideoFrame
  • A brief description - The callback for locally collected video data

  • Callback Name

- (void)onCaptureVideoFrame(VideoFrame videoFrame, String peerId);

  • Parameters
Parameter Name Type Description
frame VideoFrame video data
peerId String User ID
onCaptureAudioFrame
  • A brief description - The callback for locally collected audio data

  • Callback Name

- (void)onCaptureAudioFrame(TKAudioFrame audioFrame, String uid, int type);

  • Parameters
Parameter Name Type Description
frame TKAudioFrame audio data
type int media type
peerId String User ID
onRenderAudioFrame
  • A brief description - The callback for receiving remote audio data

  • Callback Name

- (void)onRenderAudioFrame(TKAudioFrame audioFrame, String peerId, int type);

  • Parameters
Parameter Name Type Description
frame TKAudioFrame audio data
type int media type
peerId String User ID
onRenderVideoFrame
  • A brief description - The callback for receiving video data from a remote user or receiving video data from a specific video device of a remote user

  • Callback Name

- (void)onRenderVideoFrame(VideoFrame videoFrame, String uid, int type);

or

- (void)onRenderVideoFrame(VideoFrame videoFrame, String uid, int type, String cameraId);

  • Parameters
Parameter Name Type Description
frame TKAudioFrame audio data
type int media type
peerId String User ID
cameraId String device ID