Event Callback

Callback List

  • ThunderEventHandler

Public Callback FunctionFunction Name
voidonError(int error)
voidonJoinRoomSuccess(String room, String uid, int elapsed)
voidonLeaveRoom(ThunderEventHandler.RoomStats status)
voidonBizAuthResult(boolean bPublish, int result)
voidonSdkAuthResult(int result)
voidonUserBanned(boolean status)
voidonTokenWillExpire(byte[] token)
voidonTokenRequested()
voidonNetworkQuality(String uid, int txQuality, int rxQuality)
voidonRoomStats(ThunderNotification.RoomStats stats)
voidonPlayVolumeIndication(ThunderEventHandler.AudioVolumeInfo[] speakers, int totalVolume)
voidonCaptureVolumeIndication(int totalVolume, int cpt, int micVolume)
voidonConnectionLost()
voidonAudioPlaySpectrumData(byte[] data)
voidonRecvUserAppMsgData(byte[] data, String uid)
voidonSendAppMsgDataFailedStatus(int status)
voidonRemoteAudioStopped(String uid, boolean stop)
voidonRemoteVideoStopped(String uid, boolean stop)
voidonRemoteVideoPlay(String uid, int width, int height, int elapsed)
voidonVideoSizeChanged(String uid, int width, int height, int rotation)
voidonFirstLocalAudioFrameSent(int elapsed)
voidonFirstLocalVideoFrameSent(int elapsed)
voidonPublishStreamToCDNStatus(String url, int errorCode)
voidonNetworkTypeChanged(int type)
voidonConnectionStatus(int status)
voidonAudioCaptureStatus(int status)
voidonVideoCaptureStatus(int status)
voidonLocalVideoStats(ThunderEventHandler.LocalVideoStats stats)
voidonLocalAudioStats(ThunderEventHandler.LocalAudioStats stats)
voidonRemoteVideoStatsOfUid(String uid, ThunderEventHandler.RemoteVideoStats stats)
voidonRemoteAudioStatsOfUid(String uid, ThunderEventHandler.RemoteAudioStats stats)
voidonRemoteAudioPlay(String uid, int elapsed)
voidonLocalVideoStatusChanged(int status, int errorReason)
voidonLocalAudioStatusChanged(int status, int errorReason)
voidonRemoteVideoStateChangedOfUid(String uid, int state, int reason, int elapsed)
voidonRemoteAudioStateChangedOfUid(String uid, int state, int reason, int elapsed)
voidonDeviceStats(ThunderEventHandler.DeviceStats stats)
voidonAudioRouteChanged(int routing)
voidonHowlingDetectResult(boolean bHowling)
voidonEchoDetectResult(boolean bEcho)
  • IAudioFrameObserver

Public Callback FunctionFunction Name
booleanonRecordAudioFrame(ByteBuffer samples, int numOfSamples, int bytesPerSample, int channels, int samplesPerSec)
booleanonPlaybackAudioFrame(ByteBuffer samples, int numOfSamples, int bytesPerSample, int channels, int samplesPerSec)
booleanonPlaybackAudioFrameBeforeMixing(String uid, ByteBuffer samples, int numOfSamples, int bytesPerSample, int channels, int samplesPerSec)
booleanonMixedAudioFrame(ByteBuffer samples, int numOfSamples, int bytesPerSample, int channels, int samplesPerSec, long timeStamp)
  • IGPUProcess

Public Callback FunctionFunction Name
voidonInit(int textureTarget, int outputWidth, int outputHeight)
voidonDestroy()
voidonDraw(final int textureId, final FloatBuffer cubeBuffer,final FloatBuffer textureBuffer, float[] texMatrix)
voidonOutputSizeChanged(final int width, final int height)
  • IVideoCaptureObserver

Public callback functionFunction Name
voidonCaptureVideoFrame(int width, int height, byte[] data, int length, int imageFormat)
  • IVideoDecodeObserver

Public Callback FunctionFunction Name
voidonVideoDecodeFrame(String uid, int w, int h, byte[] data, int dateLen, long renderTimeMs)
  • ThunderCustomVideoSource

Public Callback FunctionFunction Name
booleanonInitialize(ThunderVideoFrameConsumer consumer)
booleanonStart
booleanonStop
booleanonDispose
  • ThunderVideoFrameConsumer

Public Callback FunctionFunction Name
voidconsumeByteArrayFrame(byte[] data, int format, int width, int height, int rotation, long timestamp)
voidconsumeTextureFrame(int textureID, int textureFormat, int width, int height, int rotation, long timeStamp,float[] transform)
  • IThunderLogCallback

Public Callback FunctionFunction Name
voidonThunderLogWithLevel(int level, String tag, String msg)
  • IThunderMediaExtraInfoCallback

Public Callback FunctionFunction Name
voidonSendMediaExtraInfoFailedStatus(int status)
voidonRecvMediaExtraInfo(int status)
voidonRecvMixAudioInfo(int status)
voidonRecvMixVideoInfo(int status)
  • ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback

    Note:

    This callback class is deprecated from V2.7.0, you can call IThunderAudioFilePlayerEventCallback.

Public Callback FunctionFunction Name
voidonAudioFilePlayError(int errorCode)
voidonAudioFileVolume(long volume, long currentMs, long totalMs)
voidonAudioFileSeekComplete(int millisecond)
voidonAudioFilePlaying()
voidonAudioFilePause()
voidonAudioFileResume()
voidonAudioFileStop()
voidonAudioFilePlayEnd()
  • IThunderAudioFilePlayerEventCallback

Public Callback FunctionFunction Name
voidonAudioFileVolume(long volume, long currentMs, long totalMs)
voidonAudioFileStateChange(int event, int errorCode)

Callback Details

ThunderEventHandler

ThunderEventHandler.onError

public void onError(int error)

Report the SDK error message.

Parameter
ParameterDescription
errorError message code

ThunderEventHandler.onJoinRoomSuccess

public void onJoinRoomSuccess(String room, String uid, int elapsed)

Report the user of uid joining room successfully.

After calling ThunderEngine.joinRoom, receiving such a notification indicates that connection with server is normal, and the interface that can only be called after joining room successfully may be called.

Parameter
ParameterDescription
roomRoom No.
uidUser ID
elapsedTime elapsed from the user calling ThunderEngine.joinRoom until this callback is triggered, unit: ms

ThunderEventHandler.onLeaveRoom

public void onLeaveRoom(ThunderEventHandler.RoomStats status)

Called when a user exits a room.

After calling ThunderEngine.leaveRoom, this callback will be received when leaving room normally.

Parameter
ParameterDescription
RoomStatsReserved parameters. See details in ThunderEventHandler.RoomStats

ThunderEventHandler.onBizAuthResult

public void onBizAuthResult(boolean bPublish, int result)

Report business authentication results.

Results of service authentication. Jocloud forwards authentication requests to business authentication server, and returns authentication results to developer through this interface.

Parameter
ParameterDescription
bPublishtrue: publishing authentication
false: playing authentication
resultAuthentication results
0: pass
Other values: fail. Subject to developer customization. SDK simply passes-through

ThunderEventHandler.onSdkAuthResult

public void onSdkAuthResult(int result)

Report SDK authentication results.

Results of SDK authentication. After calling ThunderEngine.joinRoom, once uplink/downlink media data is available, the authentication results of SDK will be reported.

Parameter
ParameterDescription
resultAuthentication results. For detailed meaning of the values, refer to ThunderRtcConstant.AuthResult

ThunderEventHandler.onUserBanned

public void onUserBanned(boolean status)

Notification of user banned.

This callback notification will be received when user banning status changes

Parameter
ParameterDescription
statusBanning status:
true: banned
false: unbanned

ThunderEventHandler.onUserJoined

public void onUserJoined(String uid, int elapsed)

Note:

  • This callback is deprecated from V2.8.0.

Called when a remote user/anchor joining a room (valid for audio-only mode only).

This callback will be triggered in the following circumstances

  • Remote user/anchor calls the ThunderEngine.joinRoom to join room.
  • Remote user/anchor rejoins a room after a network failure.
Parameter
ParameterDescription
uidID of remote user/anchor who joined room recently
elapsedDelay (in millisecond) from local user calling ThunderEngine.joinRoom to triggering callback

ThunderEventHandler.onUserOffline

public void onUserOffline(String uid, int reason)

Note:

  • This callback is deprecated from V2.8.0.

Called when a remote user/anchor exiting a room (valid for audio-only mode only).

It prompts that a remote user/anchor has left the room (or is offline). There are two reasons that user leaves a room, regular leave or timeout.

Parameter
ParameterDescription
uidID of the user or host who exitss the room
reasonThe offline reason, see details in ThunderRtcConstant.UserOfflineReason

ThunderEventHandler.onTokenWillExpire

public void onTokenWillExpire(byte[] token)

Called when the token expires in 30 seconds.

  • Token needs to be specified when calling ThunderEngine.joinRoom. Token has a certain valid period. If token is about to expire during the call, SDK will trigger this callback 30 seconds in advance, reminding App to update token.
  • Upon receiving this callback, user needs to generate a new token at server, and call ThunderEngine.updateToken to send newly generated token to SDK.
Parameter
ParameterDescription
tokenExpiring token

ThunderEventHandler.onTokenRequested

public void onTokenRequested()

Called when the token expires.

  • Token needs to be specified when calling ThunderEngine.joinRoom. Token has a certain valid period. If token expires during the call, this callback notification will be received.
  • Upon receiving this callback, user needs to generate a new token at server, and call ThunderEngine.updateToken to send newly generated token to SDK.

ThunderEventHandler.onNetworkQuality

public void onNetworkQuality(String uid, int txQuality, int rxQuality)

Report the uplink and downlink network quality of each user.

Parameter
ParameterDescription
uidFor each callback, network quality of user corresponding to the uid is reported. If uid is 0, network quality of local user is reported
txQualityNetwork uplink quality, refer to ThunderRtcConstant.NetworkQuality
rxQualityNetwork downlink quality, refer to ThunderRtcConstant.NetworkQuality

ThunderEventHandler.onRoomStats

public void onRoomStats(ThunderNotification.RoomStats stats)

Notification for uplink/downlink traffic (periodic notification sent once every 2 seconds). After joining room ThunderEngine.joinRoom, user will receive this callback.

Parameter
ParameterDescription
statsUpstream and downstream traffic data of the room, see ThunderNotification.RoomStats class for details

ThunderEventHandler.onPlayVolumeIndication

public void onPlayVolumeIndication(ThunderEventHandler.AudioVolumeInfo[] speakers, int totalVolume)

Report which users are speaking and the speakers' volume, and whether the local user is speaking.

Once ThunderEngine.setAudioVolumeIndication is enabled, this callback is triggered at the set interval, regardless of whether a user speaks or not.

Parameter
ParameterDescription
speakersAudio volume information array.
Each speaker includes:
uid: speaker's uid.
volume: speaker's volume.
pts: capture timestamp,
refer to ThunderEventHandler.AudioVolumeInfo for detail
totalVolumeTotal volume after audio mixing, range: [0-100]

ThunderEventHandler.onCaptureVolumeIndication

public void onCaptureVolumeIndication(int totalVolume, int cpt, int micVolume)

Report the cpature volume

This callback will be received after calling ThunderEngine.enableCaptureVolumeIndication is enabled.

Parameter
ParameterDescription
totalVolumeTotal volume of capture (including microphone capture and file playback) [0-100]
cptThe timestamp of microphone capture (ms)
micVolumeThe volume of microphone capture only , range: [0-100]

ThunderEventHandler.onConnectionLost

public void onConnectionLost(){}

Called when the SDK cannot reconnect to Jocloud server 10 seconds after its connection to the server is interrupted.

After calling joinRoom, the SDK triggers this callback when it cannot connect to the server 10 seconds regardless of whether it is in the room or not. Before calling leaveRoom, SDK will be automatically reconnect to the room.


ThunderEventHandler.onAudioPlaySpectrumData

public void onAudioPlaySpectrumData(byte[] data)

Report the audio playback spectrum data.

This callback will be received after calling ThunderEngine.enableAudioPlaySpectrum is enabled.

Parameter
ParameterDescription
DateAudio spectrum data

ThunderEventHandler.onRecvUserAppMsgData

public void onRecvUserAppMsgData(byte[] data, String uid)

Callback when received developer's custom broadcast messages.

Parameter
ParameterDescription
DatePass-through message received
uiduid of user who sends the message

ThunderEventHandler.onSendAppMsgDataFailedStatus

public void onSendAppMsgDataFailedStatus(int status)

Callback when failure in sending deveploper's custom broadcast messages.

Parameter
ParameterDescription
statusFailure status
1: Frequency is too high
2: Data sent is too large
3: Publishing is not started successfully

ThunderEventHandler.onRemoteAudioStopped

public void onRemoteAudioStopped(String uid, boolean stop)

Callback when the remote user's audio stream starts or stops.

After calling ThunderEngine.joinRoom, this callback will be received when there are changes in existing audio streams in the room and subsequent audio stream status.

Parameter
ParameterDescription
uiduid of remote user
Stoptrue: Remote user audio stream has stopped
false: Remote user audio stream has started

ThunderEventHandler.onRemoteVideoStopped

public void onRemoteVideoStopped(String uid, boolean stop)

Callback when the remote user's video stream starts or stops.

After calling ThunderEngine.joinRoom, this callback will be received when there are changes in existing video streams in the room and subsequent video stream status.

Parameter
ParameterDescription
uiduid of remote user
Stoptrue: Remote user video stream has stopped
false: Remote user video stream has started

ThunderEventHandler.onRemoteVideoPlay

public void onRemoteVideoPlay(String uid, int width, int height, int elapsed)

Callback when displaying the first frame of remote video.

After calling ThunderEngine.setRemoteVideoCanvas, this callback will be received when remote video stream is received and the first frame is displayed

Parameter
ParameterDescription
uiduid of remote user
widthRemote video resolution width
heightRemote video resolution height
elapsedTime elapsed (ms) from calling ThunderEngine.joinRoom to calling back the event

ThunderEventHandler.onVideoSizeChanged

public void onVideoSizeChanged(String uid, int width, int height, int rotation)

Callback of remote video (host video) resolution change.

After calling ThunderEngine.joinRoom, this callback will be received when the resolution of local or remote video changes.

Parameter
ParameterDescription
uidUser id. uid is 0 when callback is received by user as an anchor; uid is anchor uid when callback is received by user a viewer
widthRemote video resolution width after change.
heightRemote video resolution height after change.
rotationReserved.

ThunderEventHandler.onFirstLocalAudioFrameSent

public void onFirstLocalAudioFrameSent(int elapsed)

Callback when first local audio frame sent successfully. (As an anchor, this callback is received after the first audio frame is successfully uploaded)

Parameter
ParameterDescription
elapsedTime elapsed (in milliseconds) from local user calling ThunderEngine.joinRoom to triggering this callback

ThunderEventHandler.onFirstLocalVideoFrameSent

public void onFirstLocalVideoFrameSent(int elapsed)

Callback when first local video frame sent successfully. (As an anchor, this callback is received after the first video frame is successfully uploaded)

Parameter
ParameterDescription
elapsedTime elapsed (in milliseconds) from local user calling ThunderEngine.joinRoom to triggering this callback

ThunderEventHandler.onPublishStreamToCDNStatus

public void onPublishStreamToCDNStatus(String url, int errorCode)

Report the result of pushing stream to the CDN. This callback will be triggered when stream pushing status changes.

This callback will be received after user calling ThunderEngine.addPublishOriginStreamUrl or ThunderEngine.addPublishTranscodingStreamUrl to pushing stream.

Parameter
ParameterDescription
urlThe URL to which the stream will be pushed
errorCodeThe status code of stream pushing results, referring to ThunderRtcConstant.ThunderPublishCDNErrorCode

ThunderEventHandler.onNetworkTypeChanged

public void onNetworkTypeChanged(int type)

Callback when the network type changes.

After creating and initializing engine, this callback will be received when network type changes.

Parameter
ParameterDescription
typeNetwork type, referring to ThunderRtcConstant.ThunderNetworkType

ThunderEventHandler.onConnectionStatus

public void onConnectionStatus(int status)

Report the connection status with the server.

After calling ThunderEngine.joinRoom, this callback will be received when network connection status between SDK and server (service and avp) changes.

  • In thunder mode, only connection status with avp will be checked.
  • In thunderbolt mode and without publishing or subscription (not connecting avp), only service connection status will be checked.
  • In thunderbolt mode and with publishing or subscription, service and avp connection status will be checked at the same time.
Parameter
ParameterDescription
statusThe connection status code with server, refer to ThunderRtcConstant.ThunderConnectionStatus

ThunderEventHandler.onAudioCaptureStatus

public void onAudioCaptureStatus(int status)

Callback when the audio device capture status changes.

Start audio capture. This callback will be received in case of changes in audio device capture status.

Parameter
ParameterDescription
statusThe audio device capture status, refer to ThunderRtcConstant.ThunderAudioDeviceStatus

ThunderEventHandler.onVideoCaptureStatus

public void onVideoCaptureStatus(int status)

Callback when the video device capture status changes.

Start camera capture. This callback will be received when there are changes in camera device capture status.

Parameter
ParameterDescription
statusThe video device (camera) capture status, refer to ThunderRtcConstant.ThunderVideoCaptureStatus

ThunderEventHandler.onLocalVideoStats

public void onLocalVideoStats(ThunderEventHandler.LocalVideoStats stats)

Report statistics of local video streams.

This callback describes statistics of video streams sent locally. Callback timing is as follows:

  • Immediate callback when calling the publishing interface
  • Immediate callback on bracket change during publishing
  • Periodic callback at an interval of 2s
Parameter
ParameterDescription
statsThe statistics of local video, refer to ThunderEventHandler.LocalVideoStats

ThunderEventHandler.onLocalAudioStats

public void onLocalAudioStats(ThunderEventHandler.LocalAudioStats stats)

Report the statistics of the local audio stream.

This callback describes statistics of audio streams sent locally. Callback timing: periodic callback at an interval of 2s

Parameter
ParameterDescription
statsThe statistics of local audio , refer to ThunderEventHandler.LocalAudioStats

ThunderEventHandler.onRemoteVideoStatsOfUid

public void onRemoteVideoStatsOfUid(String uid, ThunderEventHandler.RemoteVideoStats stats)

Report status message of remote video stream during the call.

This callback describes end-to-end video streaming status of remote user during the call. For each remote user (anchor), it is triggered once every 2 seconds. In case multiple remote users (anchors) exist at the same time, this callback will be triggered multiple times every 2 seconds

Parameter
ParameterDescription
uidThe uid of remote user (anchor)
statsThe statistics of remote videos , refer to ThunderEventHandler.RemoteVideoStats

ThunderEventHandler.onRemoteAudioStatsOfUid

public void onRemoteAudioStatsOfUid(String uid, ThunderEventHandler.RemoteAudioStats stats)

Report status message of remote audio stream during the call.

This callback describes end-to-end audio streaming status of remote user during the call. For each remote user (anchor), it is triggered once every 2 seconds. In case multiple remote users (anchors) exist at the same time, this callback will be triggered multiple times every 2 seconds

Parameter
ParameterDescription
uidThe uid of remote user (anchor)
statsThe statistics of remote audio, refer to ThunderEventHandler.RemoteAudioStats

ThunderEventHandler.onRemoteAudioPlay

public void onRemoteAudioPlay(String uid, int elapsed)

Callback about first frame of played remote videos.

Parameter
ParameterDescription
uidRemote user ID ( anchor ID)
elapsedPeriod from the the user calls joinRoom to the event occurs, unit: milliseconds

ThunderEventHandler.onLocalVideoStatusChanged

public void onLocalVideoStatusChanged(int status, int errorReason)

Local video status change callback. When the system status of the local video changes, the SDK calls back the current local video status and the cause of the change.

Parameter
ParameterDescription
statusLocal video status, see details in ThunderRtcConstant.LocalVideoStreamStatus
errorReasonCause of local video error, see details in ThunderRtcConstant.LocalVideoStreamErrorReason

ThunderEventHandler.onLocalAudioStatusChanged

public void onLocalAudioStatusChanged(int status, int errorReason)

Local audio status callback. When the system status of the local audio changes, the SDK calls back the current local auido status and the cause of the change.

Parameter
ParameterDescription
statusLocal audio status, see details in ThunderRtcConstant.LocalAudioStreamStatus
errorReasonCause of local audio error, see details in ThunderRtcConstant.LocalAudioStreamErrorReason

ThunderEventHandler.onRemoteVideoStateChangedOfUid

public void onRemoteVideoStateChangedOfUid(String uid, int state, int reason, int elapsed)

Callback about video status change of remote users.

Parameter
ParameterDescription
uidRemote user ID (anchor ID)
stateVideo stream status, see details in ThunderRtcConstant.RemoteVideoState
reasonCause of video stream change, see details in ThunderRtcConstant.RemoteVideoReason
elapsedPeriod from the the user calls joinRoom to the event occurs, unit: milliseconds

ThunderEventHandler.onRemoteAudioStateChangedOfUid

public void onRemoteAudioStateChangedOfUid(String uid, int state, int reason, int elapsed)

Callback about audio status change of remote users.

Parameter
ParameterDescription
uidRemote user ID ( anchor ID)
stateAudio stream status, see details in ThunderRtcConstant.RemoteAudioState
reasonCause of audio stream change, see details in ThunderRtcConstant.RemoteAudioReason
elapsedPeriod from the the user calls joinRoom to the event occurs, unit: milliseconds

ThunderEventHandler.onDeviceStats

public void onDeviceStats(ThunderEventHandler.DeviceStats stats)

CPU or memory usage satus. Called every 2 seconds after joining rooms by calling ThunderEngine.joinRoom .

Parameter
ParameterDescription
statsCPU or memory usage status, see details in ThunderEventHandler.DeviceStats

ThunderEventHandler.onAudioRouteChanged

public void onAudioRouteChanged(int routing)

Called when the audio routing changes.

Parameter
ParameterDescription
routingThe current audio routing, see details in ThunderRtcConstant.ThunderAudioFilePLayerErrorCode

ThunderEventHandler.onHowlingDetectResult

public void onHowlingDetectResult(boolean bHowling)

Callback of howling detection results.

Parameter
ParameterDescription
bHowlingDetection result: "true"-detected, "false"-not detected

ThunderEventHandler.onEchoDetectResult

public void onEchoDetectResult(boolean bEcho)

Callback of echo detection results, which will be called when the echo is detected.

Parameter
ParameterDescription
bEchoDetection result: "true"-detected, "false"-not detected

IAudioFrameObserver

onRecordAudioFrame

boolean onRecordAudioFrame(ByteBuffer samples,
                           int numOfSamples,
                           int bytesPerSample,
                           int channels,
                           int samplesPerSec)

Report the raw audio capture data.

Parameter
ParameterDescription
samplesSample data of this frame
numOfSamplesNumber of samples
bytesPerSampleBytes per sample: For PCM, 16 bits are used in general, that is, two bytes
channelsNumber of channels (crossed data for stereo); 1: single track, 2: dual track
samplesPerSecSampling rate, SamplesPerCall = (int)(SampleRate × sampleInterval); where, sample ≥ 0.01, in seconds
Return value
  • True.

onPlaybackAudioFrame

boolean onPlaybackAudioFrame(ByteBuffer samples,
                             int numOfSamples,
                             int bytesPerSample,
                             int channels,
                             int samplesPerSec)

Report the raw audio play data.

Parameter
ParameterDescription
samplesSample data of this frame
numOfSamplesNumber of samples
bytesPerSampleBytes per sample: For PCM, 16 bits are used in general, that is, two bytes
channelsNumber of channels (crossed data for stereo); 1: single track, 2: dual track
samplesPerSecSampling rate, SamplesPerCall = (int)(SampleRate × sampleInterval); where, sample ≥ 0.01, in seconds
Return value
  • True.

onPlaybackAudioFrameBeforeMixing

boolean onPlaybackAudioFrameBeforeMixing(String uid,
                                         ByteBuffer samples,
                                         int numOfSamples,
                                         int bytesPerSample,
                                         int channels,
                                         int samplesPerSec)

Report the raw decoded audio data of remote user.

Parameter
ParameterDescription
uidRemote user uid
samplesSample data of this frame
numOfSamplesNumber of samples
bytesPerSampleBytes per sample: For PCM, 16 bits are used in general, that is, two bytes
channelsNumber of channels (crossed data for stereo); 1: single track, 2: dual track
samplesPerSecSampling rate, SamplesPerCall = (int)(SampleRate × sampleInterval); where, sample ≥ 0.01, in seconds
Return value
  • True.

onMixedAudioFrame

public boolean onMixedAudioFrame(ByteBuffer samples, int numOfSamples, int bytesPerSample, int channels, int samplesPerSec, long timeStamp);

Callback of the audio data mixed with the captured data and the playback data.

Parameter
ParameterDescription
samplesSamples in the audio frame
numOfSamplesThe number of samples per channel in the audio frame
bytesPerSampleThe number of bytes per audio sample, which is usually 16-bit (2-byte) for PCM
channelsThe number of audio channels; 1-Mono, 2-Stereo (the data is interleaved)
samplesPerSecSample rate, SamplesPerCall = (int)(SampleRate × sampleInterval), sample ≥ 0.01, unit: seconds
timeStampTimestamp

IGPUProcess

IGPUProcess.onInit

void onInit(int textureTarget, int outputWidth, int outputHeight)

Allow developers to use third-party special effects.

Including "Update texture type" and “Use shader in OES texture".

Parameter
ParameterDescription
textureTargetTexture type ( GL_TEXTURE_EXTERNAL_OES / GL_TEXTURE_2D )
outputWidthTexture width
outputHeightTexture height

IGPUProcess.onDestroy

void onDestroy()

Destroying resources of special effects.


IGPUProcess.onDraw

void onDraw(final int textureId,
            final FloatBuffer cubeBuffer,
            final FloatBuffer textureBuffer,
            float[] texMatrix)

Process every frame.

Parameter
ParameterDescription
textureIdTexture ID
cubeBufferVertex coordinates
textureBufferTexture coordinates
texMatrixTexture matrix

IGPUProcess.onOutputSizeChanged

void onOutputSizeChanged(final int width, final int height)

Callback when the texture size update.

Parameter
ParameterDescription
widthUpdated texture width
heightUpdated texture height

IVideoCaptureObserver

IVideoCaptureObserver.onCaptureVideoFrame

void onCaptureVideoFrame(int width, int height, byte[] data, int length, int imageFormat)

Callback original yuv (NV21) data captured by camera to developer.

Parameter
ParameterDescription
widthVideo frame width
heightVideo frame height
DateNV21 data of video frame
lengthVideo frame length
imageFormatVideo image format. For the optional value, refer to class android.graphics.ImageFormat

IVideoDecodeObserver

IVideoDecodeObserver.onVideoDecodeFrame

void onVideoDecodeFrame(String uid, int w, int h, byte[] data, int dateLen, long renderTimeMs)

Callback decoded video data for rendering (I420) to developer

Parameter
ParameterDescription
uiduid of user to whom video frame belongs
wVideo frame width
hVideo frame height
DateI420 data of video frame
dateLenVideo frame length
renderTimeMsCurrent rendering timestamp

ThunderCustomVideoSource

ThunderCustomVideoSource.onInitialize

boolean onInitialize(ThunderVideoFrameConsumer consumer)

Initialize video source.

In this callback function, external video stream is pushed by calling consumer.consumeByteArrayFrame.

Parameter
ParameterDescription
consumerThe interface object for pushing external video stream, refer to ThunderVideoFrameConsumer
Return value
  • True.

ThunderCustomVideoSource.onStart

boolean onStart()

Start video source.

Return value
  • True.

ThunderCustomVideoSource.onStop

boolean onStop()

Stop video source.

Return value
  • True.

ThunderCustomVideoSource.onDispose

boolean onDispose()

Dispose video source.

Return value
  • True.

ThunderVideoFrameConsumer

ThunderVideoFrameConsumer.consumeByteArrayFrame

void consumeByteArrayFrame(byte[] data, int format, int width, int height, int rotation, long timestamp)

Receive video frames of type ByteArray.

Call this function to transmit video frame of type ByteArray to SDK, and SDK will push this video frame out.

Parameter
ParameterDescription
DateByte Array type of video data
formatPixel format. For optional values, refer to ThunderRtcConstant.ExternalVideoPixelFormat
widthVideo frame width
heightVideo frame height
rotationClockwise rotation angle for video frame. If rotation angle is defined, media engine will rotate image.
You may set angle value to 0, 90, 180 or 270 degrees as needed. If it is set to other values, the system will automatically ignore
timestampTimestamp of incoming video frame. Developer must set a timestamp for each video frame

ThunderVideoFrameConsumer.consumeTextureFrame

consumeTextureFrame(int textureID, int textureFormat, int width, int height, int rotation, long timeStamp,float[] transform)

Push video frames in texture to SDK.

Parameter
ParameterDescription
textureIDTexture ID
textureFormatPixel format of the video frame: GLES20.GL_TEXTURE_2D or GLES11Ext.GL_TEXTURE_EXTERNAL_OES
widthTexture width
heightTexture height
rotationClockwise rotating angle
timestampTimestamp of the video frame (ms), incorrect timestamp may cause unsynchronized audio and vide
transformA 4×4 matrix of the texture, a unit matrix is recommended

IThunderLogCallback

IThunderLogCallback.onThunderLogWithLevel

void onThunderLogWithLevel(int level, String tag, String msg)

Report the log information.

After setting this callback, log messages will be called back through this interface.

Parameter
ParameterDescription
levelLog level, refer to ThunderRtcConstant.ThunderLogLevel
tagLog tag
msgLog content

IThunderMediaExtraInfoCallback

IThunderMediaExtraInfoCallback.onSendMediaExtraInfoFailedStatus

void onSendMediaExtraInfoFailedStatus(int status)

Callback when failure in sending media extra information.

Parameter
ParameterDescription
statusFailure error code, refer to ThunderRtcConstant.ThunderSendMediaExtraInfoFailedStatus

IThunderMediaExtraInfoCallback.onRecvMediaExtraInfo

void onRecvMediaExtraInfo(java.lang.String uid,
                          java.nio.ByteBuffer data,
                          int dataLen)

Callback when received media extra information.

Parameter
ParameterDescription
uidAnchor uid
DateReceived media extra information
dataLenLength of media extra information

IThunderMediaExtraInfoCallback.onRecvMixAudioInfo

void onRecvMixAudioInfo(java.lang.String uid, ArrayList<ThunderEventHandler.MixAudioInfo> infos)

Callback when received extra information of mixed audio stream.

Parameter
ParameterDescription
uidMixed audio stream uid
infosRaw stream data of mixed audio stream, identifying which streams contribute to this mixed audio stream, refer to ThunderEventHandler.MixAudioInfo

IThunderMediaExtraInfoCallback.onRecvMixVideoInfo

void onRecvMixVideoInfo(java.lang.String uid, ArrayList<ThunderEventHandler.MixVideoInfo> infos)

Callback when received extra information of mixed video stream.

Parameter
ParameterDescription
uidMixed video stream uid
infosRaw stream data of mixed video stream, identifying which streams contribute to this mixed video stream and stream, refer to ThunderEventHandler.MixVideoInfo

ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback

ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFilePlayError

Cuation:

void onAudioFilePlayError(int errorCode)

Callback when audio file playing occur error

Parameter
ParameterDescription
errorCodeAudio file playback error codes

Meaning of error codes:

Error codeMeaning
0File opened successfully
-1Error parsing file format
-2Error decoding file format
-3File format is not supported
-4File path not in existence

ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFileVolume

Note:

  • This callback is deprecated from V2.8.0, and it is recommended to call IThunderAudioFilePlayerEventCallback.onAudioFileVolume
void onAudioFileVolume(long volume, long currentMs, long totalMs)

Report the volume of the playing audio file.

Parameter
ParameterDescription
volumeVolume value [0-100]
currentMsplay progress (in milliseconds)
totalMsTotal file length (in milliseconds)

ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFileSeekComplete

Note:

void onAudioFileSeekComplete(int millisecond)

Callback when the audio file seeking is completed.

Parameter
ParameterDescription
millisecondActual fast forward progress

ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFilePlaying

Note:

void onAudioFilePlaying()

Callback when start playback.


ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFilePause

Note:

void onAudioFilePause()

Callback when pause playback.


ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFileResume

Note:

void onAudioFileResume()

Callback when resume playback.


ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFileStop

Note:

void onAudioFileStop()

Callback when playback being stopped by user.


ThunderAudioFilePlayer.IThunderAudioFilePlayerCallback.onAudioFilePlayEnd

Note:

void onAudioFilePlayEnd()

Callback when end playback.


IThunderAudioFilePlayerEventCallback

IThunderAudioFilePlayerEventCallback.onAudioFileVolume

public void onAudioFileVolume(long volume, long currentMs, long totalMs)

Playback volume callback1.

Parameter
ParameterDescription
volumeVolume, range: [0-100]
currentMsPlayback prpgress, unit: millisecond
totalMsFile size, unit: millisecond

IThunderAudioFilePlayerEventCallback.onAudioFileStateChange

public void onAudioFileStateChange(int event, int errorCode)

Player status callback.

Parameter
ParameterDescription
eventPlayback status, see details in ThunderRtcConstant.ThunderAudioFilePlayerEvent
errorCodeError code of playback status, see details in ThunderRtcConstant.ThunderAudioFilePLayerErrorCode

Parameter

ThunderEventHandler

ThunderEventHandler.AudioVolumeInfo

Speaker volume information class

public static class AudioVolumeInfo {
        public String uid;//Speaker uid
        public int volume;//Speaker volume
        public int pts;//Capture timestamp
}

ThunderEventHandler.MixAudioInfo

Audio stream information for audio mixing.

public static class MixAudioInfo {
        public String uid;//User uid to which the audio stream belongs
        public int volume;//Volume value of audio stream [0,100]
    }

ThunderEventHandler.MixVideoInfo

Video stream information for video mixing (including video stream layout)

public static class MixVideoInfo {
        public String uid;   //User id
        public int width;    //Original width of this user's video
        public int height;   //Original height of this user's video
        public int cropX;    //X coordinate of the begin point used to crop the original video in video mixing
        public int cropY;    //Y coordinate of the begin point used to crop the original video in video mixing
        public int cropW;    //Width of the original video to be cropped in video mixing
        public int cropH;    //Height of the original video to be cropped in video mixing
        public int layoutX;  //X coordinate of the begin point of this user's video in video mixing canvas
        public int layoutY;  //Y coordinate of the begin point of this user's video in video mixing canvas
        public int layoutW;  //Width of this user's video in video mixing canvas
        public int layoutH;  //Height of this user's video in video mixing canvas
        public int zOrder;   //Layer number of this user's video frame in video mixing. The value range is the integer in [0, 100], and the minimum value is 0, indicating that the image in this region is at the lowest level
        public float alpha;  //Transparency of this user's video frame in video mixing. The value range is [0.0, 1.0]. 0.0 indicates that the image in this region is completely transparent, while 1.0 indicates completely opaque.
    }

ThunderEventHandler.LocalVideoStats

Local video statistics class

public static class LocalVideoStats {
        public  int sentBitrate;            // Actual sending bit rate (unit: Kbps), with the exception of sending bit rate of reloaded videos after packet loss
        public  int sentFrameRate;          // Actual sending frame rate (unit: fps), with the exception of sending frame rate of reloaded videos after packet loss
        public  int renderOutputFrameRate;  // Output frame rate of local preview (unit: fps)
        public  int targetBitRate;          // Target encoding bit rate of current encoder (unit: Kbps). This bit rate is a value estimated by this SDK in accordance with current network status.
        public  int targetFrameRate;        // Target encoding frame rate of current coder (unit: fps)
        public  int qualityAdaptIndication; // Quality adaptability of local videos since last statistics (based on target frame rate and target bit rate), see ThunderRtcConstant.ThunderVideoQualityAdapt for detailed definition
        public  int encoderOutputFrameRate; // Output frame rate of local encoder (unit: fps)
        public  int encodedBitrate;         // Bit rate of video encoding (Kbps). This parameter includes no encoding bit rate of reloaded videos after packet loss.
        public  int encodedFrameWidth;      // Encoded video width (px)
        public  int encodedFrameHeight;     // Encoded video height (px)
        public  int encodedFrameCount;      // Number of frames sent by video, an accumulated value
		public  int encodedType;            // Encoding mode, see details in ThunderRtcConstant.ThunderVideoEncodedType
        public  int codecType;              // Encoding type, see ThunderRtcConstant.ThunderVideoCodecType for detailed definition
        public  int configBitRate;          // Bit rate configured in the background, kbps
        public  int configFrameRate;        // Frame rate configured in the background
        public  int configWidth;            // Video width configured in the background
        public  int configHeight;           // Video height configured in the background
}

ThunderEventHandler.LocalAudioStats

Local audio statistics class

public static class LocalAudioStats {
        public int encodedBitrate; // Code rate, unit: Kbps
        public int numChannels;    // Number of channels
        public int sendSampleRate; // Sampling rate sent (unit: Hz)
        public int sendBitrate;    // Average value of bit rate of sent data (unit: Kbps)
		public int enableVad;      // Whether to enbale VAD for sending audio streams: 0-disable, 1-enable
}

ThunderEventHandler.RemoteVideoStats

Remote video statistics class

public static class RemoteVideoStats {
        public int delay; // Captured play delay
        public int width;  // Width of remote video stream
        public int height;  // Height of remote video stream
        public int receivedBitrate;  // Receiving bit rate (unit: Kbps)
        public int decoderOutputFrameRate;  // Output frame rate of remote video decoder (unit: fps)
        public int rendererOutputFrameRate; // Output frame rate of remote video renderer (unit: fps)
        public int packetLossRate; // Packet loss rate (%) of remote video after network confrontation
        public int rxStreamType; // Types of video stream, including large stream and small stream
        public int totalFrozenTime; // The accumulated time (ms) from the time when a remote user joins a channel to the time of video freezing
        public int frozenRate; // The percentage (%) of the accumulated time (from the time when a remote user joins a channel to the time of video freezing) accounting for total effective time of videos
}

ThunderEventHandler.RemoteAudioStats

Remote audio statistics class

public static class RemoteAudioStats {
        public int quality;  //Quality of audio streams sent by remote users.
                             //0: Unknown;
                             //1: Excellent;
                             //2: Good;
                             //3: Poor, flawed but does not affect communication;
                             //4: Bad, communication can be made but not smoothly;
                             //5: Very Bad, communication can barely be made;
                             //6: Disconnected, communication can not be made at all
        public int networkTransportDelay;  // Network delay from an audio sending end to an audio receiving end, unit: millisecond
        public int jitterBufferDelay;  // Delay from a receiving end to network jitter buffer, unit: millisecond
		public int totalDelay; // Total delay from capturing the host audio to audience playing the audio, unit: millisecond
        public int frameLossRate;  // Frame loss rate (%) of remote audio streams
        public int numChannels;  // Number of channels
        public int receivedSampleRate; // Sampling rate (Hz) of remote audios
        public int receivedBitrate; // Average bit rate of remote audios within a statistical period
        public int totalFrozenTime; // The accumulated time (ms) from the time when a remote user joins a channel to the time of audio freezing; during one statistical period, an audio frame loss rate of 4% is recorded as a single freeze
                                    // totalFrozenTime = number of times of audio freezing * 2 * 1000 (ms)
        public int frozenRate; // The percentage (%) of the accumulated time (from the time when a remote user joins a channel to the time of audio freezing) accounting for total effective time of audios
}

ThunderNotification.RoomStats

Uplink/downlink traffic data in the room class

public static class RoomStats {
        public int totalDuration; // Total call duration, unit: second
        public int txBitrate; //Chain sending bit rate (unit: bps)
        public int rxBitrate; //Chain receiving bit rate (unit: bps)
		public int txBytes; // Total sent bytes
        public int rxBytes; // Total received bytes
        public int txAudioBytes; // Total sent audio bytes
        public int rxAudioBytes; // Total received audio bytes
        public int txVideoBytes; // Total sent video bytes
        public int rxVideoBytes; // Total received video bytes
        public int txAudioBitrate;  //Audio packet sending bit rate (unit: bps)
        public int rxAudioBitrate;  //Audio packet receiving bit rate (unit: bps)
        public int txVideoBitrate;  //Video packet sending bit rate (unit: bps)
        public int rxVideoBitrate;  //Video packet receiving bit rate (unit: bps)
		public int lastmileDelay;  // Local client-to-edge server delay (unit: milliseconds)
}

ThunderEventHandler.DeviceStats

CPU/memory usage status

public static class DeviceStats {
        public double cpuTotalUsage; // Current system CPU usage (%)
        public double cpuAppUsage; // CPU usage of the current application (%)
        public double memoryAppUsage; // Memory usage of the current application (%)
        public double memoryTotalUsage; // Current system memory usage (%)
    }

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top