Skip to main content
SDK Introduction

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

API index

Engine entry and lifecycle

APIDescription
createAoqClientEngineGet the engine wrapper instance (a module-level lazily initialized 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 to play remote audio
stopAudioPlayerStop audio rendering
pauseAudioPlayerPause audio rendering, with fade-out supported
resumeAudioPlayerResume audio rendering, with fade-in supported
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 and external input

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

Media stream control

APIDescription
enableSendMediaStreamEnable or disable sending of a local media stream

Audio file playback

APIDescription
startAudioFileStart playing a local audio file to the publishing stream
stopAudioFileStop audio file playback
pauseAudioFilePause audio file playback
resumeAudioFileResume audio file playback
getAudioFileDurationQuery the total duration of the audio file
getAudioFileCurrentPositionQuery the current playback position of the audio file
setAudioFilePositionMillisSet the playback position of the audio file (seek)
setAudioFileVolumeSet the volume of the audio file
getAudioFileVolumeQuery the current volume of the audio file

External audio streams

APIDescription
addAudioExternalStreamAdd an external audio stream
removeAudioExternalStreamRemove an external audio stream
pushAudioExternalStreamDataFeed external audio PCM data
setAudioExternalStreamVolumeSet the volume of an external audio stream
getAudioExternalStreamVolumeQuery the volume of an external audio stream
clearAudioExternalStreamBufferClear the buffer of an external audio stream

Real-time messaging

APIDescription
sendDataMsgSend a real-time data message

Audio frame callbacks

APIDescription
setAudioFrameObserverEnable or disable the audio frame data observer
enableAudioFrameObserverEnable or disable the audio frame callback at a specified position

Local volume indication

APIDescription
enableLocalAudioVolumeIndicationEnable or disable the local capture volume indication callback

Video frame callbacks

APIDescription
setVideoFrameObserverEnable or disable the video frame data observer
enableVideoFrameObserverEnable or disable the video frame callback at a specified position

Video rendering (YUVCanvasRenderer)

APIDescription
bindBind a canvas element
unbindUnbind and clear the image
boundQuery whether a binding is currently established
drawFrameDraw one frame of I420 video data

Engine events (IAoqEngineEvents)

EventDescription
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
onDataMsgCallback for a received real-time data message
onCapturedAudioFrameCallback for raw captured audio data
onProcessCapturedAudioFrameCallback for audio data after 3A processing
onPublishAudioFrameCallback for publishing audio data
onPlaybackAudioFrameCallback for playback audio data
onCapturedVideoFrameCallback for local raw video data after capture
onPreEncodeVideoFrameCallback for local raw video data before encoding
onRemoteVideoFrameCallback 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
ParameterTypeDescription
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.
connect(config: AoqConnectConfig): number
ParameterTypeDescription
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.
ParameterTypeDescription
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 Video rendering).

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
ParameterTypeDescription
metaAoqExternalVideoFrameMeta / AoqExternalVideoEncodedFrameMetaFrame metadata (dimensions, format, and timestamp)
bufferUint8ArrayFrame 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
ParameterTypeDescription
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
ParameterTypeDescription
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
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
ParameterTypeDescription
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 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
ParameterTypeDescription
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. 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
}
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 AoqErrorCode). onWarning
onWarning: (code: number, message: string) => void
Engine warning callback. code corresponds to an AoqWarningCode value (see AoqWarningCode). 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.
ParameterTypeDescription
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 AoqAudioDeviceRouteType). 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
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)
The isBTScoMode field on Android is a mobile-only field and is not provided by Electron.
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.
relayEndpointsArray<AoqRelayEndpoint>Yes-List of relay access points
publishTracksArray<AoqTrackParam>Yes-List of local published tracks
subscribeTracksArray<AoqTrackParam>Yes-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
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
audioPublishStatsArray<AoqAudioPublishStats>Publishing statistics for audio
videoPublishStatsArray<AoqVideoPublishStats>Publishing statistics for video
dataMsgPublishStatsArray<AoqDataMsgPublishStats>Publishing statistics for data messages
audioSubscribeStatsArray<AoqAudioSubscribeStats>Subscribing statistics for audio
videoSubscribeStatsArray<AoqVideoSubscribeStats>Subscribing statistics for video
dataMsgSubscribeStatsArray<AoqDataMsgSubscribeStats>Subscribing 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
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 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
AoqErrorCodeOK0Success
AoqErrorCodeParamInvalid1Invalid parameter
AoqErrorCodeStateInvalid2Invalid state
AoqErrorCodeUnSupport3Not supported on the current platform or in the current mode
AoqErrorCodeAudio100Generic audio error
AoqErrorCodeAudioExternalBufferFull110External audio buffer is full
AoqErrorCodeAudioDevice120Generic audio device error
AoqErrorCodeAudioDeviceRecordingAuthFailed121Recording permission not granted
AoqErrorCodeAudioDeviceRecordingOccupied122Recording device is in use
AoqErrorCodeAudioDeviceRecordingBackgroundStart123Failed to start recording in the background
AoqErrorCodeAudioDeviceRecordingStartFail124Failed to start recording
AoqErrorCodeAudioDevicePlayoutOccupied125Playback device is in use
AoqErrorCodeAudioDevicePlayoutBackgroundStart126Failed to start playback in the background
AoqErrorCodeAudioDevicePlayoutStartFail127Failed to start playback
AoqErrorCodeVideo200Generic video error
AoqErrorCodeVideoExternalBufferFull210External video buffer is full
AoqErrorCodeVideoExternalCaptureNotEnabled211External video capture is not enabled
AoqErrorCodeVideoExternalEncoderNotEnabled212External video encoding is not enabled
AoqErrorCodeVideoDevice220Generic video device error
AoqErrorCodeVideoDeviceCameraOpenFail221Failed to open the camera
AoqErrorCodeVideoDeviceCameraAuthFailed222Camera permission not granted
AoqErrorCodeVideoDeviceCameraOccupied223Camera is in use
AoqErrorCodeVideoDeviceCameraRunningError224Camera runtime exception
AoqErrorCodeVideoCodec230Generic video codec error
AoqErrorCodeVideoCodecEncoderInitFail231Failed to initialize the video encoder
AoqErrorCodeVideoRender240Generic video rendering error
AoqErrorCodeVideoRenderCreateFail241Failed to create video rendering
AoqErrorCodeVideoRenderDrawError242Video 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 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.
isVoipMode / isDefaultSpeaker are mobile-only fields and are not provided by Electron.
AoqAudioCodecConfig
FieldTypeRequiredDefault valueDescription
trackTypeAoqTrackTypeNoAoqTrackTypeAudioTrack type
codecTypeAoqEncoderTypeNoAoqEncoderTypeAudioPCMCodec 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.
cameraDirection is a mobile-only field and does not exist on desktop platforms.
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 on the Electron side (excluding the texture / CVPixelBuffer formats on mobile platforms).
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
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
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.

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