Skip to main content
AOQ SDK Reference

Android SDK

AOQ Android SDK API reference

The AOQ Client SDK for Android provides a full set of real-time audio/video communication capabilities, including engine lifecycle management, audio/video capture and playback, codec configuration, external audio stream injection, audio file mixing, real-time messaging, and audio/video frame callbacks. This document is the complete Java API reference for the Android platform.

API index

Engine lifecycle

APIDescription
createEngineCreate the engine instance (singleton)
destroyDestroy the engine instance
getVersionGet the SDK version string
connectConnect to the Relay server
disconnectDisconnect from the server

Audio device management

APIDescription
startAudioCaptureOpen the audio capture device (microphone)
stopAudioCaptureClose the audio capture device
muteAudioCaptureMute or unmute audio capture
startAudioPlayerStart audio playback (play remote audio)
stopAudioPlayerStop audio playback
pauseAudioPlayerPause audio playback with optional fade-out
resumeAudioPlayerResume audio playback with optional fade-in
interruptAudioPlayerInterrupt the current audio call turn
enableSpeakerphoneSwitch audio output between speaker and earpiece
isSpeakerphoneEnabledQuery whether the speaker is currently active

Audio codec configuration

APIDescription
setAudioEncoderConfigSet audio encoding parameters
setAudioDecoderConfigSet audio decoding parameters

Video device management

APIDescription
startVideoCaptureOpen the video capture device (camera)
stopVideoCaptureClose the video capture device
switchCameraSwitch between front and rear cameras
setLocalViewSet or remove the local video rendering view
setRemoteViewSet or remove the remote video rendering view

Video encoding and external input

APIDescription
setVideoEncoderConfigSet video encoding parameters
pushExternalVideoCapturedFramePush an externally captured raw video frame
pushExternalVideoEncodedFramePush an externally encoded video frame

Media stream control / real-time messaging

APIDescription
enableSendMediaStreamEnable or disable local media stream sending
sendDataMsgSend a real-time data message

Audio file playback

APIDescription
startAudioFileStart streaming a local audio file
stopAudioFileStop audio file playback
pauseAudioFilePause audio file playback
resumeAudioFileResume audio file playback
getAudioFileDurationGet the total duration of the audio file
getAudioFileCurrentPositionGet the current playback position
setAudioFilePositionMillisSeek to a position in the audio file
setAudioFileVolumeSet the audio file volume
getAudioFileVolumeGet the current audio file volume

External audio streams

APIDescription
addAudioExternalStreamAdd an external audio stream
removeAudioExternalStreamRemove an external audio stream
pushAudioExternalStreamDataPush external PCM audio data
setAudioExternalStreamVolumeSet the volume for an external audio stream
getAudioExternalStreamVolumeGet the volume for an external audio stream
clearAudioExternalStreamBufferClear the buffer for an external audio stream

Audio/video frame callbacks

APIDescription
setAudioFrameObserverSet the audio frame data callback listener
enableAudioFrameObserverEnable or disable audio frame callbacks at a specified point
setVideoFrameObserverSet the video frame data callback listener
enableVideoFrameObserverEnable or disable video frame callbacks at a specified point

AoqClientListener callbacks

CallbackDescription
onErrorEngine error callback
onWarningEngine warning callback
onConnectionStatusChangeConnection state change callback
onStatsEngine statistics callback
onAudioDeviceStateChangedAudio device state change callback
onAudioDeviceRouteChangedAudio output route change callback
onAudioDeviceInterruptedAudio device interruption callback
onVideoDeviceStateChangedVideo device state change callback
onAudioDeviceFocusChangedAudio focus change callback
onAudioFileStateAudio file playback state callback
onDataMsgReal-time data message received callback

API details

Engine lifecycle

createEngine Create the engine instance. The SDK holds the engine as a global singleton; calling this method again returns the existing instance.
@NonNull
public static AoqClientEngine createEngine(
    @NonNull Context context,
    @NonNull AoqCreateConfig config,
    @NonNull AoqClientListener listener)
ParameterTypeDescription
contextContextAndroid application context
configAoqCreateConfigEngine creation configuration
listenerAoqClientListenerEngine event callback listener
Returns: AoqClientEngine instance; never null. destroy Destroy the engine instance and release all resources.
public static int destroy()
Returns: 0 on success; non-zero on failure. getVersion
@NonNull
public static String getVersion()
Returns: Version string, for example "1.0.0". connect Connect to the Relay server. Connection parameters are allocated by the application server via /api/v1/allocate and delivered to the client.
public abstract int connect(@NonNull AoqConnectConfig config)
Returns: 0 if the call was dispatched (asynchronous); non-zero if parameter validation failed. disconnect
public abstract int disconnect()
Returns: 0 if the call was dispatched (asynchronous); non-zero on failure.

Audio device management

public abstract int startAudioCapture(@NonNull AoqAudioCaptureConfig config)
public abstract int stopAudioCapture()
public abstract int muteAudioCapture(boolean mute)
public abstract int startAudioPlayer(@NonNull AoqAudioPlaybackConfig config)
public abstract int stopAudioPlayer()
public abstract int pauseAudioPlayer(int fadeMs)
public abstract int resumeAudioPlayer(int fadeMs)
public abstract int interruptAudioPlayer(@NonNull AoqTrackType trackType, int fadeMs)
public abstract int enableSpeakerphone(boolean enable)
public abstract boolean isSpeakerphoneEnabled()
fadeMs: fade-out/fade-in duration in milliseconds; 0 means immediate.

Audio codec configuration

public abstract int setAudioEncoderConfig(@NonNull AoqAudioCodecConfig config)
public abstract int setAudioDecoderConfig(@NonNull AoqAudioCodecConfig config)

Video device management

public abstract int startVideoCapture(@NonNull AoqVideoCaptureConfig config)
public abstract int stopVideoCapture()
public abstract int switchCamera(@NonNull AoqCameraDirection direction)
public abstract int setLocalView(@NonNull AoqTrackType trackType, @Nullable AoqVideoCanvas canvas)
public abstract int setRemoteView(@NonNull AoqTrackType trackType, @Nullable AoqVideoCanvas canvas)
Pass AoqTrackTypeVideo as the trackType parameter for setLocalView and setRemoteView.

Video encoding and external input

public abstract int setVideoEncoderConfig(@NonNull AoqVideoCodecConfig config)
public abstract int pushExternalVideoCapturedFrame(@NonNull AoqTrackType trackType, @NonNull AoqVideoFrame frame)
public abstract int pushExternalVideoEncodedFrame(@NonNull AoqTrackType trackType, @NonNull AoqVideoEncodedFrame frame)
pushExternalVideoCapturedFrame only consumes frames after startVideoCapture(isExternal=true) has been called. If the internal buffer is full, the method returns AoqErrorCodeVideoExternalBufferFull (210).

Media stream control

public abstract int enableSendMediaStream(@NonNull AoqTrackType trackType, boolean enable)
Recommended pattern: call enableSendMediaStream(false) after initialization, then enable once onConnectionStatusChange reports Connected.

Audio file playback

public abstract int startAudioFile(@NonNull String fileId, @NonNull AoqAudioFileMixConfig config)
public abstract int stopAudioFile(@NonNull String fileId)
public abstract int pauseAudioFile(@NonNull String fileId)
public abstract int resumeAudioFile(@NonNull String fileId)
public abstract long getAudioFileDuration(@NonNull String fileId)
public abstract long getAudioFileCurrentPosition(@NonNull String fileId)
public abstract int setAudioFilePositionMillis(@NonNull String fileId, long positionMillis)
public abstract int setAudioFileVolume(@NonNull String fileId, @NonNull AoqAudioStreamDirection type, int volume)
public abstract int getAudioFileVolume(@NonNull String fileId, @NonNull AoqAudioStreamDirection type)

External audio streams

public abstract int addAudioExternalStream(@NonNull String streamId, @NonNull AoqAudioExternalStreamConfig config)
public abstract int removeAudioExternalStream(@NonNull String streamId)
public abstract int pushAudioExternalStreamData(@NonNull String streamId, @NonNull AoqAudioFrameData data)
public abstract int setAudioExternalStreamVolume(@NonNull String streamId, @NonNull AoqAudioStreamDirection type, int volume)
public abstract int getAudioExternalStreamVolume(@NonNull String streamId, @NonNull AoqAudioStreamDirection type)
public abstract void clearAudioExternalStreamBuffer(@NonNull String streamId, int fadeoutMs)
When pushAudioExternalStreamData returns AoqErrorCodeAudioExternalBufferFull (110), the internal buffer is full. Wait 30 ms and retry.

Real-time messaging

public abstract int sendDataMsg(@NonNull AoqDataMsg msg)

Audio frame callbacks

public abstract int setAudioFrameObserver(@Nullable AoqClientListener.AoqAudioFrameListener listener)
public abstract int enableAudioFrameObserver(boolean enabled, @NonNull AoqAudioSource audioSource, @NonNull AoqAudioObserverConfig config)

Video frame callbacks

public abstract int setVideoFrameObserver(@Nullable AoqClientListener.AoqVideoFrameListener listener)
public abstract int enableVideoFrameObserver(boolean enabled, @NonNull AoqVideoSource videoSource, @NonNull AoqVideoObserverConfig config)

AoqClientListener callbacks

AoqClientListener is the unified delivery point for all asynchronous events from the SDK. All callback methods have a default empty implementation, so you only need to override the ones you care about.
public void onError(int code, String message)
public void onWarning(int code, String message)
public void onConnectionStatusChange(@NonNull AoqConnectionStatus status)
public void onStats(@NonNull AoqStats stats)
public void onAudioDeviceStateChanged(@NonNull AoqAudioDeviceState state)
public void onAudioDeviceRouteChanged(int routeType)
public void onAudioDeviceInterrupted(boolean interrupt)
public void onVideoDeviceStateChanged(@NonNull AoqVideoDeviceState state)
public void onAudioDeviceFocusChanged(int audioFocus)
public void onAudioFileState(@NonNull AoqAudioFileState state)
public void onDataMsg(@NonNull AoqDataMsg msg)
Connection state transitions: Disconnected → Connecting → Connected/Failed → Disconnected.

AoqAudioFrameListener

public interface AoqAudioFrameListener {
    default void onCapturedAudioFrame(@NonNull AoqAudioFrameData frame) {}
    default void onProcessCapturedAudioFrame(@NonNull AoqAudioFrameData frame) {}
    default void onPublishAudioFrame(@NonNull AoqTrackType trackType, @NonNull AoqAudioFrameData frame) {}
    default void onPlaybackAudioFrame(@NonNull AoqAudioFrameData frame) {}
}

AoqVideoFrameListener

public interface AoqVideoFrameListener {
    default boolean onCapturedVideoFrame(@NonNull AoqVideoFrameData frame) { return false; }
    default boolean onPreEncodeVideoFrame(@NonNull AoqTrackType trackType, @NonNull AoqVideoFrameData frame) { return false; }
    default boolean onRemoteVideoFrame(@NonNull AoqTrackType trackType, @NonNull AoqVideoFrameData frame) { return false; }
}
Return true to indicate that you have modified the frame data and want the SDK to read it back (write-back only takes effect for I420 format). The ByteBuffer and textureId in frame are valid only during the callback; copy them before any asynchronous use.

Data types and enumerations

General types

AoqCreateConfig
FieldTypeDefaultDescription
workDirString""SDK working directory
isBTScoModebooleanfalsetrue: Bluetooth SCO mode; false: A2DP mode
enableDumpAudiobooleanfalseEnable audio dump (for debugging)
extrasString""Extra parameters string
AoqConnectConfig
FieldTypeDefaultDescription
tokenString""Authentication token
sidString""Session ID
certFingerprintString""Server certificate fingerprint
relayEndpointsList<AoqRelayEndpoint>emptyList of Relay endpoints
workspaceIdHashString""Workspace ID hash
publishTracksList<AoqTrackParam>emptyLocal tracks to publish
subscribeTracksList<AoqTrackParam>emptyRemote tracks to subscribe to

Statistics types

AoqNetworkStats
FieldTypeDescription
sendBitrateintSend bitrate (bps)
sendByteslongCumulative bytes sent
recvBitrateintReceive bitrate (bps)
recvByteslongCumulative bytes received
lossintPacket loss rate (0-100)
rttintRound-trip time (ms)

Enumerations

AoqErrorCode
Enum valueValueDescription
AoqErrorCodeOK0Success
AoqErrorCodeParamInvalid1Invalid parameter
AoqErrorCodeStateInvalid2Invalid state
AoqErrorCodeUnSupport3Not supported
AoqErrorCodeAudio100Audio generic error
AoqErrorCodeAudioExternalBufferFull110External audio buffer full
AoqErrorCodeAudioDevice120Audio device generic error
AoqErrorCodeAudioDeviceRecordingAuthFailed121Recording permission not granted
AoqErrorCodeAudioDeviceRecordingOccupied122Recording device in use
AoqErrorCodeAudioDeviceRecordingBackgroundStart123Failed to start recording in background
AoqErrorCodeAudioDeviceRecordingStartFail124Recording start failed
AoqErrorCodeAudioDevicePlayoutOccupied125Playback device in use
AoqErrorCodeAudioDevicePlayoutBackgroundStart126Failed to start playback in background
AoqErrorCodeAudioDevicePlayoutStartFail127Playback start failed
AoqErrorCodeAudioDeviceEarpieceRequiresVoipMode128Earpiece requires VoIP mode
AoqErrorCodeVideo200Video generic error
AoqErrorCodeVideoExternalBufferFull210External video buffer full
AoqErrorCodeVideoExternalCaptureNotEnabled211External video capture not enabled
AoqErrorCodeVideoExternalEncoderNotEnabled212External video encoder not enabled
AoqErrorCodeVideoDevice220Video device generic error
AoqErrorCodeVideoDeviceCameraOpenFail221Camera open failed
AoqErrorCodeVideoDeviceCameraAuthFailed222Camera permission not granted
AoqErrorCodeVideoDeviceCameraOccupied223Camera in use
AoqErrorCodeVideoDeviceCameraRunningError224Camera runtime error
AoqErrorCodeVideoCodec230Video codec generic error
AoqErrorCodeVideoCodecEncoderInitFail231Video encoder initialization failed
AoqErrorCodeVideoRender240Video rendering generic error
AoqErrorCodeVideoRenderCreateFail241Video renderer creation failed
AoqErrorCodeVideoRenderDrawError242Video rendering draw error
AoqWarningCode
Enum valueValueDescription
AoqWCOK0No warning
AoqWCAudio100Audio generic warning
AoqWCAudioHowling101Audio howling detected
AoqWCAudioDevice120Audio device generic warning
AoqWCAudioDeviceMicEnumerateError121Microphone enumeration error
AoqWCAudioDeviceMicStartTimeout122Microphone start timeout
AoqWCAudioDeviceRecordingError123Recording error
AoqWCAudioDeviceSpeakerEnumerateError124Speaker enumeration error
AoqWCAudioDeviceSpeakerStartTimeout125Speaker start timeout
AoqWCAudioDevicePlayoutError126Playback error
AoqWCVideo200Video generic warning
AoqWCVideoCameraEnumerateError201Camera enumeration error
AoqWCVideoEncoderSwitched202Video encoder switched
AoqWCVideoRenderDowngrade203Video rendering downgraded
AoqTrackType
Enum valueValueDescription
AoqTrackTypeAudio0Audio track
AoqTrackTypeVideo1Video track
AoqTrackTypeData2Data messaging track
AoqEncoderType
Enum valueValueDescription
AoqEncoderTypeUnknown0Unknown format
AoqEncoderTypeAudioPCM1Audio PCM
AoqEncoderTypeAudioOpus2Audio Opus
AoqEncoderTypeVideoH2643Video H.264
AoqEncoderTypeVideoJpeg4Video JPEG
AoqEncoderTypeDataText5Data text
AoqConnectionStatus
Enum valueValueDescription
AoqConnectionStatusDisconnected0Disconnected
AoqConnectionStatusConnecting1Connecting
AoqConnectionStatusConnected2Connected
AoqConnectionStatusFailed3Connection failed

Audio types

AoqAudioCaptureConfig
FieldTypeDefaultDescription
isExternalbooleanfalseWhether to use external capture mode
isVoipModebooleanfalseWhether to enable VoIP mode (affects device routing, e.g., earpiece)
channelint1Channel count (default: mono)
AoqAudioPlaybackConfig
FieldTypeDefaultDescription
isVoipModebooleanfalseWhether to enable VoIP mode (hardware AEC); applies to mobile
isDefaultSpeakerbooleantrueWhether to default to the speaker; applies to mobile
isExternalbooleanfalseWhether to use external playback mode
channelint1Channel count (default: mono)
AoqAudioCodecConfig
FieldTypeDefaultDescription
trackTypeAoqTrackTypeAudioTrack type
codecTypeAoqEncoderTypeAudioPCMCodec format
sampleRateint48000Sample rate (Hz)
channelint1Channel count
bitrateint32000Bitrate (bps)

Video types

AoqVideoCaptureConfig
FieldTypeDefaultDescription
widthint1280Capture width (pixels); ignored when isExternal=true
heightint720Capture height (pixels); ignored when isExternal=true
fpsint15Capture frame rate; ignored when isExternal=true
isExternalbooleanfalseExternal capture mode; when true, the camera is not opened
cameraDirectionAoqCameraDirectionFrontCamera direction; ignored when isExternal=true
AoqVideoCodecConfig
FieldTypeDefaultDescription
trackTypeAoqTrackTypeVideoTrack type
codecTypeAoqEncoderTypeVideoH264Codec format
widthint720Encoding width (pixels)
heightint1280Encoding height (pixels)
fpsint5Encoding frame rate
bitrateint500000Target bitrate (bps)
minBitrateint128000Minimum bitrate (bps)
keyframeIntervalint2Keyframe interval (seconds)
mirrorModeAoqMirrorModeDisabledMirror mode
orientationModeAoqOrientationModeAutoVideo orientation mode
isExternalbooleanfalseWhen true, the SDK skips re-encoding; use pushExternalVideoEncodedFrame to deliver pre-encoded data
AoqVideoPixelFormat
Enum valueValueDescription
AoqVideoPixelFormatUnknown0Unknown format
AoqVideoPixelFormatI4201I420 (YUV planar)
AoqVideoPixelFormatNV122NV12 (YUV semi-planar)
AoqVideoPixelFormatNV213NV21 (YUV semi-planar)
AoqVideoPixelFormatBGRA4BGRA 32-bit
AoqVideoPixelFormatRGBA5RGBA 32-bit
AoqVideoPixelFormatTextureOES7External OES texture
AoqVideoPixelFormatTexture2D8Standard 2D texture

External audio stream types

AoqAudioExternalStreamConfig
FieldTypeDefaultDescription
trackTypeAoqTrackTypeAudioAudio track type
codecTypeAoqEncoderTypeAudioPCMAudio stream format
channelsint1Channel count
sampleRateint48000Sample rate (Hz)
playoutVolumeint100Playback volume [0-100]
publishVolumeint100Publishing volume [0-100]
maxBufferDurationint1000Maximum buffer duration (milliseconds)
enable3AbooleanfalseWhether to apply 3A processing to input PCM
AoqAudioStreamDirection
Enum valueValueDescription
AoqAudioStreamPublish0Publish stream (send)
AoqAudioStreamPlayout1Playout stream (receive)

Data message types

AoqDataMsg
FieldTypeDefaultDescription
databyte[]new byte[0]Message data (byte array)