Skip to main content

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

Parameter

Type

Description

config

AoqCreateConfig

Engine creation configuration

listener

AoqEngineEventListener | null

Engine event callback listener (interface; all callbacks are optional); may be null

context

common.Context

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

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

Parameter

Type

Description

config

AoqConnectConfig

Connection 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

Parameter

Type

Description

config

AoqAudioCaptureConfig

Capture 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

Parameter

Type

Description

mute

boolean

true: mute; false: unmute

startAudioPlayer

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

Parameter

Type

Description

config

AoqAudioPlaybackConfig

Playback 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

Parameter

Type

Description

fadeMs

number

Fade-out duration (milliseconds); 0 means immediate

resumeAudioPlayer

Resume audio playback with an optional fade-in for a smooth transition.
resumeAudioPlayer(fadeMs: number): number

Parameter

Type

Description

fadeMs

number

Fade-in duration (milliseconds); 0 means immediate

interruptAudioPlayer

Interrupt the current audio call turn.
interruptAudioPlayer(trackType: AoqTrackType, fadeMs: number): number

Parameter

Type

Description

trackType

AoqTrackType

Target track type; typically AoqTrackTypeAudio

fadeMs

number

Fade-out duration (milliseconds)

enableSpeakerphone

Switch the audio output route between the speaker and the earpiece.
enableSpeakerphone(enable: boolean): number

Parameter

Type

Description

enable

boolean

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

Parameter

Type

Description

direction

AoqCameraDirection

AoqCameraDirectionFront or AoqCameraDirectionBack

setLocalView

Set or remove the local video rendering view.
setLocalView(trackType: AoqTrackType, canvas: AoqVideoCanvas | null): number

Parameter

Type

Description

trackType

AoqTrackType

AoqTrackTypeVideo

canvas

AoqVideoCanvas | null

Rendering 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

Parameter

Type

Description

trackType

AoqTrackType

AoqTrackTypeVideo

canvas

AoqVideoCanvas | null

Rendering 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

Parameter

Type

Description

trackType

AoqTrackType

AoqTrackTypeVideo

; AoqTrackTypeScreen is also supported

frame

AoqVideoFrame

Video 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

Parameter

Type

Description

trackType

AoqTrackType

AoqTrackTypeVideo

; AoqTrackTypeScreen is also supported

frame

AoqVideoEncodedFrame

Encoded 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

Parameter

Type

Description

trackType

AoqTrackType

AoqTrackTypeAudio or AoqTrackTypeVideo

; also supports AoqTrackTypeScreen

enable

boolean

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

Field

Type

Default

Description

workDir

string

""

SDK working directory

enableDumpAudio

boolean

false

Enable raw audio dump (for debugging)

extras

string

""

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.

Field

Type

Default

Description

token

string

""

Authentication token

sid

string

""

Session ID

certFingerprint

string

""

Server certificate fingerprint

relayEndpoints

AoqRelayEndpoint[]

[]

List of Relay endpoints

workspaceIdHash

string

""

Workspace ID hash

publishTracks

AoqTrackParam[]

[]

Local tracks to publish

subscribeTracks

AoqTrackParam[]

[]

Remote tracks to subscribe to

AoqRelayEndpoint

Field

Type

Description

endpoint

string

Relay server hostname or IP

port

number

Relay server port

routeIndexnumberRoute index. Default: -1.
tcpPortnumberDefault: 0. TCP fallback port. A value of 0 uses the SDK default port, 443.

AoqTrackParam

Field

Type

Description

trackType

AoqTrackType

Track type

trackModeAoqTrackModeDefault: AoqTrackModeSegment. Applies only to downstream audio.

Enumerations

AoqErrorCode

Enum value

Value

Description

AoqECOK

0

Success

AoqECParamInvalid

1

Invalid parameter

AoqECStateInvalid

2

Invalid state

AoqECUnSupport

3

Not supported

AoqECAudio

100

Audio generic error

AoqECAudioExternalBufferFull

110

External audio buffer full

AoqECAudioDevice

120

Audio device generic error

AoqECAudioDeviceRecordingAuthFailed

121

Recording permission not granted

AoqECAudioDeviceRecordingOccupied

122

Recording device in use

AoqECAudioDeviceRecordingBackgroundStart

123

Failed to start recording in background

AoqECAudioDeviceRecordingStartFail

124

Recording start failed

AoqECAudioDevicePlayoutOccupied

125

Playback device in use

AoqECAudioDevicePlayoutBackgroundStart

126

Failed to start playback in background

AoqECAudioDevicePlayoutStartFail

127

Playback start failed

AoqECAudioDeviceEarpieceRequiresVoipMode

128

Earpiece requires VoIP mode

AoqECVideo

200

Video generic error

AoqECVideoExternalBufferFull

210

External video buffer full

AoqECVideoExternalCaptureNotEnabled

211

External video capture not enabled

AoqECVideoExternalEncoderNotEnabled

212

External video encoder not enabled

AoqECVideoDevice

220

Video device generic error

AoqECVideoDeviceCameraOpenFail

221

Camera open failed

AoqECVideoDeviceCameraAuthFailed

222

Camera permission not granted

AoqECVideoDeviceCameraOccupied

223

Camera in use

AoqECVideoDeviceCameraRunningError

224

Camera runtime error

AoqECVideoCodec

230

Video codec generic error

AoqECVideoCodecEncoderInitFail

231

Video encoder initialization failed

AoqECVideoRender

240

Video rendering generic error

AoqECVideoRenderCreateFail

241

Video renderer creation failed

AoqECVideoRenderDrawError

242

Video rendering draw error

AoqECScreen300General screen sharing error
AoqECScreenAuthFailed310Screen sharing permission denied
AoqECScreenStartFailed311Failed to start screen sharing

AoqWarningCode

Enum value

Value

Description

AoqWCOK

0

No warning

AoqWCAudio

100

Audio generic warning

AoqWCAudioHowling

101

Audio howling detected

AoqWCAudioDevice

120

Audio device generic warning

AoqWCAudioDeviceMicEnumerateError

121

Microphone enumeration error

AoqWCAudioDeviceMicStartTimeout

122

Microphone start timeout

AoqWCAudioDeviceRecordingError

123

Recording error

AoqWCAudioDeviceSpeakerEnumerateError

124

Speaker enumeration error

AoqWCAudioDeviceSpeakerStartTimeout

125

Speaker start timeout

AoqWCAudioDevicePlayoutError

126

Playback error

AoqWCVideo

200

Video generic warning

AoqWCVideoCameraEnumerateError

201

Camera enumeration error

AoqWCVideoEncoderSwitched

202

Video encoder switched

AoqWCVideoRenderDowngrade

203

Video rendering downgraded

AoqTrackType

Enum value

Value

Description

AoqTrackTypeAudio

0

Audio track

AoqTrackTypeVideo

1

Video track

AoqTrackTypeData

2

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

Value

Description

AoqConnectionStatusDisconnected

0

Disconnected

AoqConnectionStatusConnecting

1

Connecting

AoqConnectionStatusConnected

2

Connected

AoqConnectionStatusFailed

3

Connection failed

AoqMirrorMode

Mirror mode.
Enum valueValueDescription
AoqMirrorModeDisabled0Mirroring disabled
AoqMirrorModeEnabled1Mirroring enabled

AoqOrientationMode

Video orientation modes.
Enum valueValueDescription
AoqOrientationModeAuto0Automatic
AoqOrientationModePortrait1Portrait
AoqOrientationModeLandscape2Landscape

Audio types

AoqAudioCaptureConfig

Field

Type

Default

Description

isExternal

boolean

false

true: use external audio input

isVoipMode

boolean

false

true: enable VoIP mode (hardware AEC)

channel

number

1

Channel count: 1 or 2

AoqAudioPlaybackConfig

Field

Type

Default

Description

isVoipMode

boolean

false

true: enable VoIP mode (hardware AEC); first-write-wins between capture and playback config

isDefaultSpeaker

boolean

true

true: default to speaker; false: default to earpiece

isExternal

boolean

false

true: use external audio output

channel

number

1

Channel count: 1 or 2

AoqAudioCodecConfig

Field

Type

Default

Description

trackType

AoqTrackType

AoqTrackTypeAudio

Target track

codecType

AoqEncoderType

AoqEncoderTypeAudioOpus

Codec format

sampleRate

number

48000

Sample rate (Hz)

channel

number

1

Channel count

bitrate

number

32000

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

Field

Type

Default

Description

fileName

string

""

File name (including path)

cycles

number

-1

Loop count; -1 means loop indefinitely

startPosMs

number

0

Starting playback position (ms)

publishVolume

number

100

Publishing volume [0, 100]

playoutVolume

number

100

Local 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

Field

Type

Default

Description

trackType

AoqTrackType

AoqTrackTypeAudio

Track type

codecType

AoqEncoderType

AoqEncoderTypeAudioPCM

Audio format

channels

number

1

Channel count

sampleRate

number

48000

Sample rate (Hz)

playoutVolume

number

100

Playback volume [0, 100]

publishVolume

number

100

Publishing volume [0, 100]

maxBufferDuration

number

1000

Maximum buffer duration (ms)

enable3A

boolean

false

Whether to apply 3A processing to input PCM

AoqAudioFrameData

Field

Type

Description

dataPtr

ArrayBuffer | Uint8Array | null

Raw PCM audio data

dataSize

number

PCM data size (bytes)

numOfSamples

number

Sample count (mono)

bytesPerSample

number

Bytes per sample

numOfChannels

number

Channel count

samplesPerSec

number

Sample rate

pushSequence

number

PCM push sequence number

timeStamp

number

Timestamp

autoGenMute

boolean

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

Field

Type

Default

Description

sampleRate

number

48000

Callback sample rate

channels

number

1

Callback channel count

mode

AoqAudioObserverMode

ReadOnly

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

Field

Type

Default

Description

view

Object | null

null

AoqXComponentController instance; pass null to remove the rendering binding

renderMode

AoqRenderMode

AoqRenderModeAuto

Display mode

AoqCameraDirection

Camera direction.
Enum valueValueDescription
AoqCameraDirectionFront0Front camera
AoqCameraDirectionBack1Rear camera

AoqVideoCaptureConfig

Field

Type

Default

Description

width

number

1280

Capture width; ignored when isExternal=true

height

number

720

Capture height

fps

number

15

Capture frame rate

isExternal

boolean

false

true: do not open the camera; provide frames via pushExternalVideoCapturedFrame

cameraDirection

AoqCameraDirection

Front

Camera direction

AoqScreenCaptureConfig

FieldTypeDefaultDescription
isExternalbooleanfalseWhether the application supplies raw screen frames.

AoqVideoPixelFormat

Enum value

Value

Description

AoqVideoPixelFormatUnknown

0

Unknown

AoqVideoPixelFormatI420

1

I420

AoqVideoPixelFormatNV12

2

NV12

AoqVideoPixelFormatNV21

3

NV21

AoqVideoPixelFormatBGRA

4

BGRA

AoqVideoPixelFormatRGBA

5

RGBA

TextureOES and Texture2D are not supported on HarmonyOS.

AoqVideoFrame

Field

Type

Description

format

AoqVideoPixelFormat

Pixel format

width

number

Width (pixels)

height

number

Height (pixels)

dataPtr

ArrayBuffer | Uint8Array | null

Packed format data

dataSize

number

Packed data size (bytes)

dataY / dataU / dataV

ArrayBuffer | Uint8Array | null

I420 planes

strideY / strideU / strideV

number

Plane stride

timeStamp

number

Timestamp (ms); when 0, the SDK uses the local clock

AoqVideoCodecType

Codec type for externally encoded frames.
Enum valueValueDescription
AoqVideoCodecTypeJPEG0JPEG encoding

AoqVideoEncodedFrame

Field

Type

Description

codec

AoqVideoCodecType

Encoding format (AoqVideoCodecTypeJPEG = 0)

data

ArrayBuffer | Uint8Array

Encoded frame data

width

number

Width

height

number

Height

timeStamp

number

Timestamp (ms)

AoqVideoCodecConfig

Field

Type

Default

Description

trackType

AoqTrackType

AoqTrackTypeVideo

Target track

codecType

AoqEncoderType

AoqEncoderTypeVideoH264

Codec format

width

number

540

Encoding width

height

number

960

Encoding height

fps

number

5

Frame rate

bitrate

number

500000

Bitrate (bps)

minBitrate

number

128000

Minimum bitrate (bps)

keyframeInterval

number

2

Keyframe interval (seconds)

mirrorMode

AoqMirrorMode

Disabled

Mirror mode

orientationMode

AoqOrientationMode

Auto

Video orientation

isExternal

boolean

false

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

Field

Type

Default

Description

format

AoqVideoPixelFormat

I420

Callback pixel format

alignment

AoqVideoObserverAlignment

Default

Width alignment

mode

AoqVideoObserverMode

ReadOnly

Read/write mode

mirrorApplied

boolean

false

Whether 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

Field

Type

Description

audioPublishStats

AoqAudioPublishStats[]

Audio publish statistics

videoPublishStats

AoqVideoPublishStats[]

Video publish statistics

dataMsgPublishStats

AoqDataMsgPublishStats[]

Data message publish statistics

audioSubscribeStats

AoqAudioSubscribeStats[]

Audio subscribe statistics

videoSubscribeStats

AoqVideoSubscribeStats[]

Video subscribe statistics

dataMsgSubscribeStats

AoqDataMsgSubscribeStats[]

Data message subscribe statistics

networkStats

AoqNetworkStats | null

Network 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
Text Generation
Image Generation
Video Generation
World models
Audio
  • Audio generation
Text Embedding
Decision Model
TokenPlan
Model Production