Skip to main content
AOQ SDK

AOQ Client SDK Electron API reference

This topic describes the TypeScript APIs, events, and data types of AOQ Client SDK for Electron. The SDK supports macOS x64/arm64 and Windows x64 and requires Node.js 16 or later.

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.
Applicable package: aoq-electron-sdk (npm). Supported platforms: macOS (x64 / arm64) and Windows x64. Node.js >= 16.

API index

Engine entry points and lifecycle

APIDescription
createAoqClientEngineGet the engine wrapper instance (module-level lazy singleton)
createEngineCreate the native engine instance
destroyDestroy the engine instance
getVersionGet the SDK version
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

Audio codec configuration

APIDescription
setAudioEncoderConfigSet audio encoding parameters
setAudioDecoderConfigSet audio decoding parameters

Video device management

APIDescription
startVideoCaptureOpen the video capture device (camera)
stopVideoCaptureClose the video capture device

Video codec configuration 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
getScreenSourceListGet the list of shareable desktops and windows
startScreenCaptureStart screen capture
stopScreenCaptureStop screen capture

Media stream transmission control

APIDescription
enableSendMediaStreamEnable or disable local media stream transmission

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

Real-time messages

APIDescription
sendDataMsgSend a real-time data message

Audio frame callbacks

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

Local audio volume indication

APIDescription
enableLocalAudioVolumeIndicationEnable or disable local capture volume indication callbacks

Video frame callbacks

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

Video rendering (YUVCanvasRenderer)

APIDescription
bindBind a canvas element
unbindUnbind the canvas and clear its contents
boundCheck whether a canvas is bound
drawFrameRender an I420 video frame

Engine events (IAoqEngineEvents)

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
onAudioFileStateAudio file playback status callback
onLocalAudioVolumeIndicationLocal capture volume indication callback
onVideoDeviceStateChangedVideo device operation status change callback
onDataMsgReceived real-time data message callback

Audio frame events

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.

Video frame events

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

Engine entry points and lifecycle

createAoqClientEngine

Gets the engine wrapper instance. It is a module-level lazily initialized singleton. Calling this method again returns the same instance, which aligns with the singleton semantics of the native engine. It is also the default export of the package.
import createAoqClientEngine from 'aoq-electron-sdk';
export function createAoqClientEngine(): IAoqClientEngine
Returns: The IAoqClientEngine engine instance. Note that this method creates only the JS wrapper layer and the native bridge. To actually create the engine, you must also call createEngine().

createEngine

Creates the native engine instance. The engine is a global singleton, so calling this method again returns success directly.
createEngine(config: AoqCreateConfig): number
ParametersTypeDescription
configAoqCreateConfigEngine creation configuration
Returns: 0 on success; -1 indicates that the creation failed or that the parameter is not valid JSON.
On Windows, createEngine() attaches a 16 ms Win32 message pump to the libuv loop of the current JS thread (required for camera capture), and stops it on destroy(). Therefore, do not synchronously block the JS thread for a long time after createEngine().

destroy

Destroys the engine instance and releases all resources.
destroy(): number
Returns: 0 indicates success; non-0 indicates a failure. If the engine is not created, 0 is returned.

getVersion

Gets the current SDK version. You do not need to call createEngine() first.
getVersion(): string
Returns: The version string, such as "1.2.0". An empty string is returned if the version cannot be obtained.

connect

Connects to the relay server. The application server obtains temporary AOQ connection parameters based on the protocol in use and sends them to the client. For more information, see Token authentication.
connect(config: AoqConnectConfig): number
ParametersTypeDescription
configAoqConnectConfigConnection configuration, which includes the token, SID, the list of relay access points, and the lists of publishing and subscribing tracks
Returns: 0 indicates that the call is dispatched and runs asynchronously; non-0 indicates that parameter validation failed. The connection result is notified by the onConnectionStatusChange event.

disconnect

Disconnects from the server and releases the resources associated with the connection.
disconnect(): number
Returns: 0 indicates that the call is dispatched and runs asynchronously; non-0 indicates a failure.

Audio device management

startAudioCapture

startAudioCapture(config: AoqAudioCaptureConfig): number
Opens the audio capture device (microphone). The first capture triggers a system authorization request. On macOS, you must declare NSMicrophoneUsageDescription in the Info.plist file of the application.

stopAudioCapture

stopAudioCapture(): number
Closes the audio capture device.

muteAudioCapture

muteAudioCapture(mute: boolean): number
Mutes or unmutes audio capture. mute=true mutes, and false unmutes.

startAudioPlayer

startAudioPlayer(config: AoqAudioPlaybackConfig): number
Starts audio rendering to play remote audio.

stopAudioPlayer / pauseAudioPlayer / resumeAudioPlayer

stopAudioPlayer(): number
pauseAudioPlayer(fadeMs: number): number
resumeAudioPlayer(fadeMs: number): number
fadeMs: the fade-out or fade-in duration, in milliseconds. 0 indicates immediate execution.

interruptAudioPlayer

interruptAudioPlayer(trackType: AoqTrackType, fadeMs: number): number
Interrupts the current audio session and discards the buffered downlink data of the current session.
ParametersTypeDescription
trackTypeAoqTrackTypeTrack type
fadeMsnumberFade-out duration, in milliseconds

Audio codec configuration

setAudioEncoderConfig(config: AoqAudioCodecConfig): number
setAudioDecoderConfig(config: AoqAudioCodecConfig): number
We recommend that you call this method before connect(). To use Opus (AoqEncoderTypeAudioOpus), the PluginOpus plug-in must be built into the SDK or distributed with the package.

Video device management

startVideoCapture(config: AoqVideoCaptureConfig): number
stopVideoCapture(): number
Opens or closes the video capture device. On macOS, you must declare NSCameraUsageDescription in Info.plist. When config.isExternal=true, the camera is not opened, and frames are delivered by pushExternalVideoCapturedFrame.
The Electron renderer is a Chromium environment and cannot embed native views, so setLocalView / setRemoteView / switchCamera are not provided. For preview, use the frame observer with YUVCanvasRenderer (see 2.13).

Video codec configuration and external input

setVideoEncoderConfig(config: AoqVideoCodecConfig): number
setVideoDecoderConfig(config: AoqVideoCodecConfig): number
pushExternalVideoCapturedFrame(meta: AoqExternalVideoFrameMeta, buffer: Uint8Array): number
pushExternalVideoEncodedFrame(meta: AoqExternalVideoEncodedFrameMeta, buffer: Uint8Array): number
ParametersTypeDescription
metaAoqExternalVideoFrameMeta / AoqExternalVideoEncodedFrameMetaFrame metadata (dimensions, format, and timestamp)
bufferUint8ArrayFrame data (pixel data or encoded data)
  • pushExternalVideoCapturedFrame consumes Video frames after startVideoCapture({ isExternal: true }) and Screen frames after startScreenCapture({ isExternal: true }). It returns 211 when external capture is not enabled and 210 when the buffer is full.
  • AoqVideoPixelFormatI420 and packed formats (NV12 / NV21 / BGRA / RGBA) are supported. For I420, buffer must use a compact layout (stride = width), with the Y / U / V planes concatenated in order.
  • pushExternalVideoEncodedFrame requires setVideoEncoderConfig({ isExternal: true }) first. It returns 212 when it is not enabled. Only JPEG is currently supported.
  • When meta.timeStamp is 0, the SDK fills it in with the local time.

Screen capture

startScreenCapture(config: AoqScreenCaptureConfig): number
stopScreenCapture(): number
config specifies screen capture settings. Screen content is sent on the AoqTrackTypeScreen track. Returns 0 on success or a nonzero value on failure. Call getScreenSourceList to enumerate screens and windows, then pass the selected sourceId and sourceType in the capture configuration. 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.

getScreenSourceList

getScreenSourceList(): AoqScreenSourceInfo[]
Returns an array of screen sources. Available on Electron macOS and Windows only.

Media stream transmission control

enableSendMediaStream(trackType: AoqTrackType, enable: boolean): number
trackType supports AoqTrackTypeAudio, AoqTrackTypeVideo, and AoqTrackTypeScreen. Specifies whether to send a specific local media stream. We recommend that you call enableSendMediaStream(trackType, false) after initialization and enable sending only after onConnectionStatusChange reports AoqConnectionStatusConnected.

Audio file playback

startAudioFile(config: AoqAudioFileMixConfig): number
stopAudioFile(fileId: string): number
pauseAudioFile(fileId: string): number
resumeAudioFile(fileId: string): number
getAudioFileDuration(fileId: string): number
getAudioFileCurrentPosition(fileId: string): number
setAudioFilePositionMillis(fileId: string, positionMs: number): number
setAudioFileVolume(fileId: string, type: AoqAudioStreamDirection, volume: number): number
getAudioFileVolume(fileId: string, type: AoqAudioStreamDirection): number
ParametersTypeDescription
configAoqAudioFileMixConfigFile mixing configuration. fileId is carried as a configuration field.
fileIdstringFile identifier, which is defined by the caller. Subsequent API calls use it to locate the file.
positionMsnumberTarget playback position, in milliseconds
typeAoqAudioStreamDirectionPublishing volume or local playback volume
volumenumberVolume. Valid values: 0 to 100.
Description of the return value:
  • getAudioFileDuration / getAudioFileCurrentPosition return the number of milliseconds;
  • getAudioFileVolume returns the current volume;
  • The getters above return -1 when the engine is not created.
Playback state changes are reported through the onAudioFileState event.

External audio streams

addAudioExternalStream(config: AoqAudioExternalStreamConfig): number
removeAudioExternalStream(streamId: string): number
pushAudioExternalStreamData(meta: AoqAudioExternalFrameMeta, buffer: Uint8Array): number
setAudioExternalStreamVolume(streamId: string, type: AoqAudioStreamDirection, volume: number): number
getAudioExternalStreamVolume(streamId: string, type: AoqAudioStreamDirection): number
clearAudioExternalStreamBuffer(streamId: string, fadeoutMs: number): number
ParametersTypeDescription
configAoqAudioExternalStreamConfigExternal audio stream configuration. streamId is carried as a configuration field.
streamIdstringStream identifier, which is defined by the caller
metaAoqAudioExternalFrameMetaPCM frame metadata. streamId is carried as a metadata field.
bufferUint8ArrayPCM data
fadeoutMsnumberFade-out duration when the buffer is cleared, in milliseconds
  • pushAudioExternalStreamData returns 110 (external audio buffer is full) when the buffered duration exceeds maxBufferDuration.
  • getAudioExternalStreamVolume returns the current volume. It returns -1 when the engine is not created.
  • clearAudioExternalStreamBuffer has no return value on the native side and always returns 0 on a successful call.

Real-time messages

sendDataMsg(data: Uint8Array | string): number
Sends a real-time data message. If you pass a string, it is encoded in UTF-8 into a Buffer internally before it is sent. Messages from the peer are reported through the onDataMsg event callback.

Audio frame callbacks

setAudioFrameObserver(enable: boolean): number
enableAudioFrameObserver(params: AoqAudioObserverParams): number
ParametersTypeDescription
enablebooleantrue registers the built-in audio frame observer; false unregisters it
paramsAoqAudioObserverParamsSpecify the callback position, on/off state, and callback format
Usage: First, call setAudioFrameObserver(true) to register the observer. Then, call enableAudioFrameObserver for each position that you need. The data is delivered through the corresponding events.
engine.setAudioFrameObserver(true)
engine.enableAudioFrameObserver({
  enabled: true,
  audioSource: AoqAudioSource.AoqAudioSourceCaptured,
  sampleRate: 48000,
  channels: 1
})
engine.on('onCapturedAudioFrame', (frame) => { /* frame.buffer contains PCM data */ })
The frame observer on the Electron side supports only read-only mode and does not support writing frame data back in the callback (the native side is fixed to ReadOnly).

Local audio volume indication

enableLocalAudioVolumeIndication(config: AoqAudioVolumeIndicationConfig): number
Enables or disables local capture volume indication. If config.interval <= 0, the callback is disabled. After it is enabled, onLocalAudioVolumeIndication is triggered at the interval specified by config.interval. You must call this method after startAudioCapture() to obtain volume data.

Video frame callbacks

setVideoFrameObserver(enable: boolean): number
enableVideoFrameObserver(params: AoqVideoObserverParams): number
ParametersTypeDescription
enablebooleantrue registers the built-in video frame observer; false unregisters it
paramsAoqVideoObserverParamsSpecify the callback position, on/off state, pixel format, and alignment policy
The callback data is delivered as AoqVideoFrameEvent through onCapturedVideoFrame / onPreEncodeVideoFrame / onRemoteVideoFrame. For I420, buffer is the Y / U / V planes concatenated based on stride. Other packed formats are passed through as the original data. Only read-only mode is supported as well.

Video rendering (YUVCanvasRenderer)

The software renderer built into the SDK.
import { YUVCanvasRenderer } from 'aoq-electron-sdk';

class YUVCanvasRenderer {
  bind(canvas: HTMLCanvasElement): void
  unbind(): void
  get bound(): boolean
  drawFrame(frame: AoqVideoFrameEvent): void
}
APIDescription
bindBind a canvas (binding again replaces the sink)
unbindUnbind and clear the image
boundSpecifies whether a binding is established
drawFrameDraw one frame; only I420 is supported, and the method returns silently for non-I420 formats or when the size or buffer length is insufficient
const renderer = new YUVCanvasRenderer()
renderer.bind(document.getElementById('preview'))

engine.setVideoFrameObserver(true)
engine.enableVideoFrameObserver({
  enabled: true,
  videoSource: AoqVideoSource.AoqVideoSourceCaptured,
  format: AoqVideoPixelFormat.AoqVideoPixelFormatI420
})
engine.on('onCapturedVideoFrame', (frame) => renderer.drawFrame(frame))
For the rendering fill mode (such as stretch or crop), use the CSS object-fit property to control the canvas.

Engine events (IAoqEngineEvents)

The engine inherits from EventEmitter<IAoqEngineEvents>. Events are the unified exit for all asynchronous notifications from the SDK and map one-to-one to the native AoqEngineEventListener callbacks. You do not need to register the events that you do not care about.
engine.on('onError', (code, message) => {})
engine.off('onError', handler)
engine.once('onStats', (stats) => {})
engine.removeAllListeners()

onError

onError: (code: number, message: string) => void
Engine error callback. code corresponds to an AoqErrorCode value (see 3.3).

onWarning

onWarning: (code: number, message: string) => void
Engine warning callback. code corresponds to an AoqWarningCode value (see 3.3).

onConnectionStatusChange

onConnectionStatusChange: (status: AoqConnectionStatus) => void
Connection status change callback. State transitions: Disconnected -> Connecting -> Connected / Failed -> Disconnected.

onStats

onStats: (stats: AoqStats) => void
Engine statistics callback. The SDK periodically reports publishing and subscribing statistics for audio and video and network statistics, which you can use to monitor call quality and network status in real time and to diagnose audio and video issues.
ParametersTypeDescription
statsAoqStatsPublishing and subscribing statistics and network statistics for audio, video, and data messages

onAudioDeviceStateChanged

onAudioDeviceStateChanged: (state: AoqAudioDeviceState) => void
Callback for audio device capture and playback operation status changes.

onAudioDeviceRouteChanged

onAudioDeviceRouteChanged: (routeType: number) => void
Audio output route change callback. routeType corresponds to an AoqAudioDeviceRouteType value (see 3.4).

onAudioFileState

onAudioFileState: (state: AoqAudioFileState) => void
Callback for audio file playback status.

onLocalAudioVolumeIndication

onLocalAudioVolumeIndication: (volume: AoqAudioVolume) => void
Local capture volume indication callback. To enable it, call enableLocalAudioVolumeIndication.

onVideoDeviceStateChanged

onVideoDeviceStateChanged: (state: AoqVideoDeviceState) => void
Callback for video device capture operation status changes.

onDataMsg

onDataMsg: (data: Uint8Array) => void
Callback for a received real-time data message. data is a Buffer copied on the native side and can be safely held asynchronously. For text messages, use Buffer.from(data).toString() to convert the data to a string.

Audio frame events

onCapturedAudioFrame:        (frame: AoqAudioFrameEvent) => void  /* raw captured data */
onProcessCapturedAudioFrame: (frame: AoqAudioFrameEvent) => void  /* data after 3A processing */
onPublishAudioFrame:         (frame: AoqAudioFrameEvent) => void  /* publishing data */
onPlaybackAudioFrame:        (frame: AoqAudioFrameEvent) => void  /* playback data */
You must first call setAudioFrameObserver(true) and enableAudioFrameObserver to enable it.

onCapturedAudioFrame

Called when a raw audio frame is captured. The frame contains unprocessed PCM data.
engine.on('onCapturedAudioFrame', (frame: AoqAudioFrameEvent) => { ... })
ParameterTypeDescription
frameAoqAudioFrameEventCaptured audio frame data. PCM data is in frame.buffer.
Return value: None (void). Electron provides read-only access.
frame.buffer is a Uint8Array that references SDK-managed 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.
engine.on('onProcessCapturedAudioFrame', (frame: AoqAudioFrameEvent) => { ... })
ParameterTypeDescription
frameAoqAudioFrameEventAudio frame data after 3A processing. PCM data is in frame.buffer.
Return value: None (void). Electron provides read-only access.
frame.buffer is a Uint8Array that references SDK-managed 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.
engine.on('onPublishAudioFrame', (frame: AoqAudioFrameEvent) => { ... })
ParameterTypeDescription
frameAoqAudioFrameEventAudio frame data before publishing. PCM data is in frame.buffer.
Return value: None (void). Electron provides read-only access.
frame.buffer is a Uint8Array that references SDK-managed 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.
engine.on('onPlaybackAudioFrame', (frame: AoqAudioFrameEvent) => { ... })
ParameterTypeDescription
frameAoqAudioFrameEventRemote audio frame data before playback. PCM data is in frame.buffer.
Return value: None (void). Electron provides read-only access.
frame.buffer is a Uint8Array that references SDK-managed memory and is valid only during the callback. Copy the data before using it asynchronously.

Video frame events

onCapturedVideoFrame:  (frame: AoqVideoFrameEvent) => void  /* after capture, before preprocessing */
onPreEncodeVideoFrame: (frame: AoqVideoFrameEvent) => void  /* before encoding, after preprocessing */
onRemoteVideoFrame:    (frame: AoqVideoFrameEvent) => void  /* remote, after decoding and before rendering */
You must first call setVideoFrameObserver(true) and enableVideoFrameObserver to enable it. Frame events are read-only. Modifications to buffer in the callback are not written back to the SDK.
Avoid heavy computation in event callbacks: native callbacks are dispatched to the JS main thread through an asynchronous thread, and time-consuming operations in high-frequency frame events cause a backlog.

onCapturedVideoFrame

Called when a raw video frame is captured, before preprocessing. The frame comes from camera or screen capture and has not been preprocessed.
engine.on('onCapturedVideoFrame', (frame: AoqVideoFrameEvent) => { ... })
ParameterTypeDescription
frameAoqVideoFrameEventCaptured video frame data
Return value: None (void). Electron provides read-only access.
frame.buffer is a Uint8Array that references SDK-managed memory and is valid only during the callback. Copy the data before using it asynchronously.

onPreEncodeVideoFrame

Called for a video frame after preprocessing and before encoding.
engine.on('onPreEncodeVideoFrame', (frame: AoqVideoFrameEvent) => { ... })
ParameterTypeDescription
frameAoqVideoFrameEventVideo frame data before encoding
Return value: None (void). Electron provides read-only access.
frame.buffer is a Uint8Array that references SDK-managed memory and is valid only during the callback. Copy the data before using it asynchronously.

onRemoteVideoFrame

Called for a remote video frame after decoding and before rendering.
engine.on('onRemoteVideoFrame', (frame: AoqVideoFrameEvent) => { ... })
ParameterTypeDescription
frameAoqVideoFrameEventDecoded remote video frame data
Return value: None (void). Electron provides read-only access.
frame.buffer is a Uint8Array that references SDK-managed memory and is valid only during the callback. Copy the data before using it asynchronously.

Data types and enumerations

Common types

AoqCreateConfig

FieldTypeRequiredDefault valueDescription
workDirstringNo""SDK working directory (for logs and temporary files)
enableDumpAudiobooleanNofalseSpecifies whether to save audio data (for debugging)
extrasstringNo""Extended parameters (a JSON string)

AoqConnectConfig

FieldTypeRequiredDefault valueDescription
tokenstringYes-Connection authentication token
sidstringYes-Session ID
certFingerprintstringNo""Server certificate fingerprint
workspaceIdHashstringNoNoneWorkspace ID hash. An empty string is equivalent to not passing the parameter.
relayEndpointsArrayYes-List of relay access points
publishTracksArrayYes-List of local published tracks
subscribeTracksArrayYes-List of local subscribed tracks

AoqRelayEndpoint

FieldTypeRequiredDefault valueDescription
routeIndexnumberNo-1Route index
endpointstringYes-Domain name or IP address of the relay server
portnumberYes-Port of the relay server
tcpPortnumberNo0TCP fallback port. A value of 0 uses the SDK default port, 443.

AoqTrackParam

FieldTypeRequiredDefault valueDescription
trackTypeAoqTrackTypeYes-Track type
trackModeAoqTrackModeNoAoqTrackModeSegmentStreaming or non-streaming mode. Effective only for the audio downlink.

Statistics types

AoqStats

A summary of engine statistics, which is periodically reported through onStats. An array field is an empty array when it has no data, and networkStats is not delivered when it has no data.
FieldTypeDescription
audioPublishStatsArrayPublishing statistics for audio
videoPublishStatsArrayPublishing statistics for video
dataMsgPublishStatsArrayPublishing statistics for data messages
audioSubscribeStatsArraySubscribing statistics for audio
videoSubscribeStatsArraySubscribing statistics for video
dataMsgSubscribeStatsArraySubscribing statistics for data messages
networkStatsAoqNetworkStatsNetwork statistics

AoqAudioPublishStats

FieldTypeDescription
trackTypeAoqTrackTypeTrack type
bitratenumberBitrate, in bit/s
bytesnumberCumulative bytes sent
encodeVolumenumberEncoding volume of the publishing stream

AoqAudioSubscribeStats

FieldTypeDescription
trackTypeAoqTrackTypeTrack type
bitratenumberBitrate, in bit/s
bytesnumberCumulative bytes received
playVolumenumberPlayback volume

AoqVideoPublishStats

FieldTypeDescription
trackTypeAoqTrackTypeTrack type
bitratenumberBitrate, in bit/s
bytesnumberCumulative bytes sent
encodeFpsnumberEncoding frame rate

AoqVideoSubscribeStats

FieldTypeDescription
trackTypeAoqTrackTypeTrack type
bitratenumberBitrate, in bit/s
bytesnumberCumulative bytes received
decodeFpsnumberDecoding frame rate
renderFpsnumberRendering frame rate

AoqDataMsgPublishStats / AoqDataMsgSubscribeStats

FieldTypeDescription
trackTypeAoqTrackTypeTrack type
bitratenumberBitrate, in bit/s
bytesnumberCumulative bytes sent and received

AoqNetworkStats

FieldTypeDescription
sendBitratenumberSend bitrate, in bit/s
sendBytesnumberCumulative bytes sent
recvBitratenumberReceive bitrate, in bit/s
recvBytesnumberCumulative bytes received
lossnumberPacket loss rate, from 0 to 100
rttnumberRound-trip latency, in ms

Enumerations

AoqTrackType

Enum valueValueDescription
AoqTrackTypeAudio0Audio track
AoqTrackTypeVideo1Video track
AoqTrackTypeData2Data message track
AoqTrackTypeScreen3Screen sharing track. Uplink only.

AoqTrackMode

Enum valueValueDescription
AoqTrackModeSegment0Segmented: data is packaged and delivered in semantic segments, such as a sentence.
AoqTrackModeStream1Streaming: data is delivered continuously.

AoqEncoderType

Enum valueValueDescription
AoqEncoderTypeUnknown0Unknown format
AoqEncoderTypeAudioPCM1Audio PCM
AoqEncoderTypeAudioOpus2Audio Opus (plug-in based; requires PluginOpus)
AoqEncoderTypeVideoH2643Video H.264
AoqEncoderTypeVideoJpeg4Video JPEG
AoqEncoderTypeDataText5Message text

AoqConnectionStatus

Enum valueValueDescription
AoqConnectionStatusDisconnected0Disconnected
AoqConnectionStatusConnecting1Connecting
AoqConnectionStatusConnected2Connected
AoqConnectionStatusFailed3Connection failed

AoqMirrorMode

Enum valueValueDescription
AoqMirrorModeDisabled0Disable mirroring
AoqMirrorModeEnabled1Enable mirroring

AoqOrientationMode

Enum valueValueDescription
AoqOrientationModeAuto0Auto-fit
AoqOrientationModePortrait1Portrait
AoqOrientationModeLandscape2Landscape

AoqErrorCode

The following names are error codes from the underlying C++ engine. The Electron TypeScript API does not export this enum. The code argument of onError is a number. The error codes are defined at the native layer. The code parameter of onError and the API return values both use these values (the TS layer does not export them as an enum).
Enum valueValueDescription
AoqECOK0Success
AoqECParamInvalid1Invalid parameter
AoqECStateInvalid2Invalid state
AoqECUnSupport3Not supported on the current platform or in the current mode
AoqECAudio100Generic audio error
AoqECAudioExternalBufferFull110External audio buffer is full
AoqECAudioDevice120Generic audio device error
AoqECAudioDeviceRecordingAuthFailed121Recording permission not granted
AoqECAudioDeviceRecordingOccupied122Recording device is in use
AoqECAudioDeviceRecordingBackgroundStart123Failed to start recording in the background
AoqECAudioDeviceRecordingStartFail124Failed to start recording
AoqECAudioDevicePlayoutOccupied125Playback device is in use
AoqECAudioDevicePlayoutBackgroundStart126Failed to start playback in the background
AoqECAudioDevicePlayoutStartFail127Failed to start playback
AoqECVideo200Generic video error
AoqECVideoExternalBufferFull210External video buffer is full
AoqECVideoExternalCaptureNotEnabled211External video capture is not enabled
AoqECVideoExternalEncoderNotEnabled212External video encoding is not enabled
AoqECVideoDevice220Generic video device error
AoqECVideoDeviceCameraOpenFail221Failed to open the camera
AoqECVideoDeviceCameraAuthFailed222Camera permission not granted
AoqECVideoDeviceCameraOccupied223Camera is in use
AoqECVideoDeviceCameraRunningError224Camera runtime exception
AoqECVideoCodec230Generic video codec error
AoqECVideoCodecEncoderInitFail231Failed to initialize the video encoder
AoqECVideoRender240Generic video rendering error
AoqECVideoRenderCreateFail241Failed to create video rendering
AoqECVideoRenderDrawError242Video rendering drawing error
AoqECScreen300General screen sharing error
AoqECScreenAuthFailed310Screen sharing permission denied
AoqECScreenStartFailed311Failed to start screen sharing
AoqECAudioDeviceEarpieceRequiresVoipMode128The earpiece requires VoIP mode. Applies to mobile platforms and is generally not triggered in Electron.
In addition to the native error codes above, the Electron layer returns -1 when the engine is not created or has been destroyed, or when a parameter is not valid JSON.

AoqWarningCode

Enum valueValueDescription
AoqWCOK0No warning
AoqWCAudio100Generic audio warning
AoqWCAudioHowling101Audio howling detected
AoqWCAudioDevice120Generic audio device warning
AoqWCAudioDeviceMicEnumerateError121Microphone enumeration error
AoqWCAudioDeviceMicStartTimeout122Microphone startup timed out
AoqWCAudioDeviceRecordingError123Error during recording
AoqWCAudioDeviceSpeakerEnumerateError124Speaker enumeration error
AoqWCAudioDeviceSpeakerStartTimeout125Speaker startup timed out
AoqWCAudioDevicePlayoutError126Error during playback
AoqWCVideo200Generic video warning
AoqWCVideoCameraEnumerateError201Camera enumeration error
AoqWCVideoEncoderSwitched202Video encoder switched
AoqWCVideoRenderDowngrade203Video rendering downgraded

Audio types

AoqAudioCaptureConfig

FieldTypeRequiredDefault valueDescription
isExternalbooleanNofalseSpecifies whether to use external capture mode
channelnumberNo1Number of audio capture channels. 1 and 2 are supported.

AoqAudioPlaybackConfig

FieldTypeRequiredDefault valueDescription
isExternalbooleanNofalseSpecifies whether to use external playback mode
channelnumberNo1Number of audio playback channels. 1 and 2 are supported.

AoqAudioCodecConfig

FieldTypeRequiredDefault valueDescription
trackTypeAoqTrackTypeNoAoqTrackTypeAudioTrack type
codecTypeAoqEncoderTypeNoAoqEncoderTypeAudioOpusCodec format
sampleRatenumberNo48000Sample rate, in Hz. For encoding, Opus 8/16/48K and PCM 8/16/32/48K are supported. For decoding, 24K is additionally supported, but only in Segment mode.
channelnumberNo1Number of channels. 1 and 2 are supported.
bitratenumberNo32000Bitrate, in bit/s

AoqAudioDeviceRouteType

The following table lists the valid routeType values for onAudioDeviceRouteChanged. These values are defined by the native layer and are not exported as an enum by the TypeScript layer.
Enum valueValueDescription
AoqAudioDeviceRouteDefault0Default route
AoqAudioDeviceRouteHeadset1Headphones with a microphone
AoqAudioDeviceRouteEarpiece2Receiver
AoqAudioDeviceRouteHeadsetNoMic3Headphones without a microphone
AoqAudioDeviceRouteSpeakerPhone4Speaker
AoqAudioDeviceRouteUsb5USB audio device
AoqAudioDeviceRouteBluetooth6Bluetooth SCO mode
AoqAudioDeviceRouteBluetoothA2dp7Bluetooth A2DP mode

AoqAudioDeviceStateCode

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

FieldTypeDescription
stateAoqAudioDeviceStateCodeDevice operation status
reasonnumberError reason code. See AoqErrorCode.

Audio file types

AoqAudioFileMixConfig

FieldTypeRequiredDefault valueDescription
fileIdstringYes-File identifier. Subsequent API calls use it to locate the file.
fileNamestringYes-File name (including the path)
cyclesnumberNo-1Number of loops. -1 indicates unlimited looping.
startPosMsnumberNo0Start playback position, in milliseconds
publishVolumenumberNo100Publishing volume. Valid values: 0 to 100.
playoutVolumenumberNo100Playback volume. Valid values: 0 to 100.

AoqAudioFileStateCode

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

AoqAudioFileErrorCode

The following table lists the valid AoqAudioFileState.errorCode values. These values are defined by the native layer and are delivered as number values by the TypeScript layer.
Enum valueValueDescription
AoqAudioFileNoError0No error
AoqAudioFileOpenFailed1Failed to open the file
AoqAudioFileDecodeFailed2Failed to decode the file

AoqAudioFileState

FieldTypeDescription
fileIdstringFile identifier
stateCodeAoqAudioFileStateCodeFile playback status code
errorCodenumberFile error code. See AoqAudioFileErrorCode.

External audio stream types

AoqAudioStreamDirection

Enum valueValueDescription
AoqAudioStreamPublish0Publishing stream
AoqAudioStreamPlayout1Playback stream (local playback)

AoqAudioExternalStreamConfig

FieldTypeRequiredDefault valueDescription
streamIdstringYes-Stream identifier
trackTypeAoqTrackTypeNoAoqTrackTypeAudioAudio track type
codecTypeAoqEncoderTypeNoAoqEncoderTypeAudioPCMAudio stream format. PCM is currently supported.
channelsnumberNo1Number of channels. It is limited by the codec of the publishing stream. 1 and 2 are supported.
sampleRatenumberNo48000Sample rate, in Hz. 8, 12, 16, 24, 32, 44.1, 48, 64, 88.2, 96, 176.4, and 192K are supported.
playoutVolumenumberNo100Playback volume. Valid values: 0 to 100.
publishVolumenumberNo100Publishing volume. Valid values: 0 to 100.
maxBufferDurationnumberNo600000Maximum buffer duration, in milliseconds. Valid values: 100 and above. If the duration exceeds this value, push fails.
enable3AbooleanNofalseSpecifies whether to apply 3A processing to the input PCM

AoqAudioExternalFrameMeta

Metadata of an external audio frame. The PCM data is passed separately through the buffer parameter.
FieldTypeRequiredDefault valueDescription
streamIdstringYes-Identifier of the target external audio stream
numOfSamplesnumberYes0Number of samples (per channel)
bytesPerSamplenumberYes2Bytes per sample
numOfChannelsnumberYes1Number of channels
samplesPerSecnumberYes48000Number of samples per second (sample rate)
pushSequencenumberNo0PCM input round
timeStampnumberNo0Timestamp

AoqAudioFrameEvent

Event data of the audio frame observer.
FieldTypeDescription
trackTypeAoqTrackTypeTrack type
numOfSamplesnumberNumber of samples (per channel)
bytesPerSamplenumberBytes per sample
numOfChannelsnumberNumber of channels
samplesPerSecnumberNumber of samples per second (sample rate)
timeStampnumberTimestamp
autoGenMutebooleantrue indicates silent data generated by the SDK
bufferUint8ArrayAudio PCM data (already copied on the native side)

AoqAudioSource

Enum valueValueDescription
AoqAudioSourceCaptured0Captured audio data
AoqAudioSourceProcessCaptured1Audio data after 3A processing
AoqAudioSourcePublish2Audio data to be published (requires a successful connect)
AoqAudioSourcePlayback3Audio data to be played

AoqAudioObserverParams

FieldTypeRequiredDefault valueDescription
enabledbooleanYesfalseEnable or disable the callback at this position
audioSourceAoqAudioSourceYesAoqAudioSourceCapturedCallback position
sampleRatenumberNo48000Sample rate of the callback audio, in Hz. Resampling is performed if the rates do not match.
channelsnumberNo1Number of audio channels in the callback. 1 and 2 are supported.
The callback mode is fixed to read-only. Electron does not provide read-write mode.

AoqAudioVolumeIndicationConfig

FieldTypeRequiredDefault valueDescription
intervalnumberNo0Callback interval, in milliseconds. A value less than or equal to 0 disables the callback. A value greater than 0 and less than 10 is treated as 10.
smoothnumberNo3Volume smoothing coefficient. A larger value results in smoother output. Valid values: 0 to 10.

AoqAudioVolume

FieldTypeDescription
volumenumberSmoothed instantaneous volume. Valid values: 0 to 255.

Video types

AoqVideoCaptureConfig

FieldTypeRequiredDefault valueDescription
widthnumberNo1280Capture width, in pixels. This parameter is ineffective when isExternal=true.
heightnumberNo720Capture height, in pixels. This parameter is ineffective when isExternal=true.
fpsnumberNo15Capture frame rate. This parameter is ineffective when isExternal=true (the pace is determined by frame delivery).
isExternalbooleanNofalseSpecifies whether to use external capture. If it is true, the camera is not opened.

AoqVideoCodecConfig

Encoding and decoding share the same structure (setVideoEncoderConfig / setVideoDecoderConfig).
FieldTypeRequiredDefault valueDescription
isExternalbooleanNofalseWhen this parameter is true, the SDK does not perform capture or encoding, and frames are pushed directly by pushExternalVideoEncodedFrame.
trackTypeAoqTrackTypeNoAoqTrackTypeVideoTrack type
codecTypeAoqEncoderTypeNoAoqEncoderTypeVideoH264Codec format
widthnumberNo540Encoding width, in pixels
heightnumberNo960Encoding height, in pixels
fpsnumberNo5Encoding frame rate
bitratenumberNo500000Initial bitrate, in bit/s
minBitratenumberNo128000Minimum bitrate, in bit/s
keyframeIntervalnumberNo2Keyframe interval, in seconds
mirrorModeAoqMirrorModeNoAoqMirrorModeDisabledMirror mode
orientationModeAoqOrientationModeNoAoqOrientationModeAutoVideo orientation mode

AoqVideoPixelFormat

Pixel formats supported by Electron.
Enum valueValueDescription
AoqVideoPixelFormatUnknown0Unknown format
AoqVideoPixelFormatI4201I420 (YUV planar format)
AoqVideoPixelFormatNV122NV12 (YUV semi-planar format)
AoqVideoPixelFormatNV213NV21 (YUV semi-planar format)
AoqVideoPixelFormatBGRA4BGRA (32-bit)
AoqVideoPixelFormatRGBA5RGBA (32-bit)

AoqExternalVideoFrameMeta

Metadata of an external raw video frame. The pixel data is passed separately through the buffer parameter.
FieldTypeRequiredDefault valueDescription
trackTypeAoqTrackTypeNoAoqTrackTypeVideoTrack type. Supports Video / Screen routing.
formatAoqVideoPixelFormatYes-Pixel format
widthnumberYes-Video width, in pixels
heightnumberYes-Video height, in pixels
timeStampnumberNo0Timestamp, in milliseconds. If it is 0, the SDK fills it in with the local time.
When format = I420, buffer must use a compact layout (stride = width), with the Y / U / V planes concatenated in order. For other packed formats, pass the entire frame bytes directly.

AoqVideoCodecType

Enum valueValueDescription
AoqVideoCodecTypeJPEG0JPEG encoding

AoqExternalVideoEncodedFrameMeta

Metadata of an externally encoded video frame. The encoded data is passed separately through the buffer parameter.
FieldTypeRequiredDefault valueDescription
trackTypeAoqTrackTypeNoAoqTrackTypeVideoTrack type. Supports Video / Screen routing.
codecAoqVideoCodecTypeNoAoqVideoCodecTypeJPEGCodec format
widthnumberYes-Width, in pixels
heightnumberYes-Height, in pixels
timeStampnumberNo0Timestamp, in milliseconds. If it is 0, the SDK fills it in with the local time.

AoqVideoDeviceStateCode

Enum valueValueDescription
AoqVideoDeviceNone0No state
AoqVideoDeviceCaptureStarting1Capture starting
AoqVideoDeviceCaptureStarted2Capture started
AoqVideoDeviceCaptureStopping3Capture stopping
AoqVideoDeviceCaptureStopped4Capture stopped
AoqVideoDeviceCaptureFail5Capture failed (for example, permission denied or the device is unavailable)

AoqVideoDeviceState

FieldTypeDescription
stateAoqVideoDeviceStateCodeDevice capture operation status
reasonnumberError reason code. See AoqErrorCode.

AoqScreenShareSourceType

ValueNumberDescription
AoqScreenShareSourceTypeDesktop0Entire desktop
AoqScreenShareSourceTypeWindow1A specific window

AoqScreenSourceInfo

FieldTypeDescription
sourceTypeAoqScreenShareSourceTypeSource type
sourceIdstringSource ID; returned as a string to preserve int64 precision.
sourceNamestringSource name
sourceIsSelfbooleanWhether the window belongs to the current process

AoqScreenCaptureConfig

All fields are optional. isExternal defaults to false.
FieldTypeDefaultDescription
isExternalbooleanfalseWhether the application supplies raw screen frames.
sourceIdstring | number—Screen source ID. Optional. Use a string; numbers must be safe integers.
sourceTypeAoqScreenShareSourceType—Screen source type.
Except for AoqErrorCode, which is a native error-code reference and is not exported by TypeScript, the types in this section are exported from the package root, so you can directly use import { ... } from 'aoq-electron-sdk'. Exported enumerations are TypeScript enum types and are available at runtime, whereas interfaces (interface) are type constraints only. If a field marked as optional is not specified, the default value in the table is used.

Video frame callback types

AoqVideoSource

Enum valueValueDescription
AoqVideoSourceCaptured0Captured video data before preprocessing
AoqVideoSourcePreEncode1Video data before encoding, after preprocessing
AoqVideoSourceRemote2Remote video data after decoding and before rendering

AoqVideoObserverAlignment

Enum valueValueDescription
AoqVideoObserverAlignmentDefault0Default alignment
AoqVideoObserverAlignmentEven1Even-number alignment
AoqVideoObserverAlignment424-byte alignment
AoqVideoObserverAlignment838-byte alignment
AoqVideoObserverAlignment16416-byte alignment

AoqVideoObserverParams

FieldTypeRequiredDefault valueDescription
enabledbooleanYesfalseEnable or disable the callback at this position
videoSourceAoqVideoSourceYesAoqVideoSourceCapturedCallback position
formatAoqVideoPixelFormatNoAoqVideoPixelFormatI420Expected pixel format of the callback data
alignmentAoqVideoObserverAlignmentNoAoqVideoObserverAlignmentDefaultWidth alignment policy
mirrorAppliedbooleanNofalseSpecifies whether to mirror the callback data
trackTypeAoqTrackTypeNoAoqTrackTypeVideoVideo track to observe. Supports Video and Screen only.
The callback mode is fixed to read-only. Electron does not provide read-write mode. Select I420 when you use the built-in YUVCanvasRenderer for rendering.

AoqVideoFrameEvent

Event data of the video frame observer.
FieldTypeDescription
trackTypeAoqTrackTypeTrack type
formatAoqVideoPixelFormatPixel format
widthnumberWidth, in pixels
heightnumberHeight, in pixels
strideYnumberStride of the Y plane (effective only for I420)
strideUnumberStride of the U plane (effective only for I420)
strideVnumberStride of the V plane (effective only for I420)
timeStampnumberTimestamp, in milliseconds
bufferUint8ArrayFrame data. For I420, it is the Y / U / V planes concatenated based on stride. Other packed formats are passed through as the original data.

Data message types

Electron does not use the AoqDataMsg wrapper type. Data messages are sent and received directly as binary data:
DirectionTypeDescription
SendUint8Array or stringsendDataMsg(data). Strings are encoded in UTF-8.
ReceiveUint8ArrayonDataMsg(data). The data is already copied on the native side and can be held asynchronously.