Skip to main content
AOQ SDK Features

Video features

AOQ SDK video capture, preview, and encoding configuration

The AOQ Client SDK provides comprehensive video capabilities, covering video capture, rendering, codec configuration, frame data callbacks, and external video input. This document introduces common video features across Android (Java), iOS (Objective-C), and HarmonyOS (ArkTS).

1. Video capture

1.1 Overview

Video capture opens the device camera and feeds real-time video frames into the SDK encoding pipeline. The SDK supports two capture modes:
  • Internal capture (default): The SDK automatically manages the camera -- opening it, capturing frames, and closing it. Supports switching between front and rear cameras.
  • External capture: The application manages the camera or other video source. Captured frames are fed into the SDK via pushExternalVideoCapturedFrame.

1.2 Capture configuration parameters

ParameterTypeDefaultDescription
widthint1280Capture width in pixels. Not used in external capture mode.
heightint720Capture height in pixels. Not used in external capture mode.
fpsint15Capture frame rate. In external capture mode, the frame rate is determined by how fast frames are pushed.
isExternalboolfalseWhether to use external capture mode.
cameraDirectionAoqCameraDirectionFront(0)Camera direction. Not used in external capture mode.

1.3 Camera direction enum

Enum valueNumberDescription
AoqCameraDirectionFront0Front-facing camera
AoqCameraDirectionBack1Rear-facing camera

1.4 API reference

FunctionAndroidiOSHarmonyOS
Start capturestartVideoCapture(config)startVideoCapture:config:startVideoCapture(config)
Stop capturestopVideoCapture()stopVideoCapturestopVideoCapture()
Switch cameraswitchCamera(direction)switchCamera:switchCamera(direction)

1.5 Example

  • Android
  • iOS
  • HarmonyOS
AoqVideoCaptureConfig config = new AoqVideoCaptureConfig();
config.width = 1280;
config.height = 720;
config.fps = 15;
config.cameraDirection = AoqCameraDirection.AoqCameraDirectionFront;
engine.startVideoCapture(config);

2. Video rendering

2.1 Overview

Video rendering displays locally captured or remotely received video frames on screen. The SDK supports setting a local preview window and a remote rendering window. Use trackType to distinguish between the video stream (Video) and the screen share stream (Screen).

2.2 Render modes

Enum valueNumberDescription
AoqRenderModeAuto0Automatic mode
AoqRenderModeStretch1Stretch to fill. The image may be distorted.
AoqRenderModeFill2Fit with letterboxing. The full image is shown.
AoqRenderModeCrop3Crop mode. Parts of the image may be cut off.

2.3 Canvas configuration

ParameterTypeDefaultDescription
viewPlatform viewnullRendering view. Android: SurfaceView or TextureView. iOS: UIView. HarmonyOS: XComponent.
renderModeAoqRenderModeAuto(0)Render display mode

2.4 API reference

FunctionAndroidiOSHarmonyOS
Set local previewsetLocalView(trackType, canvas)setLocalView:trackType:canvas:setLocalView(trackType, canvas)
Set remote viewsetRemoteView(trackType, canvas)setRemoteView:trackType:canvas:setRemoteView(trackType, canvas)
Platform differences: Android uses SurfaceView or TextureView as the rendering container. iOS uses UIView (wrapped internally by AoqRenderView with Metal acceleration). HarmonyOS uses XComponent (managed by AoqXComponentController for native rendering).

3. Video codec configuration

3.1 Overview

Configure video encoding parameters including encoding format, resolution, frame rate, bitrate, keyframe interval, mirroring, and orientation. Use trackType to apply different encoding configurations to the video track and the screen share track.

3.2 Encoding configuration parameters

ParameterTypeDefaultDescription
trackTypeAoqTrackTypeVideo(1)Track type: Video
codecTypeAoqEncoderTypeVideoH264(3)Encoding format
widthint720Encoded width
heightint1280Encoded height
fpsint5Encoding frame rate
bitrateint500000Target bitrate (bps)
minBitrateint128000Minimum bitrate (bps)
keyframeIntervalint2Keyframe interval (seconds)
mirrorModeAoqMirrorModeDisabled(0)Mirror mode
orientationModeAoqOrientationModeAuto(0)Orientation mode
isExternalboolfalseExternal encoding mode. When true, the application pushes pre-encoded frames.

3.3 Encoding format enum

Enum valueNumberDescription
AoqEncoderTypeVideoH2643H.264 encoding
AoqEncoderTypeVideoJpeg4JPEG encoding (for external encoded frames)

3.4 Mirror mode

Enum valueNumberDescription
AoqMirrorModeDisabled0Mirroring disabled
AoqMirrorModeEnabled1Mirroring enabled

3.5 Orientation mode

Enum valueNumberDescription
AoqOrientationModeAuto0Automatic orientation
AoqOrientationModePortrait1Portrait orientation
AoqOrientationModeLandscape2Landscape orientation

3.6 API reference

FunctionAndroidiOSHarmonyOS
Set encoding configsetVideoEncoderConfig(config)setVideoEncoderConfig:setVideoEncoderConfig(config)

4. External video frame input

4.1 Overview

External video frame input lets your application push custom video frame data into the SDK for external capture or external encoding scenarios. Two push methods are supported:
  • Push raw frames: Push unencoded pixel data (I420, NV12, NV21, BGRA, RGBA, and similar formats) to the SDK. The SDK encodes the data.
  • Push encoded frames: Push already-encoded data (for example, JPEG) directly to the SDK. The SDK packages and sends it without re-encoding.
Routing is controlled by trackType: AoqTrackTypeVideo routes to the video capture track; AoqTrackTypeScreen routes to the screen share track.

4.2 Pixel format enum

Enum valueNumberDescriptionPlatform support
AoqVideoPixelFormatI4201I420 tri-planarAll platforms
AoqVideoPixelFormatNV122NV12 bi-planarAll platforms
AoqVideoPixelFormatNV213NV21 bi-planarAll platforms
AoqVideoPixelFormatBGRA4BGRA packedAll platforms
AoqVideoPixelFormatRGBA5RGBA packedAll platforms
AoqVideoPixelFormatCVPixelBuffer6Apple zero-copyiOS only
AoqVideoPixelFormatTextureOES7OES textureAndroid only
AoqVideoPixelFormatTexture2D82D textureAndroid only

4.3 Raw video frame data structure (AoqVideoFrame)

FieldTypeDescription
formatAoqVideoPixelFormatPixel format
widthintWidth in pixels
heightintHeight in pixels
databyte[] / ArrayBufferPacked format data (NV12/NV21/BGRA/RGBA)
dataY / dataU / dataVbyte[] / ArrayBufferI420 tri-planar data
strideY / strideU / strideVintI420 tri-planar strides
textureIdintTexture ID (valid for Android TextureOES/Texture2D)
transformMatrixfloat[16]4x4 texture transform matrix (Android)
eglContextEGLContextShared EGL context (Android)
pixelBufferCVPixelBufferRefApple zero-copy (iOS)
timeStamplongTimestamp in ms. If 0, the SDK uses the local clock.

4.4 Encoded video frame data structure (AoqVideoEncodedFrame)

FieldTypeDefaultDescription
codecAoqVideoCodecTypeJPEG(0)Encoding format
databyte[] / ArrayBuffer-Encoded data
widthint-Width in pixels
heightint-Height in pixels
timeStamplong0Timestamp in ms

4.5 API reference

FunctionAndroidiOSHarmonyOS
Push raw framepushExternalVideoCapturedFrame(trackType, frame)pushExternalVideoCapturedFrame:frame:pushExternalVideoCapturedFrame(trackType, frame)
Push encoded framepushExternalVideoEncodedFrame(trackType, frame)pushExternalVideoEncodedFrame:frame:pushExternalVideoEncodedFrame(trackType, frame)

5. Video frame callbacks

5.1 Overview

Video frame callbacks let you obtain raw frame data at different points in the video pipeline, for use in video analysis, custom processing, recording, and similar scenarios. Both read-only and read-write modes are supported. In read-write mode, you can modify the frame data and write it back to the SDK.

5.2 Supported data source positions

Data sourceEnum valueDescription
Captured0Video data after capture, before pre-processing
PreEncode1Video data before encoding, after pre-processing
Remote2Remote video data after decoding, before rendering

5.3 Callback configuration parameters

ParameterTypeDefaultDescription
formatAoqVideoPixelFormatI420(1)Pixel format for the callback data
alignmentAoqVideoObserverAlignmentDefault(0)Width alignment policy
modeAoqVideoObserverModeReadOnly(0)Read-only (0) or read-write (1) mode
mirrorAppliedboolfalseWhether to apply mirroring to the callback data

5.4 Width alignment enum

Enum valueNumberDescription
AoqVideoObserverAlignmentDefault0Default alignment
AoqVideoObserverAlignmentEven12-byte alignment
AoqVideoObserverAlignment424-byte alignment
AoqVideoObserverAlignment838-byte alignment
AoqVideoObserverAlignment16416-byte alignment

5.5 Usage steps

  1. Register the observer: Call setVideoFrameObserver to set the video frame callback listener.
  2. Enable the data source: Call enableVideoFrameObserver to select the data source position and start callbacks.
  3. Handle callback data: Obtain frame data inside the callback. Frame data is only valid during the callback. Copy it if you need it asynchronously.

5.6 API reference

FunctionAndroidiOSHarmonyOS
Register observersetVideoFrameObserver(listener)setVideoFrameObserver:setVideoFrameObserver(observer)
Enable callbacksenableVideoFrameObserver(enabled, source, config)enableVideoFrameObserver:videoSource:config:enableVideoFrameObserver(enabled, source, config)

5.7 Callback methods

CallbackAndroidiOSHarmonyOS
Captured dataonCapturedVideoFrame(frame)onCapturedVideoFrame:onCapturedVideoFrame(frame)
Pre-encode dataonPreEncodeVideoFrame(trackType, frame)onPreEncodeVideoFrame:frame:onPreEncodeVideoFrame(trackType, frame)
Remote dataonRemoteVideoFrame(trackType, frame)onRemoteVideoFrame:frame:onRemoteVideoFrame(trackType, frame)
Returning true/YES from a callback indicates that the data has been modified and should be written back to the SDK. This only takes effect in ReadWrite mode with I420 format.

7. Media stream sending control

7.1 Overview

Control whether local media streams are sent. Use trackType to target a specific track (Audio, Video, or Screen). When sending is disabled, capture and encoding continue, but data is not sent to the remote end.

7.2 API reference

FunctionAndroidiOSHarmonyOS
Control stream sendingenableSendMediaStream(trackType, enable)enableSendMediaStream:enable:enableSendMediaStream(trackType, enable)

7.3 Track type enum

Enum valueNumberDescription
AoqTrackTypeAudio0Audio track
AoqTrackTypeVideo1Video track
AoqTrackTypeData2Data track

8. Video device state monitoring

8.1 Overview

The SDK automatically monitors camera state changes and notifies the application layer through the onVideoDeviceStateChanged callback.

8.2 Device state codes

State codeValueDescription
AoqVideoDeviceNone0Initial state
AoqVideoDeviceCaptureStarting1Capture starting
AoqVideoDeviceCaptureStarted2Capture started
AoqVideoDeviceCaptureStopping3Capture stopping
AoqVideoDeviceCaptureStopped4Capture stopped
AoqVideoDeviceCaptureFail5Capture failed

8.3 Callback reference

CallbackAndroidiOSHarmonyOS
Device state changeonVideoDeviceStateChanged(state)onVideoDeviceStateChanged:onVideoDeviceStateChanged(state)

9. Video error and warning codes

9.1 Video error codes

Error codeValueDescription
AoqErrorCodeVideo200General video error
VideoExternalBufferFull210Video external buffer full
VideoDevice220General video device error
CameraOpenFail221Failed to open camera
CameraAuthFailed222Camera permission denied
CameraOccupied223Camera in use by another process
CameraRunningError224Camera running error
VideoCodec230General video codec error
EncoderInitFail231Encoder initialization failed
VideoRender240General video rendering error
RenderCreateFail241Renderer creation failed
RenderDrawError242Rendering draw error
Screen300General screen share error
Additional Android error codes: ScreenPermissionDenied(310) -- screen share permission denied; ScreenForegroundServiceFailed(311) -- foreground service failed to start.

9.2 Video warning codes

Warning codeValueDescription
AoqWCVideo200General video warning
CameraEnumerateError201Camera enumeration error
EncoderSwitched202Encoder switched warning
RenderDowngrade203Render downgrade warning

Appendix: Complete video API method list

CategoryMethodDescription
Capture controlstartVideoCaptureOpen video capture device
Capture controlstopVideoCaptureClose video capture device
Capture controlswitchCameraSwitch between front and rear camera
Rendering controlsetLocalViewSet local preview window
Rendering controlsetRemoteViewSet remote rendering window
CodecsetVideoEncoderConfigSet video encoding parameters
External inputpushExternalVideoCapturedFramePush raw video frame
External inputpushExternalVideoEncodedFramePush encoded video frame
Screen sharestartScreenCaptureStart screen capture
Screen sharestopScreenCaptureStop screen capture
Stream controlenableSendMediaStreamControl media stream sending
Frame callbackssetVideoFrameObserverRegister video frame observer
Frame callbacksenableVideoFrameObserverEnable or disable video frame callbacks
Video features - QwenCloud