Skip to main content
AOQ SDK

AOQ Client SDK HarmonyOS API reference

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

HarmonyOS SDK
The AOQ SDK provides generic video APIs. Qwen-Audio-Realtime does not support video input or output. For the media capabilities of other models, see their access documentation.
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 an engine instance (static singleton factory)
destroyDestroy the engine instance (static method)
getVersionGet the SDK version (static method)
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 rendering (remote audio playback)
stopAudioPlayerStop audio rendering
pauseAudioPlayerPause audio rendering, with optional fade-out
resumeAudioPlayerResume audio rendering, with optional fade-in
interruptAudioPlayerInterrupt the current audio session
enableSpeakerphoneSwitch audio output between the speaker and earpiece
isSpeakerphoneEnabledCheck whether audio output uses the speaker

Audio encoding configuration

APIDescription
setAudioEncoderConfigSet audio encoding parameters
setAudioDecoderConfigSet audio decoding parameters

Audio file playback

APIDescription
startAudioFileStart playing and publishing 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 of the audio file
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
pushAudioExternalStreamDataPush external PCM audio data
setAudioExternalStreamVolumeSet the external audio stream volume
getAudioExternalStreamVolumeGet the external audio stream volume
clearAudioExternalStreamBufferClear the external audio stream buffer
removeAudioExternalStreamRemove an external audio stream

Audio frame callbacks

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

Local audio volume indication

APIDescription
enableLocalAudioVolumeIndicationEnable or disable local capture volume indication

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 window
setRemoteViewSet or remove the remote video rendering window

Video encoding and external input

APIDescription
setVideoEncoderConfigSet video encoding parameters
setVideoDecoderConfigSet video decoding parameters
pushExternalVideoCapturedFramePush externally captured video frames
pushExternalVideoEncodedFramePush externally encoded video frames

Screen capture

APIDescription
startScreenCaptureStart screen capture
stopScreenCaptureStop screen capture

Media stream transmission control

APIDescription
enableSendMediaStreamEnable or disable local media stream transmission

Video frame callbacks

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

Real-time messages

APIDescription
sendDataMsgSend a real-time data message

AoqEngineEventListener callbacks

APIDescription
onErrorEngine error callback
onWarningEngine warning callback
onConnectionStatusChangeConnection status change callback
onStatsEngine statistics callback
onAudioDeviceStateChangedAudio device operation status change callback
onAudioDeviceRouteChangedAudio output route change callback
onAudioDeviceInterruptedAudio device interruption callback
onVideoDeviceStateChangedVideo device operation status change callback
onScreenCaptureStateChangedScreen capture status change callback
onAudioFileStateAudio file playback status callback
onLocalAudioVolumeIndicationLocal capture volume indication callback
onDataMsgReceived real-time data message callback

IAudioFrameObserver callbacks

APIDescription
onCapturedAudioFrameCalled when a raw audio frame is captured. The frame contains unprocessed PCM data.
onProcessCapturedAudioFrameCalled for an audio frame after 3A processing: acoustic echo cancellation, noise suppression, and automatic gain control.
onPublishAudioFrameCalled for an audio frame before publishing. The frame will be encoded and sent to the Relay server.
onPlaybackAudioFrameCalled for a remote audio frame before playback. The frame has been decoded but not yet mixed.

IVideoFrameObserver callbacks

APIDescription
onCapturedVideoFrameCalled when a raw video frame is captured, before preprocessing. The frame comes from camera or screen capture and has not been preprocessed.
onPreEncodeVideoFrameCalled for a video frame after preprocessing and before encoding.
onRemoteVideoFrameCalled for a remote video frame after decoding and before rendering.

API details

pushExternalVideoCapturedFrame supports Video and Screen. Enable external capture on the corresponding track first; otherwise, it returns AoqECVideoExternalCaptureNotEnabled (211). pushExternalVideoEncodedFrame requires external encoding on the corresponding track; otherwise, it returns AoqECVideoExternalEncoderNotEnabled (212).

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 | null, context: common.Context): AoqClientEngine | null
ParameterTypeDescription
configAoqCreateConfigEngine creation configuration
listenerAoqEngineEventListener | nullEngine event callback listener (interface; all callbacks are optional); may be null
contextcommon.ContextUIAbility/Page context, used for aki+ACPM initialization
Returns: AoqClientEngine | null — null if native creation fails.
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

Connects to the Relay server. The AppServer sends the connection parameters to the client.
In the generic SDK API documentation, the AppServer allocates connection parameters through /api/v1/allocate. For a specific model, see Qwen-Omni-Realtime AOQ access, Qwen-Audio-Realtime AOQ access, or Qwen-LiveTranslate-Realtime AOQ access.
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.
Connection state changes are reported asynchronously via onConnectionStatusChange. It is recommended to call enableSendMediaStream(false) before calling connect.

disconnect

Disconnects from the server and releases connection resources. Returns immediately. The disconnection result is reported through onConnectionStatusChange.
disconnect(): number
Parameters: None. Return value: 0 indicates that the call has been dispatched for asynchronous execution. A nonzero value indicates failure and corresponds to AoqErrorCode. Audio and video capture/playback devices are not stopped automatically.

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

Stops audio rendering and closes the playback device.
stopAudioPlayer(): number
Parameters: None. Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

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

Audio encoding configuration

setAudioEncoderConfig

Configures audio encoding for publishing. Configuration changes take effect immediately.
setAudioEncoderConfig(config: AoqAudioCodecConfig): number
ParameterTypeDescription
configAoqAudioCodecConfigAudio encoding configuration. Set trackType to AoqTrackType.AoqTrackTypeAudio.
Return value: 0 on success; non-zero on failure (an AoqErrorCode value, such as AoqECParamInvalid for invalid parameters).
codecType specifies the encoding format (Opus by default). sampleRate and channel must match the capture settings. bitrate applies only to lossy codecs such as Opus.

setAudioDecoderConfig

Configures audio decoding for subscribed audio. The settings must match the remote encoding settings.
setAudioDecoderConfig(config: AoqAudioCodecConfig): number
ParameterTypeDescription
configAoqAudioCodecConfigAudio decoding configuration. Set trackType to AoqTrackType.AoqTrackTypeAudio.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
sampleRate must match the output sample rate of the remote encoder. A mismatch may cause decoding errors or audio quality issues.

Audio file playback

startAudioFile

Starts streaming and playing a local audio file. Remote streaming and local playback can run simultaneously, with their volumes controlled by publishVolume and playoutVolume, respectively.
startAudioFile(fileId: string, config: AoqAudioFileMixConfig): number
ParameterTypeDescription
fileIdstringApplication-defined file identifier used for subsequent control
configAoqAudioFileMixConfigAudio file playback configuration
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
Playback state changes are reported through onAudioFileState. Repeated calls with the same fileId replace the previous playback.

stopAudioFile

Stops audio file playback.
stopAudioFile(fileId: string): number
ParameterTypeDescription
fileIdstringFile identifier, matching the value passed to startAudioFile
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

pauseAudioFile

Pauses audio file playback.
pauseAudioFile(fileId: string): number
ParameterTypeDescription
fileIdstringFile identifier
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

resumeAudioFile

Resumes audio file playback. Call this method after pauseAudioFile.
resumeAudioFile(fileId: string): number
ParameterTypeDescription
fileIdstringFile identifier
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

getAudioFileDuration

Gets the total duration of an audio file.
getAudioFileDuration(fileId: string): number
ParameterTypeDescription
fileIdstringFile identifier
Return value: The total duration in milliseconds. Returns 0 if the file is not loaded or does not exist.

getAudioFileCurrentPosition

Gets the current playback position of an audio file.
getAudioFileCurrentPosition(fileId: string): number
ParameterTypeDescription
fileIdstringFile identifier
Return value: The current playback position in milliseconds. Returns 0 if the file is not loaded or does not exist.

setAudioFilePositionMillis

Sets the playback position of an audio file (seek).
setAudioFilePositionMillis(fileId: string, positionMillis: number): number
ParameterTypeDescription
fileIdstringFile identifier
positionMillisnumberTarget playback position in milliseconds
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

setAudioFileVolume

Sets the audio file volume. Streaming and local playback volumes can be controlled separately.
setAudioFileVolume(fileId: string, type: AoqAudioStreamDirection, volume: number): number
ParameterTypeDescription
fileIdstringFile identifier
typeAoqAudioStreamDirectionVolume direction. AoqAudioStreamPublish controls streaming; AoqAudioStreamPlayout controls playback.
volumenumberVolume. Valid values: 0-100.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

getAudioFileVolume

Gets the current audio file volume.
getAudioFileVolume(fileId: string, type: AoqAudioStreamDirection): number
ParameterTypeDescription
fileIdstringFile identifier
typeAoqAudioStreamDirectionVolume direction
Return value: The current volume (0-100). Returns 0 if the file does not exist.

External audio streams

addAudioExternalStream

Adds an external audio stream. Multiple independent streams can be created and distinguished by streamId.
addAudioExternalStream(streamId: string, config: AoqAudioExternalStreamConfig): number
ParameterTypeDescription
streamIdstringApplication-defined external stream identifier
configAoqAudioExternalStreamConfigExternal audio stream configuration
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

pushAudioExternalStreamData

Feeds external PCM audio data into the specified stream.
pushAudioExternalStreamData(streamId: string, data: AoqAudioFrameData): number
ParameterTypeDescription
streamIdstringExternal stream identifier
dataAoqAudioFrameDataPCM audio frame data
Return value: 0 indicates success. A nonzero value indicates failure. AoqECAudioExternalBufferFull(110) is returned when the buffer is full.
Memory referenced by data.dataPtr needs to remain valid only during the call; the SDK copies it internally. The sample rate and channel count must match the configuration passed to addAudioExternalStream.

setAudioExternalStreamVolume

Sets the external audio stream volume. Streaming and local playback volumes can be controlled separately.
setAudioExternalStreamVolume(streamId: string, type: AoqAudioStreamDirection, vol: number): number
ParameterTypeDescription
streamIdstringExternal stream identifier
typeAoqAudioStreamDirectionVolume direction
volnumberVolume. Valid values: 0-100.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

getAudioExternalStreamVolume

Gets the current external audio stream volume.
getAudioExternalStreamVolume(streamId: string, type: AoqAudioStreamDirection): number
ParameterTypeDescription
streamIdstringExternal stream identifier
typeAoqAudioStreamDirectionVolume direction
Return value: The current volume (0-100). Returns 0 if the stream does not exist.

clearAudioExternalStreamBuffer

Clears the external audio stream buffer with optional fade-out. Commonly used to interrupt current playback.
clearAudioExternalStreamBuffer(streamId: string, fadeoutMs: number): void
ParameterTypeDescription
streamIdstringExternal stream identifier
fadeoutMsnumberFade-out duration in milliseconds. -1 uses the default value, 0 clears the buffer immediately, and a value greater than 0 retains the specified duration for fade-out.
Return value: None (void).

removeAudioExternalStream

Removes an external audio stream and releases its resources.
removeAudioExternalStream(streamId: string): number
ParameterTypeDescription
streamIdstringExternal stream identifier
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

Audio frame callbacks

setAudioFrameObserver

Sets the audio frame observer. Pass observer=null to remove it.
setAudioFrameObserver(observer: IAudioFrameObserver | null): number
ParameterTypeDescription
observerIAudioFrameObserver | nullAudio frame listener. Pass null to remove it.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
Set the observer with this method first, then call enableAudioFrameObserver to enable callbacks at the required positions.

enableAudioFrameObserver

Enables or disables audio frame callbacks at the specified position.
enableAudioFrameObserver(enabled: boolean, audioSource: AoqAudioSource, config: AoqAudioObserverConfig): number
ParameterTypeDescription
enabledbooleantrue enables callbacks; false disables them.
audioSourceAoqAudioSourceAudio source position: capture, after 3A processing, publishing, or playback
configAoqAudioObserverConfigCallback configuration
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
frame.dataPtr is a Uint8Array copy of native memory and is currently read-only (ReadWrite is equivalent to ReadOnly; write-back is planned for a future release). Callbacks are dispatched asynchronously on the JS thread and can directly access ets state.

Local audio volume indication

enableLocalAudioVolumeIndication

Enables or disables local captured audio volume indications. When enabled, the SDK invokes onLocalAudioVolumeIndication at config.interval intervals to report the local captured volume and whether speech is detected.
enableLocalAudioVolumeIndication(config: AoqAudioVolumeIndicationConfig): number
ParameterTypeDescription
configAoqAudioVolumeIndicationConfigVolume indication configuration. interval<=0 disables callbacks.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
Call this method after startAudioCapture to obtain volume data. Values of interval>0 and <10 are treated as 10.

Video device management

startVideoCapture

Opens the video capture device (camera). Captured video is sent over AoqTrackType.AoqTrackTypeVideo. For external video input (pushExternalVideoCapturedFrame), set isExternal to true; the camera is not opened in this mode.
startVideoCapture(config: AoqVideoCaptureConfig): number
ParameterTypeDescription
configAoqVideoCaptureConfigVideo capture configuration.
Return value: 0 on success; non-zero on failure (an AoqErrorCode value, such as AoqECVideoDeviceCameraAuthFailed when camera permission has not been granted).
Declare ohos.permission.CAMERA in module.json5 and request permission at runtime. Device state changes are reported through onVideoDeviceStateChanged.

stopVideoCapture

Closes the video capture device and stops local video capture.
stopVideoCapture(): number
Parameters: None. Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.

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
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

Configures video encoding for publishing, routed by config.trackType. If isExternal=true, pushExternalVideoEncodedFrame sends encoded frames directly without re-encoding by the SDK.
setVideoEncoderConfig(config: AoqVideoCodecConfig): number
ParameterTypeDescription
configAoqVideoCodecConfigVideo encoding configuration.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
Before using pushExternalVideoEncodedFrame, call this method with isExternal=true. This mode bypasses the capture pipeline and does not require startVideoCapture/startScreenCapture. When using pushExternalVideoCapturedFrame, keep isExternal=false so that the SDK encodes the frames.

setVideoDecoderConfig

setVideoDecoderConfig(config: AoqVideoCodecConfig): number
config specifies video decoding settings. Only the following fields take effect: trackType, codecType, width, height, fps, bitrate. Other fields apply only to encoding. Screen does not support downstream decoding. If config.trackType is Screen, the method returns AoqECUnSupport without applying the configuration. Returns 0 on success or a nonzero value on failure.

pushExternalVideoCapturedFrame

Push an externally captured raw video frame.
pushExternalVideoCapturedFrame(trackType: AoqTrackType, frame: AoqVideoFrame): number
ParameterTypeDescription
trackTypeAoqTrackTypeAoqTrackTypeVideo. AoqTrackTypeScreen is also supported.
frameAoqVideoFrameVideo frame data
For Video, call startVideoCapture(isExternal=true) first. For Screen, call startScreenCapture(isExternal=true) first. 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. AoqTrackTypeScreen is also supported.
frameAoqVideoEncodedFrameEncoded frame data
Only consumed after setVideoEncoderConfig(isExternal=true) is configured.

Screen capture

startScreenCapture(config: AoqScreenCaptureConfig): number
stopScreenCapture(): number
config specifies screen capture settings. Screen content is sent on the AoqTrackTypeScreen track. For start, 0 means that the request is accepted; onScreenCaptureStateChanged reports the result asynchronously. A nonzero return rejects the request synchronously without a duplicate failure event. Stop returns 0 on success or a nonzero value on failure, and reports the stopped state through this callback. With isExternal=false, the SDK captures the screen and the system prompts for permission. You do not need to wait for Started before enabling transmission or producing external frames. For external raw frames, set isExternal=true and supply raw Screen frames through pushExternalVideoCapturedFrame for SDK encoding. For external encoded frames, configure the Screen track for external encoding with setVideoEncoderConfig, then call pushExternalVideoEncodedFrame; startScreenCapture is not required.

Media stream transmission 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. AoqTrackTypeScreen is also supported.
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).

Video frame callbacks

setVideoFrameObserver

Sets the video frame observer. Pass observer=null to remove it.
setVideoFrameObserver(observer: IVideoFrameObserver | null): number
ParameterTypeDescription
observerIVideoFrameObserver | nullVideo frame listener. Pass null to remove it.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
Set the observer with this method first, then call enableVideoFrameObserver to enable callbacks at the required positions.

enableVideoFrameObserver

Enables or disables video frame callbacks at the specified position.
enableVideoFrameObserver(enabled: boolean, videoSource: AoqVideoSource, config: AoqVideoObserverConfig): number
ParameterTypeDescription
enabledbooleantrue enables callbacks; false disables them.
videoSourceAoqVideoSourceVideo source position: after capture, before encoding, or after remote decoding
configAoqVideoObserverConfigCallback configuration. Use config.trackType to observe the Video or Screen track.
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
The buffers in frame are Uint8Array copies of native memory and are currently read-only. Return values are ignored, and ReadWrite is equivalent to ReadOnly. Write-back is planned for a future release.

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;
  onScreenCaptureStateChanged?: (state: AoqScreenCaptureState) => void;
  onLocalAudioVolumeIndication?: (volume: AoqAudioVolume) => void;
}

Real-time messages

sendDataMsg

Sends a real-time data message to the remote end. Call this method after connect succeeds and enableSendMediaStream(Data, true) is called.
sendDataMsg(msg: AoqDataMsg): number
ParameterTypeDescription
msgAoqDataMsgData message
Return value: 0 indicates success. A nonzero value indicates failure and corresponds to AoqErrorCode.
The remote end receives the message through onDataMsg. Message size is subject to internal SDK limits. Split oversized messages into smaller parts before sending.

AoqEngineEventListener callbacks

onError

Engine error callback. Triggered when an unrecoverable error occurs.
onError?: (code: number, message: string) => void
ParameterTypeDescription
codenumberError code corresponding to an AoqErrorCode enum value
messagestringError description
Return value: None (void).

onWarning

Engine warning callback. Triggered by recoverable exceptions that do not prevent the SDK from continuing to run.
onWarning?: (code: number, message: string) => void
ParameterTypeDescription
codenumberWarning code corresponding to an AoqWarningCode enum value
messagestringWarning description
Return value: None (void).

onConnectionStatusChange

Connection state change callback. State transitions: Disconnected → Connecting → Connected/Failed → Disconnected.
onConnectionStatusChange?: (status: AoqConnectionStatus) => void
ParameterTypeDescription
statusAoqConnectionStatusCurrent connection state
Return value: None (void).
Enable media sending with enableSendMediaStream(trackType, true) after receiving Connected.

onStats

Engine statistics callback. The SDK periodically reports audio/video publishing and subscription statistics and network statistics to monitor call quality and network conditions and diagnose audio/video issues.
onStats?: (stats: AoqStats) => void
ParameterTypeDescription
statsAoqStatsStatistics for audio/video/data message publishing and subscription, and network statistics
Return value: None (void).

onAudioDeviceStateChanged

Callback for audio device capture/playback state changes.
onAudioDeviceStateChanged?: (state: AoqAudioDeviceState) => void
ParameterTypeDescription
stateAoqAudioDeviceStateAudio device state, including state (state code) and reason (error reason)
Return value: None (void).

onAudioDeviceRouteChanged

Callback for audio output route changes.
onAudioDeviceRouteChanged?: (routeType: number) => void
ParameterTypeDescription
routeTypenumberCurrent audio output route, corresponding to an AoqAudioDeviceRouteType enum value
Return value: None (void).

onAudioDeviceInterrupted

Audio device interruption callback. Triggered by system interruptions, such as incoming calls or another application taking audio focus.
onAudioDeviceInterrupted?: (interrupt: boolean) => void
ParameterTypeDescription
interruptbooleantrue indicates interruption; false indicates recovery from interruption.
Return value: None (void).

onVideoDeviceStateChanged

Callback for video device capture state changes.
onVideoDeviceStateChanged?: (state: AoqVideoDeviceState) => void
ParameterTypeDescription
stateAoqVideoDeviceStateVideo device state, including state (state code) and reason (error reason)
Return value: None (void).

onScreenCaptureStateChanged

Reports screen capture state changes using AoqScreenCaptureStateCode and the unified AoqErrorCode. Notifications are delivered asynchronously on the JS thread. Screen capture failures are not also reported through onError.
onScreenCaptureStateChanged?: (state: AoqScreenCaptureState) => void
ParameterTypeDescription
stateAoqScreenCaptureStateScreen capture state, including state (state code) and reason (error cause).
Return value: None (void).
Started indicates that capture or external input is ready, not that media has been sent. Fail and Stopped are terminal states after cleanup.

onAudioFileState

Audio file playback state callback.
onAudioFileState?: (state: AoqAudioFileState) => void
ParameterTypeDescription
stateAoqAudioFileStateAudio file playback state, including fileId, stateCode, and errorCode
Return value: None (void).

onLocalAudioVolumeIndication

Reports the locally captured audio volume. Triggered only after volume indications are enabled through enableLocalAudioVolumeIndication.
onLocalAudioVolumeIndication?: (volume: AoqAudioVolume) => void
ParameterTypeDescription
volumeAoqAudioVolumeLocal volume information, including isSpeech (whether speech is detected) and volume (smoothed instantaneous volume [0-255]).
Return value: None (void).

onDataMsg

Callback for received real-time data messages.
onDataMsg?: (msg: AoqDataMsg) => void
ParameterTypeDescription
msgAoqDataMsgData message
Return value: None (void).
Callbacks are dispatched asynchronously on the JS thread. data is valid only during the callback. Make a copy for asynchronous use.

IAudioFrameObserver callbacks

Audio frame observer interface. All methods are optional; implement them as needed. frame.dataPtr is a Uint8Array copy of native memory and is currently read-only (ReadWrite is planned for a future release).
export interface IAudioFrameObserver {
  onCapturedAudioFrame?: (frame: AoqAudioFrameData) => void;
  onProcessCapturedAudioFrame?: (frame: AoqAudioFrameData) => void;
  onPublishAudioFrame?: (trackType: AoqTrackType, frame: AoqAudioFrameData) => void;
  onPlaybackAudioFrame?: (frame: AoqAudioFrameData) => void;
}
MethodWhen triggeredParameter
onCapturedAudioFrameWhen a raw audio frame is captured (AoqAudioSourceCaptured)frame: AoqAudioFrameData
onProcessCapturedAudioFrameAudio frame after 3A processing (AoqAudioSourceProcessCaptured)frame: AoqAudioFrameData
onPublishAudioFrameAudio frame before publishing (AoqAudioSourcePublish)trackType: track type; frame: AoqAudioFrameData
onPlaybackAudioFrameRemote audio frame before playback (AoqAudioSourcePlayback)frame: AoqAudioFrameData
Return value: None (void).
Use setAudioFrameObserver(obs) + enableAudioFrameObserver(true, src, cfg). Callbacks are dispatched asynchronously on the JS thread and can directly access ets state.

onCapturedAudioFrame

Called when a raw audio frame is captured. The frame contains unprocessed PCM data.
onCapturedAudioFrame?(frame: AoqAudioFrameData): void
ParameterTypeDescription
frameAoqAudioFrameDataCaptured audio frame data
Return value: None (void).
frame.dataPtr is a Uint8Array copy of native memory and is valid only during the callback. Copy the data before using it asynchronously.

onProcessCapturedAudioFrame

Called for an audio frame after 3A processing: acoustic echo cancellation, noise suppression, and automatic gain control.
onProcessCapturedAudioFrame?(frame: AoqAudioFrameData): void
ParameterTypeDescription
frameAoqAudioFrameDataAudio frame data after 3A processing
Return value: None (void).
frame.dataPtr is a Uint8Array copy of native memory and is valid only during the callback. Copy the data before using it asynchronously.

onPublishAudioFrame

Called for an audio frame before publishing. The frame will be encoded and sent to the Relay server.
onPublishAudioFrame?(trackType: AoqTrackType, frame: AoqAudioFrameData): void
ParameterTypeDescription
trackTypeAoqTrackTypeTrack type
frameAoqAudioFrameDataAudio frame data before publishing
Return value: None (void).
frame.dataPtr is a Uint8Array copy of native memory and is valid only during the callback. Copy the data before using it asynchronously.

onPlaybackAudioFrame

Called for a remote audio frame before playback. The frame has been decoded but not yet mixed.
onPlaybackAudioFrame?(frame: AoqAudioFrameData): void
ParameterTypeDescription
frameAoqAudioFrameDataRemote audio frame data before playback
Return value: None (void).
frame.dataPtr is a Uint8Array copy of native memory and is valid only during the callback. Copy the data before using it asynchronously.

IVideoFrameObserver callbacks

Video frame observer interface. All methods are optional and return boolean. Return values are currently ignored; data is read-only, and ReadWrite is planned for a future release. Each of the three callbacks includes trackType to distinguish Video and Screen tracks.
export interface IVideoFrameObserver {
  onCapturedVideoFrame?: (trackType: AoqTrackType, frame: AoqVideoFrame) => boolean;
  onPreEncodeVideoFrame?: (trackType: AoqTrackType, frame: AoqVideoFrame) => boolean;
  onRemoteVideoFrame?: (trackType: AoqTrackType, frame: AoqVideoFrame) => boolean;
}
MethodWhen triggeredParameter
onCapturedVideoFrameWhen a raw video frame is captured (before preprocessing, AoqVideoSourceCaptured)trackType: track type; frame: AoqVideoFrame
onPreEncodeVideoFrameVideo frame before encoding (after preprocessing, AoqVideoSourcePreEncode)trackType: track type; frame: AoqVideoFrame
onRemoteVideoFrameRemote video frame after decoding and before rendering (AoqVideoSourceRemote)trackType: track type; frame: AoqVideoFrame
Return value: boolean. true semantically indicates modified data to be written back to the SDK. The current OHOS NAPI path does not perform write-back and ignores the return value.
Use setVideoFrameObserver(obs) + enableVideoFrameObserver(true, src, cfg). The buffers in frame are Uint8Array copies of native memory and are valid only during the callback.

onCapturedVideoFrame

Called when a raw video frame is captured, before preprocessing. The frame comes from camera or screen capture and has not been preprocessed.
onCapturedVideoFrame?(trackType: AoqTrackType, frame: AoqVideoFrame): boolean
ParameterTypeDescription
trackTypeAoqTrackTypeTrack type: Video or Screen
frameAoqVideoFrameCaptured video frame data
Return value: boolean. true requests that modified data be written back to the SDK. The current OHOS NAPI path does not write data back, so true has the same effect as false. false indicates read-only access.
The buffers in frame are Uint8Array copies of native memory and are valid only during the callback. Copy the data before using it asynchronously.

onPreEncodeVideoFrame

Called for a video frame after preprocessing and before encoding.
onPreEncodeVideoFrame?(trackType: AoqTrackType, frame: AoqVideoFrame): boolean
ParameterTypeDescription
trackTypeAoqTrackTypeTrack type: Video or Screen
frameAoqVideoFrameVideo frame data before encoding
Return value: boolean. true requests that modified data be written back to the SDK. The current OHOS NAPI path does not write data back, so true has the same effect as false. false indicates read-only access.
The buffers in frame are Uint8Array copies of native memory and are valid only during the callback. Copy the data before using it asynchronously.

onRemoteVideoFrame

Called for a remote video frame after decoding and before rendering.
onRemoteVideoFrame?(trackType: AoqTrackType, frame: AoqVideoFrame): boolean
ParameterTypeDescription
trackTypeAoqTrackTypeTrack type: Video or Screen
frameAoqVideoFrameDecoded remote video frame data
Return value: boolean. true requests that modified data be written back to the SDK. The current OHOS NAPI path does not write data back, so true has the same effect as false. false indicates read-only access.
The buffers in frame are Uint8Array copies of native memory and are valid only during the callback. Copy the data before using it asynchronously.

Data types and enumerations

In v1.3.0, Index.ets exports the following enums and interfaces:
  • Enums: AoqTrackMode, AoqScreenCaptureStateCode.
  • Interfaces: AoqAudioVolumeIndicationConfig, AoqAudioVolume, AoqScreenCaptureConfig, AoqScreenCaptureState.

Common types

AoqCreateConfig

FieldTypeDefaultDescription
workDirstring""SDK working directory
enableDumpAudiobooleanfalseEnable raw audio dump (for debugging)
extrasstring""Extra parameters string
maxEncodedVideoFrameBytesnumber190 × 1024Maximum encoded frame size in bytes. Applies only to the SDK internal JPEG encoder.
enableDropOversizedVideoFramebooleanfalseFor the SDK internal JPEG encoder, whether to drop a frame that remains oversized at the lowest quality.
AoqCreateConfig on HarmonyOS does not include isBTScoMode.

AoqConnectConfig

subscribeTracks must not include AoqTrackTypeScreen; otherwise, connect returns AoqECUnSupport without starting a connection. setRemoteView also returns AoqECUnSupport for Screen.
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
routeIndexnumberRoute index. Default: -1.
tcpPortnumberDefault: 0. TCP fallback port. A value of 0 uses the SDK default port, 443.

AoqTrackParam

FieldTypeDescription
trackTypeAoqTrackTypeTrack type
trackModeAoqTrackModeDefault: AoqTrackModeSegment. Applies only to downstream audio.

Enumerations

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
AoqECScreen300General screen sharing error
AoqECScreenAuthFailed310Screen sharing permission denied
AoqECScreenStartFailed311Failed to start screen sharing

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
AoqTrackTypeScreen3Screen sharing track. Uplink only.

AoqEncoderType

Track media encoding formats.
Enum valueValueDescription
AoqEncoderTypeUnknown0Unknown format
AoqEncoderTypeAudioPCM1PCM audio
AoqEncoderTypeAudioOpus2Opus audio
AoqEncoderTypeVideoH2643H.264 video
AoqEncoderTypeVideoJpeg4JPEG video
AoqEncoderTypeDataText5Text data

AoqTrackMode

ValueNumberDescription
AoqTrackModeSegment0Segment mode: delivers data in semantic segments, such as sentences. Applies only to downstream audio.
AoqTrackModeStream1Stream mode: delivers data continuously. Applies only to downstream audio.

AoqConnectionStatus

Enum valueValueDescription
AoqConnectionStatusDisconnected0Disconnected
AoqConnectionStatusConnecting1Connecting
AoqConnectionStatusConnected2Connected
AoqConnectionStatusFailed3Connection failed

AoqMirrorMode

Mirror mode.
Enum valueValueDescription
AoqMirrorModeDisabled0Mirroring disabled
AoqMirrorModeEnabled1Mirroring enabled

AoqOrientationMode

Video orientation modes.
Enum valueValueDescription
AoqOrientationModeAuto0Automatic
AoqOrientationModePortrait1Portrait
AoqOrientationModeLandscape2Landscape

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
codecTypeAoqEncoderTypeAoqEncoderTypeAudioOpusCodec format
sampleRatenumber48000Sample rate (Hz)
channelnumber1Channel count
bitratenumber32000Bitrate (bps)

AoqAudioDeviceStateCode

Audio device capture and playback state codes.
Enum valueValueDescription
AoqAudioDeviceNone0No state
AoqAudioDeviceRecordStarting1Capture starting
AoqAudioDeviceRecordStarted2Capture started
AoqAudioDeviceRecordStopping3Capture stopping
AoqAudioDeviceRecordStopped4Capture stopped
AoqAudioDeviceRecordFail5Capture failed
AoqAudioDevicePlayStarting6Playback starting
AoqAudioDevicePlayStarted7Playback started
AoqAudioDevicePlayStopping8Playback stopping
AoqAudioDevicePlayStopped9Playback stopped
AoqAudioDevicePlayFail10Playback failed

AoqAudioDeviceState

Audio device state.
FieldTypeDefault valueDescription
stateAoqAudioDeviceStateCodeAoqAudioDeviceNoneState code
reasonnumber0Error reason code (see AoqErrorCode)

AoqAudioDeviceRouteType

Audio device route types.
Enum valueValueDescription
AoqAudioDeviceRouteDefault0Default route
AoqAudioDeviceRouteHeadset1Headset with microphone
AoqAudioDeviceRouteEarpiece2Earpiece
AoqAudioDeviceRouteHeadsetNoMic3Headset without microphone
AoqAudioDeviceRouteSpeakerPhone4Speaker
AoqAudioDeviceRouteUsb5USB audio device
AoqAudioDeviceRouteBluetooth6Bluetooth SCO mode
AoqAudioDeviceRouteBluetoothA2dp7Bluetooth A2DP mode

Audio file 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]

AoqAudioFileStateCode

Audio file state codes.
Enum valueValueDescription
AoqAudioFileNone0No state
AoqAudioFileStarted1Playback started
AoqAudioFileStopped2Playback stopped
AoqAudioFilePaused3Playback paused
AoqAudioFileResumed4Playback resumed
AoqAudioFileEnded5Playback ended
AoqAudioFileBuffering6Playback buffering
AoqAudioFileBufferingEnd7Buffering ended
AoqAudioFileFailed8Playback failed

AoqAudioFileErrorCode

Audio file error codes.
Enum valueValueDescription
AoqAudioFileNoError0No error
AoqAudioFileOpenFailed1Failed to open file
AoqAudioFileDecodeFailed2Failed to decode file

AoqAudioFileState

Audio file state.
FieldTypeDefault valueDescription
fileIdstring""File ID
stateCodeAoqAudioFileStateCodeAoqAudioFileNoneState code
errorCodeAoqAudioFileErrorCodeAoqAudioFileNoErrorError code

External audio stream and volume types

AoqAudioStreamDirection

External audio stream directions.
Enum valueValueDescription
AoqAudioStreamPublish0Publishing stream
AoqAudioStreamPlayout1Playback stream

AoqAudioExternalStreamToggle

External audio stream toggle states.
Enum valueValueDescription
AoqAudioExternalStreamToggleNormal0Normal state
AoqAudioExternalStreamTogglePause1Paused state

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

AoqAudioSource

Audio frame callback data sources.
Enum valueValueDescription
AoqAudioSourceCaptured0Captured audio data
AoqAudioSourceProcessCaptured1Audio data after 3A processing
AoqAudioSourcePublish2Published audio data
AoqAudioSourcePlayback3Playback audio data

AoqAudioObserverMode

Audio frame callback modes.
Enum valueValueDescription
AoqAudioObserverModeReadOnly0Read-only mode
AoqAudioObserverModeReadWrite1Read-write mode (the current OHOS NAPI path does not perform write-back and behaves as ReadOnly)

AoqAudioObserverConfig

FieldTypeDefaultDescription
sampleRatenumber48000Callback sample rate
channelsnumber1Callback channel count
modeAoqAudioObserverModeReadOnlyRead/write mode

AoqAudioVolumeIndicationConfig

FieldTypeDefaultDescription
reportSpeechbooleanfalseWhether to detect speech.
intervalnumber0Callback interval in milliseconds. Values of 0 or less disable callbacks; values between 0 and 10 use 10.
smoothnumber3Smoothing factor, from 0 to 10. Higher values produce smoother results.

AoqAudioVolume

FieldTypeDescription
isSpeechbooleanWhether speech is detected.
volumenumberSmoothed instantaneous volume, from 0 to 255.

Video types

AoqRenderMode

Rendering modes.
Enum valueValueDescription
AoqRenderModeAuto0Automatic mode
AoqRenderModeStretch1Stretch mode. The image may be distorted.
AoqRenderModeFill2Letterbox mode. The entire image is preserved.
AoqRenderModeCrop3Crop mode. Part of the image may be lost.

AoqVideoCanvas

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

AoqCameraDirection

Camera direction.
Enum valueValueDescription
AoqCameraDirectionFront0Front camera
AoqCameraDirectionBack1Rear camera

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

AoqScreenCaptureConfig

FieldTypeDefaultDescription
isExternalbooleanfalseWhether the application supplies raw screen frames.

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

AoqVideoCodecType

Codec type for externally encoded frames.
Enum valueValueDescription
AoqVideoCodecTypeJPEG0JPEG encoding

AoqVideoEncodedFrame

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

AoqVideoCodecConfig

FieldTypeDefaultDescription
trackTypeAoqTrackTypeAoqTrackTypeVideoTarget track
codecTypeAoqEncoderTypeAoqEncoderTypeVideoH264Codec format
widthnumber540Encoding width
heightnumber960Encoding height
fpsnumber5Frame rate
bitratenumber500000Bitrate (bps)
minBitratenumber128000Minimum bitrate (bps)
keyframeIntervalnumber2Keyframe interval (seconds)
mirrorModeAoqMirrorModeDisabledMirror mode
orientationModeAoqOrientationModeAutoVideo orientation
isExternalbooleanfalsetrue: the SDK skips re-encoding

AoqVideoDeviceStateCode

Video device capture state codes.
Enum valueValueDescription
AoqVideoDeviceNone0No state
AoqVideoDeviceCaptureStarting1Camera starting
AoqVideoDeviceCaptureStarted2Camera started
AoqVideoDeviceCaptureStopping3Camera stopping
AoqVideoDeviceCaptureStopped4Camera stopped
AoqVideoDeviceCaptureFail5Camera startup failed

AoqVideoDeviceState

Video device state.
FieldTypeDefault valueDescription
stateAoqVideoDeviceStateCodeAoqVideoDeviceNoneState code
reasonnumber0Error reason code (see AoqErrorCode)

AoqScreenCaptureStateCode

ValueNumberDescription
AoqScreenCaptureNone0None
AoqScreenCaptureStarting1Starting
AoqScreenCaptureStarted2Input ready; does not indicate transmission
AoqScreenCaptureStopping3Stopping
AoqScreenCaptureStopped4Stopped
AoqScreenCaptureFail5Start or runtime failure

AoqScreenCaptureState

FieldTypeDefaultDescription
stateAoqScreenCaptureStateCode—Screen capture state.
reasonnumber—0 for normal states; an AoqErrorCode on failure.

Video frame callback types

AoqVideoSource

Video frame callback data sources (pipeline positions).
Enum valueValueDescription
AoqVideoSourceCaptured0Video data after capture (before preprocessing)
AoqVideoSourcePreEncode1Video data before encoding (after preprocessing)
AoqVideoSourceRemote2Remote video data after decoding and before rendering

AoqVideoObserverMode

Video frame callback modes.
Enum valueValueDescription
AoqVideoObserverModeReadOnly0Read-only mode
AoqVideoObserverModeReadWrite1Read-write mode (the current OHOS NAPI path does not perform write-back and behaves as ReadOnly)

AoqVideoObserverAlignment

Video output width alignment.
Enum valueValueDescription
AoqVideoObserverAlignmentDefault0Default alignment
AoqVideoObserverAlignmentEven1Even alignment
AoqVideoObserverAlignment424-byte alignment
AoqVideoObserverAlignment838-byte alignment
AoqVideoObserverAlignment16416-byte alignment

AoqVideoObserverConfig

FieldTypeDefaultDescription
formatAoqVideoPixelFormatI420Callback pixel format
alignmentAoqVideoObserverAlignmentDefaultWidth alignment
modeAoqVideoObserverModeReadOnlyRead/write mode
mirrorAppliedbooleanfalseWhether to apply mirroring
trackTypeAoqTrackTypeAoqTrackTypeVideoVideo track to observe. Supports Video and Screen only.

Data message types

AoqDataMsg

Real-time message data structure.
FieldTypeDefault valueDescription
dataArrayBuffer / Uint8ArrayRequiredMessage data

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

AoqAudioPublishStats

Audio publishing statistics.
FieldTypeDescription
trackTypenumberTrack type (corresponding to AoqTrackType)
bitratenumberBitrate in bps
bytesnumberTotal bytes sent
encodeVolumenumberPublishing encoding volume

AoqVideoPublishStats

Video publishing statistics.
FieldTypeDescription
trackTypenumberTrack type (corresponding to AoqTrackType)
bitratenumberBitrate in bps
bytesnumberTotal bytes sent
encodeFpsnumberEncoding frame rate

AoqDataMsgPublishStats

Data message publishing statistics.
FieldTypeDescription
trackTypenumberTrack type (corresponding to AoqTrackType)
bitratenumberBitrate in bps
bytesnumberTotal bytes sent

AoqAudioSubscribeStats

Audio subscription statistics.
FieldTypeDescription
trackTypenumberTrack type (corresponding to AoqTrackType)
bitratenumberBitrate in bps
bytesnumberTotal bytes received
playVolumenumberPlayback volume

AoqVideoSubscribeStats

Video subscription statistics.
FieldTypeDescription
trackTypenumberTrack type (corresponding to AoqTrackType)
bitratenumberBitrate in bps
bytesnumberTotal bytes received
decodeFpsnumberDecoding frame rate
renderFpsnumberRendering frame rate

AoqDataMsgSubscribeStats

Data message subscription statistics.
FieldTypeDescription
trackTypenumberTrack type (corresponding to AoqTrackType)
bitratenumberBitrate in bps
bytesnumberTotal bytes received

AoqNetworkStats

Network statistics.
FieldTypeDescription
sendBitratenumberSend bitrate in bps
sendBytesnumberTotal bytes sent
recvBitratenumberReceive bitrate in bps
recvBytesnumberTotal bytes received
lossnumberPacket loss rate (0-100)
rttnumberRound-trip latency in milliseconds