Skip to main content
AOQ SDK overview

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.

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

API index

Engine entry and lifecycle

API

Description

createAoqClientEngine

Get the engine wrapper instance (a module-level lazily initialized singleton)

createEngine

Create the native engine instance

destroy

Destroy the engine instance

getVersion

Get the SDK version

connect

Connect to the relay server

disconnect

Disconnect from the server

Audio device management

API

Description

startAudioCapture

Open the audio capture device (microphone)

stopAudioCapture

Close the audio capture device

muteAudioCapture

Mute or unmute audio capture

startAudioPlayer

Start audio rendering to play remote audio

stopAudioPlayer

Stop audio rendering

pauseAudioPlayer

Pause audio rendering, with fade-out supported

resumeAudioPlayer

Resume audio rendering, with fade-in supported

interruptAudioPlayer

Interrupt the current audio session

Audio codec configuration

API

Description

setAudioEncoderConfig

Set audio encoding parameters

setAudioDecoderConfig

Set audio decoding parameters

Video device management

API

Description

startVideoCapture

Open the video capture device (camera)

stopVideoCapture

Close the video capture device

Video codec and external input

API

Description

setVideoEncoderConfig

Set video encoding parameters

setVideoDecoderConfig

Set video decoding parameters

pushExternalVideoCapturedFrame

Push an externally captured video frame

pushExternalVideoEncodedFrame

Push an externally encoded video frame

Media stream control

API

Description

enableSendMediaStream

Enable or disable sending of a local media stream

Audio file playback

API

Description

startAudioFile

Start playing a local audio file to the publishing stream

stopAudioFile

Stop audio file playback

pauseAudioFile

Pause audio file playback

resumeAudioFile

Resume audio file playback

getAudioFileDuration

Query the total duration of the audio file

getAudioFileCurrentPosition

Query the current playback position of the audio file

setAudioFilePositionMillis

Set the playback position of the audio file (seek)

setAudioFileVolume

Set the volume of the audio file

getAudioFileVolume

Query the current volume of the audio file

External audio streams

API

Description

addAudioExternalStream

Add an external audio stream

removeAudioExternalStream

Remove an external audio stream

pushAudioExternalStreamData

Feed external audio PCM data

setAudioExternalStreamVolume

Set the volume of an external audio stream

getAudioExternalStreamVolume

Query the volume of an external audio stream

clearAudioExternalStreamBuffer

Clear the buffer of an external audio stream

Real-time messaging

API

Description

sendDataMsg

Send a real-time data message

Audio frame callbacks

API

Description

setAudioFrameObserver

Enable or disable the audio frame data observer

enableAudioFrameObserver

Enable or disable the audio frame callback at a specified position

Local volume indication

API

Description

enableLocalAudioVolumeIndication

Enable or disable the local capture volume indication callback

Video frame callbacks

API

Description

setVideoFrameObserver

Enable or disable the video frame data observer

enableVideoFrameObserver

Enable or disable the video frame callback at a specified position

Video rendering (YUVCanvasRenderer)

API

Description

bind

Bind a canvas element

unbind

Unbind and clear the image

bound

Query whether a binding is currently established

drawFrame

Draw one frame of I420 video data

Engine events (IAoqEngineEvents)

Event

Description

onError

Engine error callback

onWarning

Engine warning callback

onConnectionStatusChange

Connection status change callback

onStats

Engine statistics callback

onAudioDeviceStateChanged

Audio device operation status change callback

onAudioDeviceRouteChanged

Audio output route change callback

onAudioFileState

Audio file playback status callback

onLocalAudioVolumeIndication

Local capture volume indication callback

onVideoDeviceStateChanged

Video device operation status change callback

onDataMsg

Callback for a received real-time data message

onCapturedAudioFrame

Callback for raw captured audio data

onProcessCapturedAudioFrame

Callback for audio data after 3A processing

onPublishAudioFrame

Callback for publishing audio data

onPlaybackAudioFrame

Callback for playback audio data

onCapturedVideoFrame

Callback for local raw video data after capture

onPreEncodeVideoFrame

Callback for local raw video data before encoding

onRemoteVideoFrame

Callback for remote video data after decoding and before rendering

API details

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

Parameters

Type

Description

config

AoqCreateConfig

Engine 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

Parameters

Type

Description

config

AoqConnectConfig

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

Parameters

Type

Description

trackType

AoqTrackType

Track type

fadeMs

number

Fade-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 and external input

setVideoEncoderConfig(config: AoqVideoCodecConfig): number
setVideoDecoderConfig(config: AoqVideoCodecConfig): number
pushExternalVideoCapturedFrame(meta: AoqExternalVideoFrameMeta, buffer: Uint8Array): number
pushExternalVideoEncodedFrame(meta: AoqExternalVideoEncodedFrameMeta, buffer: Uint8Array): number

Parameters

Type

Description

meta

AoqExternalVideoFrameMeta / AoqExternalVideoEncodedFrameMeta

Frame metadata (dimensions, format, and timestamp)

buffer

Uint8Array

Frame data (pixel data or encoded data)

Notes:
  • pushExternalVideoCapturedFrame is consumed only after startVideoCapture({ 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.

Media stream control

enableSendMediaStream(trackType: AoqTrackType, enable: boolean): number
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

Parameters

Type

Description

config

AoqAudioFileMixConfig

File mixing configuration. fileId is carried as a configuration field.

fileId

string

File identifier, which is defined by the caller. Subsequent API calls use it to locate the file.

positionMs

number

Target playback position, in milliseconds

type

AoqAudioStreamDirection

Publishing volume or local playback volume

volume

number

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

Parameters

Type

Description

config

AoqAudioExternalStreamConfig

External audio stream configuration. streamId is carried as a configuration field.

streamId

string

Stream identifier, which is defined by the caller

meta

AoqAudioExternalFrameMeta

PCM frame metadata. streamId is carried as a metadata field.

buffer

Uint8Array

PCM data

fadeoutMs

number

Fade-out duration when the buffer is cleared, in milliseconds

Notes:
  • 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 messaging

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

Parameters

Type

Description

enable

boolean

true registers the built-in audio frame observer; false unregisters it

params

AoqAudioObserverParams

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

Parameters

Type

Description

enable

boolean

true registers the built-in video frame observer; false unregisters it

params

AoqVideoObserverParams

Specify 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. It takes on the preview responsibilities of setLocalView / setRemoteView on mobile platforms.
import { YUVCanvasRenderer } from 'aoq-electron-sdk';

class YUVCanvasRenderer {
  bind(canvas: HTMLCanvasElement): void
  unbind(): void
  get bound(): boolean
  drawFrame(frame: AoqVideoFrameEvent): void
}

API

Description

bind

Bind a canvas (binding again replaces the sink)

unbind

Unbind and clear the image

bound

Specifies whether a binding is established

drawFrame

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

Parameters

Type

Description

stats

AoqStats

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

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.

Data types and enumerations

All types are exported from the package root, so you can directly use import { ... } from 'aoq-electron-sdk'. 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.

General types

AoqCreateConfig

Field

Type

Required

Default value

Description

workDir

string

No

""

SDK working directory (for logs and temporary files)

enableDumpAudio

boolean

No

false

Specifies whether to save audio data (for debugging)

extras

string

No

""

Extended parameters (a JSON string)

The isBTScoMode field on Android is a mobile-only field and is not provided by Electron.

AoqConnectConfig

Field

Type

Required

Default value

Description

token

string

Yes

-

Connection authentication token

sid

string

Yes

-

Session ID

certFingerprint

string

No

""

Server certificate fingerprint

workspaceIdHash

string

No

None

Workspace ID hash. An empty string is equivalent to not passing the parameter.

relayEndpoints

Array

Yes

-

List of relay access points

publishTracks

Array

Yes

-

List of local published tracks

subscribeTracks

Array

Yes

-

List of local subscribed tracks

AoqRelayEndpoint

Field

Type

Required

Default value

Description

routeIndex

number

No

-1

Route index

endpoint

string

Yes

-

Domain name or IP address of the relay server

port

number

Yes

-

Port of the relay server

AoqTrackParam

Field

Type

Required

Default value

Description

trackType

AoqTrackType

Yes

-

Track type

trackMode

AoqTrackMode

No

AoqTrackModeSegment

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

Field

Type

Description

audioPublishStats

Array

Publishing statistics for audio

videoPublishStats

Array

Publishing statistics for video

dataMsgPublishStats

Array

Publishing statistics for data messages

audioSubscribeStats

Array

Subscribing statistics for audio

videoSubscribeStats

Array

Subscribing statistics for video

dataMsgSubscribeStats

Array

Subscribing statistics for data messages

networkStats

AoqNetworkStats

Network statistics

AoqAudioPublishStats

Field

Type

Description

trackType

AoqTrackType

Track type

bitrate

number

Bitrate, in bit/s

bytes

number

Cumulative bytes sent

encodeVolume

number

Encoding volume of the publishing stream

AoqAudioSubscribeStats

Field

Type

Description

trackType

AoqTrackType

Track type

bitrate

number

Bitrate, in bit/s

bytes

number

Cumulative bytes received

playVolume

number

Playback volume

AoqVideoPublishStats

Field

Type

Description

trackType

AoqTrackType

Track type

bitrate

number

Bitrate, in bit/s

bytes

number

Cumulative bytes sent

encodeFps

number

Encoding frame rate

AoqVideoSubscribeStats

Field

Type

Description

trackType

AoqTrackType

Track type

bitrate

number

Bitrate, in bit/s

bytes

number

Cumulative bytes received

decodeFps

number

Decoding frame rate

renderFps

number

Rendering frame rate

AoqDataMsgPublishStats / AoqDataMsgSubscribeStats

Field

Type

Description

trackType

AoqTrackType

Track type

bitrate

number

Bitrate, in bit/s

bytes

number

Cumulative bytes sent and received

AoqNetworkStats

Field

Type

Description

sendBitrate

number

Send bitrate, in bit/s

sendBytes

number

Cumulative bytes sent

recvBitrate

number

Receive bitrate, in bit/s

recvBytes

number

Cumulative bytes received

loss

number

Packet loss rate, from 0 to 100

rtt

number

Round-trip latency, in ms

Enumerations

AoqTrackType

Enum value

Value

Description

AoqTrackTypeAudio

0

Audio track

AoqTrackTypeVideo

1

Video track

AoqTrackTypeData

2

Data message track

AoqTrackMode

Enum value

Value

Description

AoqTrackModeSegment

0

Segmented: data is packaged and delivered in semantic segments, such as a sentence.

AoqTrackModeStream

1

Streaming: data is delivered continuously.

AoqEncoderType

Enum value

Value

Description

AoqEncoderTypeUnknown

0

Unknown format

AoqEncoderTypeAudioPCM

1

Audio PCM

AoqEncoderTypeAudioOpus

2

Audio Opus (plug-in based; requires PluginOpus)

AoqEncoderTypeVideoH264

3

Video H.264

AoqEncoderTypeVideoJpeg

4

Video JPEG

AoqEncoderTypeDataText

5

Message text

AoqConnectionStatus

Enum value

Value

Description

AoqConnectionStatusDisconnected

0

Disconnected

AoqConnectionStatusConnecting

1

Connecting

AoqConnectionStatusConnected

2

Connected

AoqConnectionStatusFailed

3

Connection failed

AoqMirrorMode

Enum value

Value

Description

AoqMirrorModeDisabled

0

Disable mirroring

AoqMirrorModeEnabled

1

Enable mirroring

AoqOrientationMode

Enum value

Value

Description

AoqOrientationModeAuto

0

Auto-fit

AoqOrientationModePortrait

1

Portrait

AoqOrientationModeLandscape

2

Landscape

AoqErrorCode

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 value

Value

Description

AoqErrorCodeOK

0

Success

AoqErrorCodeParamInvalid

1

Invalid parameter

AoqErrorCodeStateInvalid

2

Invalid state

AoqErrorCodeUnSupport

3

Not supported on the current platform or in the current mode

AoqErrorCodeAudio

100

Generic audio error

AoqErrorCodeAudioExternalBufferFull

110

External audio buffer is full

AoqErrorCodeAudioDevice

120

Generic audio device error

AoqErrorCodeAudioDeviceRecordingAuthFailed

121

Recording permission not granted

AoqErrorCodeAudioDeviceRecordingOccupied

122

Recording device is in use

AoqErrorCodeAudioDeviceRecordingBackgroundStart

123

Failed to start recording in the background

AoqErrorCodeAudioDeviceRecordingStartFail

124

Failed to start recording

AoqErrorCodeAudioDevicePlayoutOccupied

125

Playback device is in use

AoqErrorCodeAudioDevicePlayoutBackgroundStart

126

Failed to start playback in the background

AoqErrorCodeAudioDevicePlayoutStartFail

127

Failed to start playback

AoqErrorCodeVideo

200

Generic video error

AoqErrorCodeVideoExternalBufferFull

210

External video buffer is full

AoqErrorCodeVideoExternalCaptureNotEnabled

211

External video capture is not enabled

AoqErrorCodeVideoExternalEncoderNotEnabled

212

External video encoding is not enabled

AoqErrorCodeVideoDevice

220

Generic video device error

AoqErrorCodeVideoDeviceCameraOpenFail

221

Failed to open the camera

AoqErrorCodeVideoDeviceCameraAuthFailed

222

Camera permission not granted

AoqErrorCodeVideoDeviceCameraOccupied

223

Camera is in use

AoqErrorCodeVideoDeviceCameraRunningError

224

Camera runtime exception

AoqErrorCodeVideoCodec

230

Generic video codec error

AoqErrorCodeVideoCodecEncoderInitFail

231

Failed to initialize the video encoder

AoqErrorCodeVideoRender

240

Generic video rendering error

AoqErrorCodeVideoRenderCreateFail

241

Failed to create video rendering

AoqErrorCodeVideoRenderDrawError

242

Video rendering drawing error

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 value

Value

Description

AoqWCOK

0

No warning

AoqWCAudio

100

Generic audio warning

AoqWCAudioHowling

101

Audio howling detected

AoqWCAudioDevice

120

Generic audio device warning

AoqWCAudioDeviceMicEnumerateError

121

Microphone enumeration error

AoqWCAudioDeviceMicStartTimeout

122

Microphone startup timed out

AoqWCAudioDeviceRecordingError

123

Error during recording

AoqWCAudioDeviceSpeakerEnumerateError

124

Speaker enumeration error

AoqWCAudioDeviceSpeakerStartTimeout

125

Speaker startup timed out

AoqWCAudioDevicePlayoutError

126

Error during playback

AoqWCVideo

200

Generic video warning

AoqWCVideoCameraEnumerateError

201

Camera enumeration error

AoqWCVideoEncoderSwitched

202

Video encoder switched

AoqWCVideoRenderDowngrade

203

Video rendering downgraded

Audio types

AoqAudioCaptureConfig

Field

Type

Required

Default value

Description

isExternal

boolean

No

false

Specifies whether to use external capture mode

channel

number

No

1

Number of audio capture channels. 1 and 2 are supported.

AoqAudioPlaybackConfig

Field

Type

Required

Default value

Description

isExternal

boolean

No

false

Specifies whether to use external playback mode

channel

number

No

1

Number of audio playback channels. 1 and 2 are supported.

isVoipMode / isDefaultSpeaker are mobile-only fields and are not provided by Electron.

AoqAudioCodecConfig

Field

Type

Required

Default value

Description

trackType

AoqTrackType

No

AoqTrackTypeAudio

Track type

codecType

AoqEncoderType

No

AoqEncoderTypeAudioPCM

Codec format

sampleRate

number

No

48000

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

channel

number

No

1

Number of channels. 1 and 2 are supported.

bitrate

number

No

32000

Bitrate, 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 value

Value

Description

AoqAudioDeviceRouteDefault

0

Default route

AoqAudioDeviceRouteHeadset

1

Headphones with a microphone

AoqAudioDeviceRouteEarpiece

2

Receiver

AoqAudioDeviceRouteHeadsetNoMic

3

Headphones without a microphone

AoqAudioDeviceRouteSpeakerPhone

4

Speaker

AoqAudioDeviceRouteUsb

5

USB audio device

AoqAudioDeviceRouteBluetooth

6

Bluetooth SCO mode

AoqAudioDeviceRouteBluetoothA2dp

7

Bluetooth A2DP mode

AoqAudioDeviceStateCode

Enum value

Value

Description

AoqAudioDeviceNone

0

No state

AoqAudioDeviceRecordStarting

1

Capture starting

AoqAudioDeviceRecordStarted

2

Capture started

AoqAudioDeviceRecordStopping

3

Capture stopping

AoqAudioDeviceRecordStopped

4

Capture stopped

AoqAudioDeviceRecordFail

5

Capture failed

AoqAudioDevicePlayStarting

6

Playback starting

AoqAudioDevicePlayStarted

7

Playback started

AoqAudioDevicePlayStopping

8

Playback stopping

AoqAudioDevicePlayStopped

9

Playback stopped

AoqAudioDevicePlayFail

10

Playback failed

AoqAudioDeviceState

Field

Type

Description

state

AoqAudioDeviceStateCode

Device operation status

reason

number

Error reason code. See AoqErrorCode.

Audio file types

AoqAudioFileMixConfig

Field

Type

Required

Default value

Description

fileId

string

Yes

-

File identifier. Subsequent API calls use it to locate the file.

fileName

string

Yes

-

File name (including the path)

cycles

number

No

-1

Number of loops. -1 indicates unlimited looping.

startPosMs

number

No

0

Start playback position, in milliseconds

publishVolume

number

No

100

Publishing volume. Valid values: 0 to 100.

playoutVolume

number

No

100

Playback volume. Valid values: 0 to 100.

AoqAudioFileStateCode

Enum value

Value

Description

AoqAudioFileNone

0

No state

AoqAudioFileStarted

1

Playback started

AoqAudioFileStopped

2

Playback stopped

AoqAudioFilePaused

3

Playback paused

AoqAudioFileResumed

4

Playback resumed

AoqAudioFileEnded

5

Playback ended

AoqAudioFileBuffering

6

Playback buffering

AoqAudioFileBufferingEnd

7

Buffering ended

AoqAudioFileFailed

8

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

Value

Description

AoqAudioFileNoError

0

No error

AoqAudioFileOpenFailed

1

Failed to open the file

AoqAudioFileDecodeFailed

2

Failed to decode the file

AoqAudioFileState

Field

Type

Description

fileId

string

File identifier

stateCode

AoqAudioFileStateCode

File playback status code

errorCode

number

File error code. See AoqAudioFileErrorCode.

External audio stream types

AoqAudioStreamDirection

Enum value

Value

Description

AoqAudioStreamPublish

0

Publishing stream

AoqAudioStreamPlayout

1

Playback stream (local playback)

AoqAudioExternalStreamConfig

Field

Type

Required

Default value

Description

streamId

string

Yes

-

Stream identifier

trackType

AoqTrackType

No

AoqTrackTypeAudio

Audio track type

codecType

AoqEncoderType

No

AoqEncoderTypeAudioPCM

Audio stream format. PCM is currently supported.

channels

number

No

1

Number of channels. It is limited by the codec of the publishing stream. 1 and 2 are supported.

sampleRate

number

No

48000

Sample rate, in Hz. 8, 12, 16, 24, 32, 44.1, 48, 64, 88.2, 96, 176.4, and 192K are supported.

playoutVolume

number

No

100

Playback volume. Valid values: 0 to 100.

publishVolume

number

No

100

Publishing volume. Valid values: 0 to 100.

maxBufferDuration

number

No

600000

Maximum buffer duration, in milliseconds. Valid values: 100 and above. If the duration exceeds this value, push fails.

enable3A

boolean

No

false

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

Field

Type

Required

Default value

Description

streamId

string

Yes

-

Identifier of the target external audio stream

numOfSamples

number

Yes

0

Number of samples (per channel)

bytesPerSample

number

Yes

2

Bytes per sample

numOfChannels

number

Yes

1

Number of channels

samplesPerSec

number

Yes

48000

Number of samples per second (sample rate)

pushSequence

number

No

0

PCM input round

timeStamp

number

No

0

Timestamp

AoqAudioFrameEvent

Event data of the audio frame observer.

Field

Type

Description

trackType

AoqTrackType

Track type

numOfSamples

number

Number of samples (per channel)

bytesPerSample

number

Bytes per sample

numOfChannels

number

Number of channels

samplesPerSec

number

Number of samples per second (sample rate)

timeStamp

number

Timestamp

autoGenMute

boolean

true indicates silent data generated by the SDK

buffer

Uint8Array

Audio PCM data (already copied on the native side)

AoqAudioSource

Enum value

Value

Description

AoqAudioSourceCaptured

0

Captured audio data

AoqAudioSourceProcessCaptured

1

Audio data after 3A processing

AoqAudioSourcePublish

2

Audio data to be published (requires a successful connect)

AoqAudioSourcePlayback

3

Audio data to be played

AoqAudioObserverParams

Field

Type

Required

Default value

Description

enabled

boolean

Yes

false

Enable or disable the callback at this position

audioSource

AoqAudioSource

Yes

AoqAudioSourceCaptured

Callback position

sampleRate

number

No

48000

Sample rate of the callback audio, in Hz. Resampling is performed if the rates do not match.

channels

number

No

1

Number 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

Field

Type

Required

Default value

Description

interval

number

No

0

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

smooth

number

No

3

Volume smoothing coefficient. A larger value results in smoother output. Valid values: 0 to 10.

AoqAudioVolume

Field

Type

Description

volume

number

Smoothed instantaneous volume. Valid values: 0 to 255.

Video types

AoqVideoCaptureConfig

Field

Type

Required

Default value

Description

width

number

No

1280

Capture width, in pixels. This parameter is ineffective when isExternal=true.

height

number

No

720

Capture height, in pixels. This parameter is ineffective when isExternal=true.

fps

number

No

15

Capture frame rate. This parameter is ineffective when isExternal=true (the pace is determined by frame delivery).

isExternal

boolean

No

false

Specifies whether to use external capture. If it is true, the camera is not opened.

cameraDirection is a mobile-only field and does not exist on desktop platforms.

AoqVideoCodecConfig

Encoding and decoding share the same structure (setVideoEncoderConfig / setVideoDecoderConfig).

Field

Type

Required

Default value

Description

isExternal

boolean

No

false

When this parameter is true, the SDK does not perform capture or encoding, and frames are pushed directly by pushExternalVideoEncodedFrame.

trackType

AoqTrackType

No

AoqTrackTypeVideo

Track type

codecType

AoqEncoderType

No

AoqEncoderTypeVideoH264

Codec format

width

number

No

540

Encoding width, in pixels

height

number

No

960

Encoding height, in pixels

fps

number

No

5

Encoding frame rate

bitrate

number

No

500000

Initial bitrate, in bit/s

minBitrate

number

No

128000

Minimum bitrate, in bit/s

keyframeInterval

number

No

2

Keyframe interval, in seconds

mirrorMode

AoqMirrorMode

No

AoqMirrorModeDisabled

Mirror mode

orientationMode

AoqOrientationMode

No

AoqOrientationModeAuto

Video orientation mode

AoqVideoPixelFormat

Pixel formats supported on the Electron side (excluding the texture / CVPixelBuffer formats on mobile platforms).

Enum value

Value

Description

AoqVideoPixelFormatUnknown

0

Unknown format

AoqVideoPixelFormatI420

1

I420 (YUV planar format)

AoqVideoPixelFormatNV12

2

NV12 (YUV semi-planar format)

AoqVideoPixelFormatNV21

3

NV21 (YUV semi-planar format)

AoqVideoPixelFormatBGRA

4

BGRA (32-bit)

AoqVideoPixelFormatRGBA

5

RGBA (32-bit)

AoqExternalVideoFrameMeta

Metadata of an external raw video frame. The pixel data is passed separately through the buffer parameter.

Field

Type

Required

Default value

Description

trackType

AoqTrackType

No

AoqTrackTypeVideo

Track type

format

AoqVideoPixelFormat

Yes

-

Pixel format

width

number

Yes

-

Video width, in pixels

height

number

Yes

-

Video height, in pixels

timeStamp

number

No

0

Timestamp, 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 value

Value

Description

AoqVideoCodecTypeJPEG

0

JPEG encoding

AoqExternalVideoEncodedFrameMeta

Metadata of an externally encoded video frame. The encoded data is passed separately through the buffer parameter.

Field

Type

Required

Default value

Description

trackType

AoqTrackType

No

AoqTrackTypeVideo

Track type

codec

AoqVideoCodecType

No

AoqVideoCodecTypeJPEG

Codec format

width

number

Yes

-

Width, in pixels

height

number

Yes

-

Height, in pixels

timeStamp

number

No

0

Timestamp, in milliseconds. If it is 0, the SDK fills it in with the local time.

AoqVideoDeviceStateCode

Enum value

Value

Description

AoqVideoDeviceNone

0

No state

AoqVideoDeviceCaptureStarting

1

Capture starting

AoqVideoDeviceCaptureStarted

2

Capture started

AoqVideoDeviceCaptureStopping

3

Capture stopping

AoqVideoDeviceCaptureStopped

4

Capture stopped

AoqVideoDeviceCaptureFail

5

Capture failed (for example, permission denied or the device is unavailable)

AoqVideoDeviceState

Field

Type

Description

state

AoqVideoDeviceStateCode

Device capture operation status

reason

number

Error reason code. See AoqErrorCode.

Video frame callback types

AoqVideoSource

Enum value

Value

Description

AoqVideoSourceCaptured

0

Captured video data before preprocessing

AoqVideoSourcePreEncode

1

Video data before encoding, after preprocessing

AoqVideoSourceRemote

2

Remote video data after decoding and before rendering

AoqVideoObserverAlignment

Enum value

Value

Description

AoqVideoObserverAlignmentDefault

0

Default alignment

AoqVideoObserverAlignmentEven

1

Even-number alignment

AoqVideoObserverAlignment4

2

4-byte alignment

AoqVideoObserverAlignment8

3

8-byte alignment

AoqVideoObserverAlignment16

4

16-byte alignment

AoqVideoObserverParams

Field

Type

Required

Default value

Description

enabled

boolean

Yes

false

Enable or disable the callback at this position

videoSource

AoqVideoSource

Yes

AoqVideoSourceCaptured

Callback position

format

AoqVideoPixelFormat

No

AoqVideoPixelFormatI420

Expected pixel format of the callback data

alignment

AoqVideoObserverAlignment

No

AoqVideoObserverAlignmentDefault

Width alignment policy

mirrorApplied

boolean

No

false

Specifies whether to mirror the callback data

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.

Field

Type

Description

trackType

AoqTrackType

Track type

format

AoqVideoPixelFormat

Pixel format

width

number

Width, in pixels

height

number

Height, in pixels

strideY

number

Stride of the Y plane (effective only for I420)

strideU

number

Stride of the U plane (effective only for I420)

strideV

number

Stride of the V plane (effective only for I420)

timeStamp

number

Timestamp, in milliseconds

buffer

Uint8Array

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

Direction

Type

Description

Send

Uint8Array or string

sendDataMsg(data). Strings are encoded in UTF-8.

Receive

Uint8Array

onDataMsg(data). The data is already copied on the native side and can be held asynchronously.

Text Generation
Image Generation
  • FAQ
Video Generation
Audio
Text Embedding
Model Production
AOQ Client SDK Electron API reference - Alibaba Cloud Model Studio