Skip to main content
AOQ SDK Reference

HarmonyOS SDK

AOQ HarmonyOS SDK API reference

AOQ Client SDK HarmonyOS (OHOS) API reference. The platform language is ArkTS (.ets), bridged to the C++ engine via NAPI.

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

APIDescription
enableSendMediaStreamEnable or disable local media stream sending

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

Real-time messaging

APIDescription
sendDataMsgSend a real-time data message

Audio frame callbacks

APIDescription
setAudioFrameObserverSet the audio frame data callback observer
enableAudioFrameObserverEnable or disable audio frame callbacks at a specified point

Video frame callbacks

APIDescription
setVideoFrameObserverSet the video frame data callback observer
enableVideoFrameObserverEnable or disable video frame callbacks at a specified point

AoqEngineEventListener callbacks

CallbackDescription
onErrorEngine error callback
onWarningEngine warning callback
onConnectionStatusChangeConnection state change callback
onStatsStatistics callback
onAudioDeviceStateChangedAudio device state change callback
onAudioDeviceRouteChangedAudio output route change callback
onAudioDeviceInterruptedAudio device interruption callback
onVideoDeviceStateChangedVideo device state change callback
onAudioFileStateAudio file playback state callback
onDataMsgReal-time data message received callback
IAudioFrameObserverAudio frame data observer interface
IVideoFrameObserverVideo frame data observer interface

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. Returns null if the native engine fails to initialize.
static createEngine(config: AoqCreateConfig, listener: AoqEngineEventListener, context: common.Context): AoqClientEngine | null
ParameterTypeDescription
configAoqCreateConfigEngine creation configuration
listenerAoqEngineEventListenerEngine event callback listener (interface; all callbacks are optional)
contextcommon.ContextUIAbility/Page context, used for aki+ACPM initialization
Returns: AoqClientEngine | null -- null if native creation fails. Note: Unlike Android, this SDK returns null on failure. Always null-check the return value. The context must be a valid UIAbility or Page context.

destroy

Destroy the engine singleton and release all resources. You must call createEngine again before resuming use.
static destroy(): number
Returns: 0 on success; non-zero on failure.

getVersion

Get the current SDK version string.
static getVersion(): string
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.
connect(config: AoqConnectConfig): number
ParameterTypeDescription
configAoqConnectConfigConnection configuration, including token, SID, and Relay endpoint list
Returns: 0 if the call was dispatched (asynchronous); non-zero if parameter validation failed. Note: Connection state changes are reported asynchronously via onConnectionStatusChange. It is recommended to call enableSendMediaStream(false) before calling connect.

disconnect

Disconnect from the server and release connection-related resources. Audio and video capture/playback devices are not stopped automatically.
disconnect(): number
Returns: 0 if the call was dispatched (asynchronous); non-zero on failure.

Audio device management

startAudioCapture

Open the audio capture device (microphone).
startAudioCapture(config: AoqAudioCaptureConfig): number
ParameterTypeDescription
configAoqAudioCaptureConfigCapture configuration
Returns: 0 on success; non-zero on failure.

stopAudioCapture

Close the audio capture device.
stopAudioCapture(): number

muteAudioCapture

Mute or unmute audio capture.
muteAudioCapture(mute: boolean): number
ParameterTypeDescription
mutebooleantrue: mute; false: unmute

startAudioPlayer

Start audio playback (play remote audio through the speaker or earpiece).
startAudioPlayer(config: AoqAudioPlaybackConfig): number
ParameterTypeDescription
configAoqAudioPlaybackConfigPlayback configuration

stopAudioPlayer

Stop audio playback.
stopAudioPlayer(): number

pauseAudioPlayer

Pause audio playback with an optional fade-out for a smooth transition.
pauseAudioPlayer(fadeMs: number): number
ParameterTypeDescription
fadeMsnumberFade-out duration (milliseconds); 0 means immediate

resumeAudioPlayer

Resume audio playback with an optional fade-in for a smooth transition.
resumeAudioPlayer(fadeMs: number): number
ParameterTypeDescription
fadeMsnumberFade-in duration (milliseconds); 0 means immediate

interruptAudioPlayer

Interrupt the current audio call turn.
interruptAudioPlayer(trackType: AoqTrackType, fadeMs: number): number
ParameterTypeDescription
trackTypeAoqTrackTypeTarget track type; typically AoqTrackTypeAudio
fadeMsnumberFade-out duration (milliseconds)

enableSpeakerphone

Switch the audio output route between the speaker and the earpiece.
enableSpeakerphone(enable: boolean): number
ParameterTypeDescription
enablebooleantrue: use speaker; false: use earpiece

isSpeakerphoneEnabled

Query whether the speaker is currently active.
isSpeakerphoneEnabled(): boolean
Returns: true if the speaker is active; false if the earpiece is active.

Audio codec configuration

setAudioEncoderConfig

Set audio encoding parameters.
setAudioEncoderConfig(config: AoqAudioCodecConfig): number

setAudioDecoderConfig

Set audio decoding parameters.
setAudioDecoderConfig(config: AoqAudioCodecConfig): number

Video device management

startVideoCapture

Open the video capture device (camera). When config.isExternal = true, the camera is not opened; the caller provides frames via pushExternalVideoCapturedFrame.
startVideoCapture(config: AoqVideoCaptureConfig): number

stopVideoCapture

Close the video capture device.
stopVideoCapture(): number

switchCamera

Switch between the front and rear cameras.
switchCamera(direction: AoqCameraDirection): number
ParameterTypeDescription
directionAoqCameraDirectionAoqCameraDirectionFront or AoqCameraDirectionBack

setLocalView

Set or remove the local video rendering view.
setLocalView(trackType: AoqTrackType, canvas: AoqVideoCanvas | null): number
ParameterTypeDescription
trackTypeAoqTrackTypeAoqTrackTypeVideo
canvasAoqVideoCanvas | nullRendering canvas configuration; pass null or set canvas.view to null to remove the rendering view
Note: On HarmonyOS, this must be called after the XComponent.onLoad callback. Pass an AoqXComponentController instance as canvas.view.

setRemoteView

Set or remove the remote video rendering view.
setRemoteView(trackType: AoqTrackType, canvas: AoqVideoCanvas | null): number
ParameterTypeDescription
trackTypeAoqTrackTypeAoqTrackTypeVideo
canvasAoqVideoCanvas | nullRendering canvas configuration; pass null or set canvas.view to null to remove the rendering view

Video encoding and external input

setVideoEncoderConfig

Set video encoding parameters. The call is routed to the track specified by config.trackType.
setVideoEncoderConfig(config: AoqVideoCodecConfig): number

pushExternalVideoCapturedFrame

Push an externally captured raw video frame.
pushExternalVideoCapturedFrame(trackType: AoqTrackType, frame: AoqVideoFrame): number
ParameterTypeDescription
trackTypeAoqTrackTypeAoqTrackTypeVideo
frameAoqVideoFrameVideo frame data
Only consumed after startVideoCapture(isExternal=true). Supported formats: NV12, NV21, BGRA, RGBA, I420. If the internal buffer is full, the method returns AoqECVideoExternalBufferFull(210). Sleep and retry; do not busy-loop.

pushExternalVideoEncodedFrame

Push an externally encoded video frame. The SDK sends it directly without re-encoding.
pushExternalVideoEncodedFrame(trackType: AoqTrackType, frame: AoqVideoEncodedFrame): number
ParameterTypeDescription
trackTypeAoqTrackTypeAoqTrackTypeVideo
frameAoqVideoEncodedFrameEncoded frame data
Only consumed after setVideoEncoderConfig(isExternal=true) is configured.

Media stream control

enableSendMediaStream

Enable or disable local media stream sending. The call is routed to the track specified by trackType.
enableSendMediaStream(trackType: AoqTrackType, enable: boolean): number
ParameterTypeDescription
trackTypeAoqTrackTypeAoqTrackTypeAudio or AoqTrackTypeVideo
enablebooleantrue: enable sending; false: disable sending
Recommended pattern: call enableSendMediaStream(trackType, false) after initialization, then enable once the connection is established and the session handshake completes (onConnectionStatusChange reports AoqConnectionStatusConnected).

Audio file playback

startAudioFile

Start streaming a local audio file. Audio file playback is mixed into both the published stream and local playback.
startAudioFile(fileId: string, config: AoqAudioFileMixConfig): number
ParameterTypeDescription
fileIdstringUnique identifier for the audio file, specified by the caller
configAoqAudioFileMixConfigPlayback configuration

stopAudioFile / pauseAudioFile / resumeAudioFile

stopAudioFile(fileId: string): number
pauseAudioFile(fileId: string): number
resumeAudioFile(fileId: string): number

getAudioFileDuration / getAudioFileCurrentPosition

getAudioFileDuration(fileId: string): number      // Returns total duration (ms); negative on failure
getAudioFileCurrentPosition(fileId: string): number // Returns current position (ms); negative on failure

setAudioFilePositionMillis

setAudioFilePositionMillis(fileId: string, positionMillis: number): number

setAudioFileVolume / getAudioFileVolume

setAudioFileVolume(fileId: string, type: AoqAudioStreamDirection, volume: number): number
getAudioFileVolume(fileId: string, type: AoqAudioStreamDirection): number // Returns [0, 100]; negative on failure

External audio streams

addAudioExternalStream

Add an external audio stream.
addAudioExternalStream(streamId: string, config: AoqAudioExternalStreamConfig): number

pushAudioExternalStreamData

Push external PCM audio data. Returns AoqECAudioExternalBufferFull(110) if the internal buffer is full.
pushAudioExternalStreamData(streamId: string, data: AoqAudioFrameData): number

setAudioExternalStreamVolume / getAudioExternalStreamVolume

setAudioExternalStreamVolume(streamId: string, type: AoqAudioStreamDirection, vol: number): number
getAudioExternalStreamVolume(streamId: string, type: AoqAudioStreamDirection): number

clearAudioExternalStreamBuffer

Clear the external audio stream buffer. No return value; executes asynchronously.
clearAudioExternalStreamBuffer(streamId: string, fadeoutMs: number): void
ParameterTypeDescription
fadeoutMsnumber-1: default fade-out; 0: clear immediately; >0: retain the specified duration then fade out

removeAudioExternalStream

removeAudioExternalStream(streamId: string): number

Real-time messaging

sendDataMsg

Send a real-time data message over the MoQT data channel.
sendDataMsg(msg: AoqDataMsg): number

Audio frame callbacks

setAudioFrameObserver

Set the audio frame data callback observer. Register the observer first, then call enableAudioFrameObserver to start receiving callbacks.
setAudioFrameObserver(observer: IAudioFrameObserver | null): number

enableAudioFrameObserver

enableAudioFrameObserver(enabled: boolean, audioSource: AoqAudioSource, config: AoqAudioObserverConfig): number

Video frame callbacks

setVideoFrameObserver

setVideoFrameObserver(observer: IVideoFrameObserver | null): number

enableVideoFrameObserver

enableVideoFrameObserver(enabled: boolean, videoSource: AoqVideoSource, config: AoqVideoObserverConfig): number

AoqEngineEventListener callbacks

All callbacks are optional properties (?).
export interface AoqEngineEventListener {
  onError?: (code: number, message: string) => void;
  onWarning?: (code: number, message: string) => void;
  onConnectionStatusChange?: (status: AoqConnectionStatus) => void;
  onStats?: (stats: AoqStats) => void;
  onAudioDeviceStateChanged?: (state: AoqAudioDeviceState) => void;
  onAudioDeviceRouteChanged?: (routeType: number) => void;
  onAudioDeviceInterrupted?: (interrupt: boolean) => void;
  onVideoDeviceStateChanged?: (state: AoqVideoDeviceState) => void;
  onAudioFileState?: (state: AoqAudioFileState) => void;
  onDataMsg?: (msg: AoqDataMsg) => void;
}

IAudioFrameObserver

export interface IAudioFrameObserver {
  onCapturedAudioFrame?: (frame: AoqAudioFrameData) => void;
  onProcessCapturedAudioFrame?: (frame: AoqAudioFrameData) => void;
  onPublishAudioFrame?: (trackType: AoqTrackType, frame: AoqAudioFrameData) => void;
  onPlaybackAudioFrame?: (frame: AoqAudioFrameData) => void;
}
frame.dataPtr is a Uint8Array copy of native memory and is currently read-only (modifications are not written back to the SDK).

IVideoFrameObserver

export interface IVideoFrameObserver {
  onCapturedVideoFrame?: (frame: AoqVideoFrame) => boolean;
  onPreEncodeVideoFrame?: (trackType: AoqTrackType, frame: AoqVideoFrame) => boolean;
  onRemoteVideoFrame?: (trackType: AoqTrackType, frame: AoqVideoFrame) => boolean;
}
Frame buffers are Uint8Array copies of native memory, valid only during the callback. They are currently equivalent to read-only; write-back support is planned for a future release.

Data types and enumerations

General types

AoqCreateConfig

FieldTypeDefaultDescription
workDirstring""SDK working directory
enableDumpAudiobooleanfalseEnable raw audio dump (for debugging)
extrasstring""Extra parameters string
Unlike Android, AoqCreateConfig on HarmonyOS does not include isBTScoMode.

AoqConnectConfig

FieldTypeDefaultDescription
tokenstring""Authentication token
sidstring""Session ID
certFingerprintstring""Server certificate fingerprint
relayEndpointsAoqRelayEndpoint[][]List of Relay endpoints
workspaceIdHashstring""Workspace ID hash
publishTracksAoqTrackParam[][]Local tracks to publish
subscribeTracksAoqTrackParam[][]Remote tracks to subscribe to

AoqRelayEndpoint

FieldTypeDescription
endpointstringRelay server hostname or IP
portnumberRelay server port

AoqTrackParam

FieldTypeDescription
trackTypeAoqTrackTypeTrack type

AoqErrorCode

Enum valueValueDescription
AoqECOK0Success
AoqECParamInvalid1Invalid parameter
AoqECStateInvalid2Invalid state
AoqECUnSupport3Not supported
AoqECAudio100Audio generic error
AoqECAudioExternalBufferFull110External audio buffer full
AoqECAudioDevice120Audio device generic error
AoqECAudioDeviceRecordingAuthFailed121Recording permission not granted
AoqECAudioDeviceRecordingOccupied122Recording device in use
AoqECAudioDeviceRecordingBackgroundStart123Failed to start recording in background
AoqECAudioDeviceRecordingStartFail124Recording start failed
AoqECAudioDevicePlayoutOccupied125Playback device in use
AoqECAudioDevicePlayoutBackgroundStart126Failed to start playback in background
AoqECAudioDevicePlayoutStartFail127Playback start failed
AoqECAudioDeviceEarpieceRequiresVoipMode128Earpiece requires VoIP mode
AoqECVideo200Video generic error
AoqECVideoExternalBufferFull210External video buffer full
AoqECVideoExternalCaptureNotEnabled211External video capture not enabled
AoqECVideoExternalEncoderNotEnabled212External video encoder not enabled
AoqECVideoDevice220Video device generic error
AoqECVideoDeviceCameraOpenFail221Camera open failed
AoqECVideoDeviceCameraAuthFailed222Camera permission not granted
AoqECVideoDeviceCameraOccupied223Camera in use
AoqECVideoDeviceCameraRunningError224Camera runtime error
AoqECVideoCodec230Video codec generic error
AoqECVideoCodecEncoderInitFail231Video encoder initialization failed
AoqECVideoRender240Video rendering generic error
AoqECVideoRenderCreateFail241Video renderer creation failed
AoqECVideoRenderDrawError242Video 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
Unlike Android, AoqTrackTypeScreen(3) is not included on HarmonyOS. Screen capture is not yet available.

AoqConnectionStatus

Enum valueValueDescription
AoqConnectionStatusDisconnected0Disconnected
AoqConnectionStatusConnecting1Connecting
AoqConnectionStatusConnected2Connected
AoqConnectionStatusFailed3Connection failed

AoqEncoderType / AoqMirrorMode / AoqOrientationMode

Same as the Android SDK; no changes.

Audio types

AoqAudioCaptureConfig

FieldTypeDefaultDescription
isExternalbooleanfalsetrue: use external audio input
isVoipModebooleanfalsetrue: enable VoIP mode (hardware AEC)
channelnumber1Channel count: 1 or 2

AoqAudioPlaybackConfig

FieldTypeDefaultDescription
isVoipModebooleanfalsetrue: enable VoIP mode (hardware AEC); first-write-wins between capture and playback config
isDefaultSpeakerbooleantruetrue: default to speaker; false: default to earpiece
isExternalbooleanfalsetrue: use external audio output
channelnumber1Channel count: 1 or 2

AoqAudioCodecConfig

FieldTypeDefaultDescription
trackTypeAoqTrackTypeAoqTrackTypeAudioTarget track
codecTypeAoqEncoderTypeAoqEncoderTypeAudioPCMCodec format
sampleRatenumber48000Sample rate (Hz)
channelnumber1Channel count
bitratenumber32000Bitrate (bps)

Video types

AoqVideoCaptureConfig

FieldTypeDefaultDescription
widthnumber1280Capture width; ignored when isExternal=true
heightnumber720Capture height
fpsnumber15Capture frame rate
isExternalbooleanfalsetrue: do not open the camera; provide frames via pushExternalVideoCapturedFrame
cameraDirectionAoqCameraDirectionFrontCamera direction

AoqVideoCodecConfig

FieldTypeDefaultDescription
trackTypeAoqTrackTypeAoqTrackTypeVideoTarget track
codecTypeAoqEncoderTypeAoqEncoderTypeVideoH264Codec format
widthnumber720Encoding width
heightnumber1280Encoding height
fpsnumber15Frame rate
bitratenumber500Bitrate (kbps)
minBitratenumber128Minimum bitrate (kbps)
keyframeIntervalnumber2Keyframe interval (seconds)
mirrorModeAoqMirrorModeDisabledMirror mode
orientationModeAoqOrientationModeAutoVideo orientation
isExternalbooleanfalsetrue: the SDK skips re-encoding
Unlike Android, bitrate units on HarmonyOS are kbps (defaults: 500/128). On Android they are bps (defaults: 500000/128000).

AoqVideoCanvas

FieldTypeDefaultDescription
viewObject | nullnullAoqXComponentController instance; pass null to remove the rendering binding
renderModeAoqRenderModeAoqRenderModeAutoDisplay mode

AoqVideoPixelFormat

Enum valueValueDescription
AoqVideoPixelFormatUnknown0Unknown
AoqVideoPixelFormatI4201I420
AoqVideoPixelFormatNV122NV12
AoqVideoPixelFormatNV213NV21
AoqVideoPixelFormatBGRA4BGRA
AoqVideoPixelFormatRGBA5RGBA
TextureOES and Texture2D are not supported on HarmonyOS.

AoqVideoFrame

FieldTypeDescription
formatAoqVideoPixelFormatPixel format
widthnumberWidth (pixels)
heightnumberHeight (pixels)
dataPtrArrayBuffer | Uint8Array | nullPacked format data
dataSizenumberPacked data size (bytes)
dataY / dataU / dataVArrayBuffer | Uint8Array | nullI420 planes
strideY / strideU / strideVnumberPlane stride
timeStampnumberTimestamp (ms); when 0, the SDK uses the local clock

AoqVideoEncodedFrame

FieldTypeDescription
codecAoqVideoCodecTypeEncoding format (AoqVideoCodecTypeJPEG = 0)
dataArrayBuffer | Uint8ArrayEncoded frame data
widthnumberWidth
heightnumberHeight
timeStampnumberTimestamp (ms)

Audio file and external stream types

AoqAudioFileMixConfig

FieldTypeDefaultDescription
fileNamestring""File name (including path)
cyclesnumber-1Loop count; -1 means loop indefinitely
startPosMsnumber0Starting playback position (ms)
publishVolumenumber100Publishing volume [0, 100]
playoutVolumenumber100Local playback volume [0, 100]

AoqAudioExternalStreamConfig

FieldTypeDefaultDescription
trackTypeAoqTrackTypeAoqTrackTypeAudioTrack type
codecTypeAoqEncoderTypeAoqEncoderTypeAudioPCMAudio format
channelsnumber1Channel count
sampleRatenumber48000Sample rate (Hz)
playoutVolumenumber100Playback volume [0, 100]
publishVolumenumber100Publishing volume [0, 100]
maxBufferDurationnumber1000Maximum buffer duration (ms)
enable3AbooleanfalseWhether to apply 3A processing to input PCM

AoqAudioFrameData

FieldTypeDescription
dataPtrArrayBuffer | Uint8Array | nullRaw PCM audio data
dataSizenumberPCM data size (bytes)
numOfSamplesnumberSample count (mono)
bytesPerSamplenumberBytes per sample
numOfChannelsnumberChannel count
samplesPerSecnumberSample rate
pushSequencenumberPCM push sequence number
timeStampnumberTimestamp
autoGenMutebooleantrue: this is SDK-generated silence data

Observer configuration types

AoqAudioObserverConfig

FieldTypeDefaultDescription
sampleRatenumber48000Callback sample rate
channelsnumber1Callback channel count
modeAoqAudioObserverModeReadOnlyRead/write mode

AoqVideoObserverConfig

FieldTypeDefaultDescription
formatAoqVideoPixelFormatI420Callback pixel format
alignmentAoqVideoObserverAlignmentDefaultWidth alignment
modeAoqVideoObserverModeReadOnlyRead/write mode
mirrorAppliedbooleanfalseWhether to apply mirroring

Statistics types

AoqStats

FieldTypeDescription
audioPublishStatsAoqAudioPublishStats[]Audio publish statistics
videoPublishStatsAoqVideoPublishStats[]Video publish statistics
dataMsgPublishStatsAoqDataMsgPublishStats[]Data message publish statistics
audioSubscribeStatsAoqAudioSubscribeStats[]Audio subscribe statistics
videoSubscribeStatsAoqVideoSubscribeStats[]Video subscribe statistics
dataMsgSubscribeStatsAoqDataMsgSubscribeStats[]Data message subscribe statistics
networkStatsAoqNetworkStats | nullNetwork statistics

Statistics subtypes

AoqAudioPublishStats: trackType / bitrate / bytes / encodeVolume AoqVideoPublishStats: trackType / bitrate / bytes / encodeFps AoqAudioSubscribeStats: trackType / bitrate / bytes / playVolume AoqVideoSubscribeStats: trackType / bitrate / bytes / decodeFps / renderFps AoqDataMsgPublishStats / AoqDataMsgSubscribeStats: trackType / bitrate / bytes AoqNetworkStats: sendBitrate / sendBytes / recvBitrate / recvBytes / loss / rtt

Key differences from the Android SDK

CategoryAndroidHarmonyOS
Implementation languageJavaArkTS (.ets), NAPI-bridged to C++
Return value typeint / long / booleannumber / boolean
createEngine return@NonNull AoqClientEngineAoqClientEngine | null
createEngine contextandroid.content.Contextcommon.Context (UIAbility/Page)
Listener formAbstract class with default empty methodsTS interface; all callbacks are optional (?)
Frame observer formInterface with default methodsTS interface; all callbacks are optional (?)
AoqCreateConfigIncludes isBTScoModeDoes not include isBTScoMode
AoqAudioPlaybackConfigNo isVoipModeIncludes isVoipMode; first-write-wins between capture and playback
onAudioDeviceFocusChangedProvidedNot provided (no audio focus abstraction)
Video rendering viewView (SurfaceView/TextureView)AoqXComponentController (extends XComponentController)
Pixel format enumIncludes TextureOES (7) / Texture2D (8)Does not include texture formats
Video frame extra fieldstextureId / transformMatrix / eglContextNot included
Frame data containerbyte[] / ByteBufferArrayBuffer / Uint8Array
Video encoding bitrate unitbps (defaults: 500000/128000)kbps (defaults: 500/128)
AoqTrackTypeIncludes AoqTrackTypeScreen (3)Does not include AoqTrackTypeScreen; screen capture not yet available
Screen capture APIsstartScreenCapture / stopScreenCaptureNot yet provided
Observer write-backI420 write-back supportedCurrently equivalent to read-only; write-back planned for future release
Observer re-registration safetyRelies on SDK internalsUAF protection using tombstone pattern
Device monitoringImplicit in Java layerAoqDeviceMonitor (internal) starts automatically
Error code namespaceAoqErrorCodeXxxAoqECXxx (e.g., AoqECOK, AoqECParamInvalid)

Architecture notes

  1. AoqXComponentController: Extends XComponentController and overrides onSurfaceCreated, onSurfaceChanged, and onSurfaceDestroyed. Create an instance, attach it to an XComponent, and pass it as canvas.view when calling setLocalView or setRemoteView.
  2. NAPI architecture: facade (AoqClientEngine.ets) -> implementation (AoqClientEngineImpl.ets) -> NAPI (libaoq_client_sdk.so). Configuration objects are flattened into individual parameters at the implementation layer.
  3. Device monitoring (internal): AoqDeviceMonitor starts automatically after createEngine and forwards network state and app foreground/background state to the C++ engine.
  4. Observer UAF protection: Re-registration follows a three-step sequence: cut old reference in C++ -> push old observer to tombstone -> point to new observer.
  5. Frame payload semantics: Uint8Array buffers in audio/video frame callbacks are copies of native memory. Write-back is not supported in P1; zero-copy is planned for P2.