Skip to content

C++ API Documentation

Plugin Overview

qtivcomposer Plugin

The qtivcomposer plugin uses GPU hardware to merge multiple input video streams into a single output stream. Pad properties determine how the input buffers from each stream are composited into the output buffer.

AttributePurpose
PositionSets the X and Y placement of each input frame in the output image.
CropsOptionally crops the source image.
DimensionsScales frames up or down and adjusts the resolution.
RotateRotates a frame by right-angle increments.
Flip-horizontal / Flip-verticalControls how each input frame is mirrored in the composed output.
AlphaAdds an alpha-blending value to a frame.
Z orderControls layer stacking. By default, stacking follows sink pad creation order, such as sink_0, sink_1, and so on.
PropertyDescription
nameObject name.
- Access: read, write
- Type: string
- Default: "video_composer0"
parentParent object.
- Access: read, write
- Type: GstObject
engineBackend engine used for conversion.
- Access: read, write
- Type: GstVideoConverterBackend
- Default: 1, gles
- 1: gles uses the OpenGLES-based converter
- 2: fcv uses the FastCV-based converter
- Note: the Qualcomm Computer Vision SDK (fcv) backend is currently unsupported
latencyExtra delay for live pipelines, allowing upstream elements more time to generate buffers.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
start-time-selectionDetermines how output start time is selected.
- Access: read, write
- Type: GstAggregatorStartTimeSelection
- Default: 0, zero
- 0: zero starts at runtime 0
- 1: first starts from the first observed input runtime
- 2: set uses the start-time property
start-timeStart time used when start-time-selection is set to set.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 18446744073709551615
backgroundBackground color.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: unsigned integer
- Range: 0 to 4294967295
- Default: 4286611584

waylandsink Plugin

The waylandsink plugin is implemented on top of GStreamer's GstVideoSink class. It works with the Wayland Weston compositor, creates a window automatically, and renders incoming video frames into that window.

Qualcomm extends waylandsink with window-positioning support, a GBM-based zero-copy buffer backend, and an XDG shell backend.

tip

In the current release, the x, y, width, and height properties are not supported.

PropertyDescription
nameObject name.
- Access: read, write
- Type: string
- Default: "waylandsink0"
parentParent object.
- Access: read, write
- Type: GstObject
syncSynchronizes rendering to the pipeline clock.
- Access: read, write
- Type: boolean
- Default: true
max-latenessMaximum lateness allowed before a buffer is dropped, in nanoseconds. -1 means unlimited.
- Access: read, write
- Type: 64-bit integer
- Range: -1 to 9223372036854775807
- Default: 20000000
qosEmits QoS events upstream.
- Access: read, write
- Type: boolean
- Default: true
asyncTransitions to PAUSED asynchronously.
- Access: read, write
- Type: boolean
- Default: true
ts-offsetTimestamp offset in nanoseconds.
- Access: read, write
- Type: 64-bit integer
- Range: -9223372036854775808 to 9223372036854775807
- Default: 0
enable-last-sampleEnables the last-sample property.
- Access: read, write
- Type: boolean
- Default: true
last-sampleThe last sample received by the sink.
- Access: read
- Type: GstSample boxed pointer
blocksizeByte size of each buffer pull. 0 means default.
- Access: read, write
- Type: unsigned integer
- Range: 0 to 4294967295
- Default: 4096
render-delayExtra sink-side render delay in nanoseconds.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
throttle-timeInterval between rendered buffers. 0 disables throttling.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
max-bitrateMaximum rendered bitrate in bits per second. 0 disables the limit.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
show-preroll-frameControls whether preroll frames are rendered.
- Access: read, write
- Type: boolean
- Default: true
displayWayland display name used for the connection if not supplied through GstContext.
- Access: read, write
- Type: string
- Default: null
xdg-shellUses the XDG shell protocol.
- Access: read, write
- Type: boolean
- Default: true
fullscreenControls fullscreen display.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: boolean
- Default: false

qtivsplit Plugin

The qtivsplit plugin uses GPU hardware to split one input video stream into multiple output streams. The number of streams is user-defined and matches the number of source pads.

Each source pad's mode property determines how the input stream is split.

ModeDescription
noneCopies incoming frames from the sink pad to every source pad. Additional color conversion and scaling may be performed based on the negotiated GstCaps.
single-roi-metaChecks whether GstVideoRegionOfInterestMeta is present in the input buffer. The number of source pads must match the maximum expected ROI metadata entries per GstBuffer. If there are too few pads, unmatched ROI metadata is ignored.
batch-roi-metaProcesses ROI metadata attached to the buffer. Unlike single-roi-meta, each metadata entry is forwarded as an individual buffer.
PropertyDescription
nameObject name.
- Access: read, write
- Type: string
- Default: "videosplit0"
parentParent object.
- Access: read, write
- Type: GstObject
engineBackend engine used for conversion.
- Access: read, write
- Type: GstVideoConverterBackend
- Default: 1, gles
- 1: gles uses the OpenGLES-based converter
- 2: fcv uses the Qualcomm Computer Vision SDK-based converter
- Note: the Qualcomm Computer Vision SDK (fcv) backend is currently unsupported

qtivtransform Plugin

The qtivtransform plugin uses GPU hardware to scale, flip, rotate, crop, and color-convert input YUV or RGB frames according to element properties.

AttributePurpose
DestinationSets the X and Y position of the input frame in the output image and defines the output dimensions.
CropOptionally crops the source frame.
RotateRotates the frame by right-angle increments.
Flip-horizontal / Flip-verticalMirrors the frame horizontally or vertically.

If no transformation properties are specified on the source pad caps, the plugin negotiates capabilities identical to the input stream and runs in pass-through mode until the parameters change.

The plugin uses Qualcomm's IB2C library on the Adreno GPU to perform these transformations. The library is wrapped by the custom GstC2dVideoConverter abstraction, which exposes APIs for creating, configuring, and processing input and output buffers.

The custom GstImageBufferPool can allocate either GBM or ION output buffers, depending on downstream negotiation:

  • GBM allocation uses Qualcomm's libgbm implementation.
  • ION allocation is performed by issuing IOCTL commands to the kernel.
PropertyDescription
nameObject name.
- Access: read, write
- Type: string
- Default: "videotransform0"
parentParent object.
- Access: read, write
- Type: GstObject
engineBackend engine used for conversion.
- Access: read, write
- Type: GstVideoConverterBackend
- Default: 1, gles
- 1: gles uses the OpenGLES-based converter
- 2: fcv uses the Qualcomm Computer Vision SDK-based converter
- Note: the Qualcomm Computer Vision SDK (fcv) backend is currently unsupported
flip-horizontalMirrors the frame horizontally.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: boolean
- Default: false
flip-verticalMirrors the frame vertically.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: boolean
- Default: false
rotateRotates the frame.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: GstVideoTransformRotate
- Default: 0, none
- 0: none
- 1: 90CW
- 2: 90CCW
- 3: 180
cropInput crop rectangle in the format <X, Y, WIDTH, HEIGHT>.
- Note: this property does not support time synchronization.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: array of gint-typed GstValue entries
destinationOutput destination rectangle in the format <X, Y, WIDTH, HEIGHT>.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: array of gint-typed GstValue entries
backgroundBackground color.
- Access: read, write; modifiable in NULL, READY, PAUSED, and PLAYING
- Type: unsigned integer
- Range: 0 to 4294967295
- Default: 4286611584

qtisocketsink Plugin

The qtisocketsink plugin sends GstBuffer objects backed by file descriptors (FDs) to other processes through UNIX domain sockets. qtisocketsrc is the corresponding receiving element.

qtisocketsink requires a UNIX domain socket file with the .sock suffix. That file is passed through the socket property so the FD can be transferred.

Buffers received from other processes are tracked through reference counting. The counter is incremented or decremented as buffers are sent or returned through the socket.

Some commonly used qtisocketsink settings are listed below.

SettingDescription
asyncWhen set to false, the socket transitions to PAUSED asynchronously.
max-latenessMaximum lateness allowed before a buffer is dropped, in nanoseconds.
max-bitrateMaximum rendered bitrate in bits per second.
PropertyDescription
nameObject name.
- Access: read, write
- Type: string
- Default: "fdsocketsink0"
parentParent object.
- Access: read, write
- Type: GstObject
syncSynchronizes rendering to the pipeline clock.
- Access: read, write
- Type: boolean
- Default: true
max-latenessMaximum lateness allowed before a buffer is dropped. -1 means unlimited.
- Access: read, write
- Type: 64-bit integer
- Range: -1 to 9223372036854775807
- Default: -1
qosEmits QoS events upstream.
- Access: read, write
- Type: boolean
- Default: false
asyncTransitions to PAUSED asynchronously.
- Access: read, write
- Type: boolean
- Default: true
ts-offsetTimestamp offset in nanoseconds.
- Access: read, write
enable-last-sampleEnables the last-sample property.
- Access: read, write
- Type: boolean
- Default: true
last-sampleLast sample received by the sink.
- Access: read
- Type: GstSample boxed pointer
blocksizeByte size of each buffer pull. 0 means default.
- Access: read, write
- Type: unsigned integer
- Range: 0 to 4294967295
- Default: 4096
render-delayExtra sink-side render delay in nanoseconds.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
throttle-timeInterval between rendered buffers. 0 disables throttling.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
max-bitrateMaximum rendered bitrate in bits per second. 0 disables the limit.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
socketPath to the UNIX domain socket.
- Access: read, write; only modifiable in NULL or READY
- Type: string
- Default: null

qtisocketsrc Plugin

The qtisocketsrc plugin receives FD-backed GstBuffer objects from another process through a UNIX domain socket, typically from a qtisocketsink element.

The plugin requires a socket file with the .sock suffix. After the connection is established, it polls or waits for incoming GstBuffer objects and constructs buffer blocks from the received frame data.

Common buffer-related settings include:

  • blocksize: byte size of each read operation.
  • num-buffers: number of buffers pushed downstream before EOF is sent.
PropertyDescription
nameObject name.
- Access: read, write
- Type: string
- Default: "fdsocketsrc0"
parentParent object.
- Access: read, write
- Type: GstObject
blocksizeByte size of each read operation. -1 means default.
- Access: read, write
- Type: unsigned integer
- Range: 0 to 4294967295
- Default: 4096
num-buffersNumber of buffers output before EOS is sent. -1 means unlimited.
- Access: read, write
- Type: integer
- Range: -1 to 2147483647
- Default: -1
typefindRuns type finding before negotiation. Deprecated and currently non-functional.
- Access: read, write, deprecated
- Type: boolean
- Default: false
do-timestampApplies the current stream time to outgoing buffers.
- Access: read, write
- Type: boolean
- Default: false
socketPath to the UNIX domain socket.
- Access: read, write; only modifiable in NULL or READY
- Type: string
- Default: null
timeoutSocket connection timeout.
- Access: read, write; only modifiable in NULL or READY
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0

v4l2h264dec Plugin

The v4l2h264dec plugin decodes video streams through the V4L2 API. On supported platforms, it uses the hardware H.264 decoder to provide hardware-accelerated H.264 decoding.

tip

In the current release, only capture-io-mode and output-io-mode are writable. Both properties can only be used together with (5) dmabuf-import - GST_V4L2_IO_DMABUF_IMPORT.

PropertyDescription
automatic-request-sync-point-flagsFlags used when requesting sync points automatically.
- Access: read, write
- Type: GstVideoDecoderRequestSyncPointFlags
- Default: 0x00000003, corrupt-output+discard-input
automatic-request-sync-pointsRequests sync points automatically when needed.
- Access: read, write
- Type: boolean
- Default: false
capture-io-modeCapture-side I/O mode matched to the source pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
deviceDevice path.
- Access: read
- Type: string
- Default: "/dev/video0"
device-fdDevice file descriptor.
- Access: read
- Type: integer
- Range: -1 to 2147483647
- Default: -1
device-nameDevice name.
- Access: read
- Type: string
- Default: null
discard-corrupted-framesDrops frames marked as corrupted instead of outputting them.
- Access: read, write
- Type: boolean
- Default: false
extra-controlsExtra V4L2 control IDs for the device.
- Access: read, write
- Type: boxed GstStructure pointer
max-errorsMaximum consecutive decoder errors allowed before reporting a stream error.
- Access: read, write
- Type: integer
- Range: -1 to 2147483647
- Default: 10
min-force-key-unit-intervalMinimum interval between forced key-unit requests, in nanoseconds.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
nameObject name.
- Access: read, write
- Type: string
- Default: "v4l2h264dec0"
output-io-modeOutput-side I/O mode matched to the sink pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
parentParent object.
- Access: read, write
- Type: GstObject
qosHandles QoS events from downstream.
- Access: read, write
- Type: boolean
- Default: true

v4l2h265dec Plugin

The v4l2h265dec plugin decodes video streams through the V4L2 API. On supported platforms, it uses the hardware H.265 decoder to provide hardware-accelerated H.265 decoding.

  • V4L2 is the standard Linux interface for video devices and is responsible for video capture, encoding, and decoding.
  • H.265 provides better compression efficiency than H.264, and hardware decoding reduces system resource usage.
  • GstVideoDecoder is the GStreamer base class that keeps the plugin aligned with standard decoding flows.

tip

In the current release, only capture-io-mode and output-io-mode are writable. Both properties can only be used together with (5) dmabuf-import - GST_V4L2_IO_DMABUF_IMPORT.

PropertyDescription
automatic-request-sync-point-flagsFlags used when requesting sync points automatically.
- Access: read, write
- Type: GstVideoDecoderRequestSyncPointFlags
- Default: 0x00000003, corrupt-output+discard-input
automatic-request-sync-pointsRequests sync points automatically when needed.
- Access: read, write
- Type: boolean
- Default: false
capture-io-modeCapture-side I/O mode matched to the source pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
deviceDevice path.
- Access: read
- Type: string
- Default: "/dev/video0"
device-fdDevice file descriptor.
- Access: read
- Type: integer
- Range: -1 to 2147483647
- Default: -1
device-nameDevice name.
- Access: read
- Type: string
- Default: null
discard-corrupted-framesDrops frames marked as corrupted instead of outputting them.
- Access: read, write
- Type: boolean
- Default: false
extra-controlsExtra V4L2 control IDs for the device.
- Access: read, write
- Type: boxed GstStructure pointer
max-errorsMaximum consecutive decoder errors allowed before reporting a stream error.
- Access: read, write
- Type: integer
- Range: -1 to 2147483647
- Default: 10
min-force-key-unit-intervalMinimum interval between forced key-unit requests, in nanoseconds.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
nameObject name.
- Access: read, write
- Type: string
- Default: "v4l2h265dec0"
output-io-modeOutput-side I/O mode matched to the sink pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
parentParent object.
- Access: read, write
- Type: GstObject
qosHandles QoS events from downstream.
- Access: read, write
- Type: boolean
- Default: true

v4l2h264enc Plugin

The v4l2h264enc plugin encodes video through the V4L2 API. On supported platforms, it uses the hardware H.264 encoder to provide hardware-accelerated H.264 encoding.

  • V4L2 is the standard Linux interface for video devices and is responsible for video capture and encoding.
  • Hardware H.264 encoding improves throughput while reducing CPU usage compared with software encoding.
  • GstVideoEncoder is the base class that keeps the element compatible with standard GStreamer encoding flows.
PropertyDescription
capture-io-modeCapture-side I/O mode matched to the source pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
deviceDevice path.
- Access: read
- Type: string
- Default: "/dev/video1"
device-fdDevice file descriptor.
- Access: read
- Type: integer
- Range: -1 to 2147483647
- Default: -1
device-nameDevice name.
- Access: read
- Type: string
- Default: null
extra-controlsExtra V4L2 control IDs for the device.
- Access: read, write
- Type: boxed GstStructure pointer
min-force-key-unit-intervalMinimum interval between forced key-unit requests, in nanoseconds.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
nameObject name.
- Access: read, write
- Type: string
- Default: "v4l2h264enc0"
output-io-modeOutput-side I/O mode matched to the sink pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
parentParent object.
- Access: read, write
- Type: GstObject
qosHandles QoS events from downstream.
- Access: read, write
- Type: boolean
- Default: true
ControlTypeDescription
horizontal_flipbooleanvalue=0 by default; flags=execute-on-write
vertical_flipbooleanvalue=0 by default; flags=execute-on-write
rotateintegermin=0, max=270, step=90, value=0; flags=execute-on-write and modify-layout

v4l2h265enc Plugin

The v4l2h265enc plugin encodes video through the V4L2 API. On supported platforms, it uses the hardware H.265 encoder to provide hardware-accelerated H.265 encoding.

  • V4L2 is the standard Linux interface for video devices and is responsible for video capture and encoding.
  • Hardware H.265 encoding provides better compression efficiency than H.264 while reducing CPU usage through dedicated hardware blocks.
  • GstVideoEncoder is the base class that keeps the element compatible with standard GStreamer encoding flows.
PropertyDescription
capture-io-modeCapture-side I/O mode matched to the source pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
deviceDevice path.
- Access: read
- Type: string
- Default: "/dev/video1"
device-fdDevice file descriptor.
- Access: read
- Type: integer
- Range: -1 to 2147483647
- Default: -1
device-nameDevice name.
- Access: read
- Type: string
- Default: null
extra-controlsExtra V4L2 control IDs for the device.
- Access: read, write
- Type: boxed GstStructure pointer
min-force-key-unit-intervalMinimum interval between forced key-unit requests, in nanoseconds.
- Access: read, write
- Type: unsigned 64-bit integer
- Range: 0 to 18446744073709551615
- Default: 0
nameObject name.
- Access: read, write
- Type: string
- Default: "v4l2h265enc0"
output-io-modeOutput-side I/O mode matched to the sink pad.
- Access: read, write
- Type: GstV4l2IOMode
- Default: 0, auto
parentParent object.
- Access: read, write
- Type: GstObject
qosHandles QoS events from downstream.
- Access: read, write
- Type: boolean
- Default: true

C++ API Overview

StructureMemberTypeDescription
Imagedataconst char *Pointer to the image data buffer.
data_maskconst char *Pointer to the mask buffer. Reserved.
stream_idstringUnique stream identifier. Required and useful in multi-threaded scenarios.
widthintImage width.
heightintImage height.
width_paddingintWidth padding. Used only on 6490 QL.
height_paddingintHeight padding. Used only on 6490 QL.
sizeuint64_tBuffer size occupied by the image data.
fpsdoubleFrame rate.
idxuint64_tFrame counter.
frame_timestringFrame timestamp. Used only on 6490 QL.
enable_mask_drawingboolWhether mask drawing is enabled.
pipe_statusintPipeline status.
strideintStride value.
scanlineintScanline value.
ptsint64_tPresentation timestamp.
formatstringImage format.
Public FunctionDescription
void clogger(const char* path_and_prefix)Creates log files and sets the file path and filename prefix.
void set_log_level(GSTLogLevel log_level)Sets the log level.
typedef function<int8_t(const Image &)> GetImageCBCallback type used by stream-start APIs to provide image buffers to application code.
int start_stream(string stream_id, GetImageCB &cb)Starts a stream by stream_id. This is the recommended interface for most applications.
int start_stream_input_file(string file_path, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)Starts a file-based stream.
int start_stream_input_rtsp(string rtsp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)Starts an RTSP stream.
int start_stream_input_rtmp(string rtmp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)Starts an RTMP stream.
EnumMemberTypeDescription
GSTLogLevelSINFOuint8_tInfo log level.
SWARNINGuint8_tWarning log level.
SERRORuint8_tError log level.
SDEBUGuint8_tDebug log level.
SOFFuint8_tLogging disabled.
StreamTypeEMPTYuint8_tNo output protocol.
WAYLANDSINKuint8_tWayland display output.
RTSPSINKuint8_tRTSP output.
RTMPSINKuint8_tRTMP output.
MP4uint8_tMP4 file output.

Image Structure

Image describes frame metadata, buffer pointers, and pipeline-side image properties.

MemberTypeDescription
dataconst char *Pointer to the image data buffer.
data_maskconst char *Pointer to the mask data buffer. Reserved.
stream_idstringUnique stream identifier. Required and useful in multi-threaded scenarios.
widthintImage width.
heightintImage height.
width_paddingintWidth padding. Used only on 6490 QL.
height_paddingintHeight padding. Used only on 6490 QL.
sizeuint64_tBuffer size occupied by the image data.
fpsdoubleFrame rate.
idxuint64_tFrame counter.
frame_timestringFrame timestamp. Used only on 6490 QL.
enable_mask_drawingboolWhether mask drawing is enabled.
pipe_statusintPipeline status.
strideintStride value.
scanlineintScanline value.
ptsint64_tPresentation timestamp.
formatstringImage format.

warning

Unless otherwise stated, all definitions belong to the Aidlux::AidStream namespace:

cpp
using namespace Aidlux::AidStream;

Start a Stream by Stream ID

APIint start_stream(string stream_id, GetImageCB &cb)
DescriptionStarts a stream by stream_id. Stream definitions are read from /usr/local/share/aidstream-gst/conf/aidstream-gst.conf. Each stream_id must be unique. This is the strongly recommended interface for production use.
Parametersstream_id: unique stream configuration identifier.
cb: callback function. See GetImageCB.
For configuration details, see AidStream configuration reference.
Return Value0 for success, -1 for failure

Example:

cpp
int res = start_stream("stream1", my_cb);

Start a File Stream

APIint start_stream_input_file(string file_path, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
DescriptionStarts a file-based stream without relying on a configuration file.
Parametersfile_path: source MP4 file.
cb: callback function.
display_type: output type.
target_path: output target path.
stream_id: unique stream identifier.
Note: width and height are no longer effective.
Return Value0 for success, -1 for failure

Example:

cpp
int res = start_stream_input_file("./test.mp4", my_cb, StreamType::WAYLANDSINK, "<output-stream-url>/aidstream-gst-test-6");

Start an RTSP Stream

APIint start_stream_input_rtsp(string rtsp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
DescriptionStarts an RTSP stream without relying on a configuration file.
Parametersrtsp_addr: source RTSP address.
cb: callback function.
display_type: output type.
target_path: output target path.
stream_id: unique stream identifier.
Note: width and height are no longer effective.
Return Value0 for success, -1 for failure

Example:

cpp
int res = start_stream_input_rtsp("<input-stream-url>/h264/ch1/main/av_stream", my_cb, StreamType::RTSPSINK, "<output-stream-url>/aidstream-gst-test-3");

Start an RTMP Stream

APIint start_stream_input_rtmp(string rtmp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
DescriptionStarts an RTMP stream without relying on a configuration file.
Parametersrtmp_addr: source RTMP address.
cb: callback function.
display_type: output type.
target_path: output target path.
stream_id: unique stream identifier.
Note: width and height are no longer effective.
Return Value0 for success, -1 for failure

Example:

cpp
int res = start_stream_input_rtmp("<input-stream-url>/h264/ch1/main/av_stream", my_cb, StreamType::EMPTY, "<output-stream-url>/aidstream-gst-test-2");

Create Logs with clogger

APIvoid clogger(const char* path_and_prefix)
DescriptionCreates log files and sets the file path and filename prefix.
Parameterspath_and_prefix: log filename with path, for example "./aidclog_aidstream_".
Return ValueNone

Example:

cpp
const char* log_path = "./aidclog_aidstream_";
Aidlux::AidStream::clogger(log_path);

Set the Log Level

APIvoid set_log_level(GSTLogLevel log_level)
DescriptionSets the log level.
Parameterslog_level: a GSTLogLevel enum value. See GSTLogLevel.
Return ValueNone

Example:

cpp
Aidlux::AidStream::set_log_level(GSTLogLevel::SINFO);

GSTLogLevel Enum

MemberTypeDescription
SINFOuint8_tInfo log level.
SWARNINGuint8_tWarning log level.
SERRORuint8_tError log level.
SDEBUGuint8_tDebug log level.
SOFFuint8_tLogging disabled.

StreamType Enum

MemberTypeDescription
EMPTYuint8_tNo output protocol.
WAYLANDSINKuint8_tWayland display output.
RTSPSINKuint8_tRTSP output.
RTMPSINKuint8_tRTMP output.
MP4uint8_tMP4 file output.

ScenarioType Enum

MemberTypeDescription
Pulling_AintRead stream → (custom frame processing).
PullingEncode_BintEncode stream → stream output.
PullingInferenceOutput_CintRead stream → (decode) → AI processing → output results.
PullingInferenceEncode_DintRead stream → (decode) → AI processing → stream output.
PullingMultiCompInference_EintMerge multiple streams, run inference (Qualcomm QNN via qtimlqnn).
PullingMultiComp_FintMerge multiple streams into one.
PullingMultiCompInference_GintMerge multiple streams, run inference, save as MP4, and push RTSP.
PullingMultiCompInference_HintMerge multiple streams, run inference, save as MP4, and push RTSP.

TaskType Enum

MemberTypeDescription
MultiVideoDecodeintMulti-video decoding task.
MultiVideoEncodeintMulti-video encoding task.
VideoDecodeintVideo decoding task. Required for all stream pull operations.
InferenceCBintInference callback task. Invokes inference within the callback.
VideoEncodeintVideo encoding task. Required when encoding is needed.
CustomCBintCustom callback task. For user-defined callback operations.
InferenceQTIintQTI inference task using the Qualcomm qtimlqnn plugin.

AidStreamStatusCode-Enum

MemberTypeValueDescription
AS_OKint0Success.
AS_ERR_INVALID_PARAMint-1Invalid parameter.
AS_ERR_STREAM_EXISTSint-2Stream already exists.
AS_ERR_STREAM_NOT_FOUNDint-3Specified stream not found.
AS_ERR_PIPELINE_CREATEint-4Pipeline creation failed.
AS_ERR_NOT_RUNNINGint-5Stream is not in running state.
AS_ERR_NOT_SYNCEDint-6Stream is not synchronized.
AS_ERR_PUSH_BUFFERint-7Buffer push failed.
AS_ERR_INTERNALint-8Internal error.

HevcAuInfo Structure

HevcAuInfo describes the parsed HEVC access unit information.

MemberTypeDescription
has_vpsboolWhether the AU contains a VPS (Video Parameter Set).
has_spsboolWhether the AU contains an SPS (Sequence Parameter Set).
has_ppsboolWhether the AU contains a PPS (Picture Parameter Set).
is_keyframeboolWhether the AU is a keyframe.
has_sliceboolWhether the AU contains slice data.

Callback Function: GetImageCB

APItypedef std::function<int8_t(const Image &)> GetImageCB
DescriptionCallback type used by stream-start APIs to hand image buffers to application code. Users implement the callback themselves; the SDK only defines the callback signature.
ParametersThe callback receives an Image instance containing buffer pointers, dimensions, frame rate, and related metadata. See Image.
Return ValueUser-defined

Example:

cpp
int8_t my_get_img_cb(const Image &img)
{
    printf("width: %d, height: %d, fps: %f\n", img.width, img.height, img.fps);
    return 0;
}

AidStream Configuration Reference

When using int start_stream(string stream_id, GetImageCB &cb), input and output streams can be configured through /usr/local/share/aidstream-gst/conf/aidstream-gst.conf.

Requirements:

  • The configuration file must be in JSON format.
  • Parameters marked as required must be provided.
  • Parameter names are case-sensitive.
ParameterTypeRequiredDescription
streamsIdstringYesStream ID used to uniquely identify one stream configuration.
inputTypestringYesInput protocol type. Supported values: rtsp, rtmp, file. Unsupported values or invalid addresses cause startup failure.
inputAddrstringYesInput stream address.
outputTypestringYesOutput protocol type. Supported values: rtsp, wayland, mp4, empty. empty means output is sent to fakesink without pushing or rendering.
outputAddrstringYesOutput stream address.
decodeTypestringNoHardware decode format. Supported values: H264, H265.
encodeTypestringNoHardware encode format. Supported values: H264, H265.
audioboolNoEnables audio.
saveMp4boolNoSaves output as MP4.
outputFilestringNoOutput path for saved MP4 files.
widthintNoOutput video width.
heightintNoOutput video height.
fpsintNoOutput frame rate.
rolling_saveboolNoEnables rolling recording.
rollingFpsintNoFrame rate used for rolling recording.
manual_rebuildboolNoEnables manual pipeline rebuild.
network_pushboolNoEnables network pushing.

tip

Placeholder conventions:

  • <input-stream-url>: for example, rtsp://admin:aidlux123@192.168.110.234:554
  • <output-stream-url>: for example, rtsp://192.168.111.115:8554

Update these addresses according to your local network environment.

Reference example:

json
{
  "streams": [
    {
      "streamsId": "1",
      "properties": {
        "inputType": "rtsp",
        "inputAddr": "<input-stream-url>/h264/ch1/main/av_stream",
        "outputType": "rtsp",
        "outputAddr": "<output-stream-url>/aidstream-gst-rtsp-test-1",
        "decodeType": "H264",
        "encodeType": "H264"
      }
    }
  ]
}

StreamIns Structure

StreamIns is used as the parameter to start() and exposes a richer stream-configuration model for programmatic startup.

MemberTypeDefaultDescription
stream_idstring"empty"Unique stream identifier.
p_stream_idstring"empty_p"Parent stream identifier, used to link parent-child stream relationships.
inputTypestring""Input stream type: rtsp, rtmp, file, or usbcam.
inputAddrstring""Input source address.
outputTypestring""Output type: rtsp, wayland, mp4, or empty.
outputAddrstring""Output target address.
decodeTypestring"H264"Hardware decode format: H264 or H265.
encodeTypestring"H264"Hardware encode format: H264 or H265.
audio_switchboolfalseEnables audio.
save_mp4boolfalseSaves output as MP4.
network_pushboolfalseEnables network push output. When enabled, separate processing is triggered.
output_filestring"/tmp/saved_output.mp4"Output path for MP4 files.
widthint0Video width.
heightint0Video height.
fpsint0Video frame rate.
rolling_saveboolfalseEnables rolling recording.
rollingFpsint-1Frame rate used for rolling recording MP4 playback.
manual_rebuildbooltrueWhether to manually reconnect on EOS or error (true = manual, false = auto).

AidStreamEngine Class

AidStreamEngine provides a newer engine API driven by ScenarioType and TaskType.

MethodDescription
AidStreamEngine(ScenarioType scenario_type)Constructor. Initializes the engine with a scenario type.
~AidStreamEngine()Destructor.
int add_task(TaskType task_type, std::unordered_map<std::string, std::string>& config)Adds a processing task. Returns 0 on success, -1 on failure.
void set_callback(TaskType task_type, GetImageCB &callback)Sets the callback function for the specified task type.
int start()Starts the engine. Returns 0 on success.
static void stop()Stops the engine. This is a static method.

Start a Stream with StreamIns

APIint start(StreamIns &stream_ins, GetImageCB &cb)
DescriptionStarts a stream by configuring all stream parameters programmatically without a configuration file.
Parametersstream_ins: stream configuration structure containing the full stream definition.
cb: callback function.
Return Value0 for success, -1 or another AidStreamStatusCode value for failure
Refer to [AidStreamStatusCode Enum](#aidstreamstatuscode-enum)

Stop and Release a Stream

APIvoid gstreamer_pipeline_shutdown(string stream_id)
DescriptionStops a stream. You can stop a single stream by stream_id, or stop all streams by passing "all_stream".
Parametersstream_id: target stream ID or "all_stream".
Return ValueNone

Retrieve Rolling Recording Files

APIint get_rolling_save_video(std::string stream_id, std::string output_video, int delay_seconds = 5)
DescriptionRetrieves the MP4 file currently being generated by the rolling-recording pipeline, merging and exporting a video clip of the specified duration from the rolling buffer. Useful for persisting video clips after exception or event detection.
Parametersstream_id: stream identifier.
output_video: output video file path.
delay_seconds: delay in seconds before retrieval (default: 5).
Return Value0 for success, -1 for failure

USB Camera Interface

APIint start_stream_input_usbcam(StreamIns &stream_ins, GetImageCB cb, StreamType display_type, std::string stream_id)
DescriptionStarts stream processing from a USB camera.
Parametersstream_ins: USB camera initialization settings.
cb: callback function.
display_type: output stream type.
stream_id: unique stream identifier.
Return Value0 for success, -1 for failure

Splice Stream APIs

The splice-stream APIs are intended for raw-stream stitching and mixed display scenarios.

APIint start_splice_stream(std::string stream_id, GetImageCB &cb)
DescriptionStarts decoding and output for a splice stream.
Parametersstream_id: unique stream identifier.
cb: callback function.
Return Value0 for success, -1 for failure
APIint stop_splice_stream(std::string stream_id)
DescriptionStops a splice stream.
Parametersstream_id: unique stream identifier.
Return Value0 for success, -1 for failure
APIint decode_put_frame_splice(const uint8_t *data, size_t size, const std::string &stream_id, int64_t pts = -1, bool is_keyframe = false)
DescriptionPushes a video frame into the splice buffer.
Parametersdata: video frame data pointer.
size: data size.
stream_id: unique stream identifier.
pts: presentation timestamp (default: -1).
is_keyframe: whether this is a keyframe (default: false).
Return Value0 for success, -1 for failure
APIHevcAuInfo parse_hevc_au_info_splice(const uint8_t *data, size_t size)
DescriptionParses H.265 (HEVC) access unit metadata before splicing.
Parametersdata: HEVC data pointer.
size: data size.
Return ValueHevcAuInfo structure containing VPS/SPS/PPS/keyframe/slice information.

Get Stream Properties

APIint get_properties(std::string stream_id, StreamIns &stream_obj)
DescriptionReads the stream configuration properties for the specified stream_id from the configuration file and populates the StreamIns object.
Parametersstream_id: unique stream identifier.
stream_obj: reference to a StreamIns object to receive the configuration.
Return Value0 for success, -1 for failure

Get Stream Status

APIint get_stream_status()
DescriptionReturns the current running status of the stream. Returns 1 when the stream is actively running.
ParametersNone
Return Value1: stream is running, 0: stream is idle, -1: uninitialized

Get Image Data

APIcv::Mat get_data(int height, int width, char* data)
DescriptionConverts raw image data of the specified height and width into an OpenCV cv::Mat object in CV_8UC3 format.
Parametersheight: image height.
width: image width.
data: pointer to image data buffer.
Return ValueOpenCV cv::Mat object

V4L2 Image Conversion

Converts V4L2-sourced image data to OpenCV BGR-format cv::Mat objects.

APIint v4l2_get_mat(cv::Mat &destMat, Image img)
DescriptionConverts image data from Image into a BGR-format cv::Mat, cropping to the actual dimensions (removing padding). Designed for the 6490 QL platform.
ParametersdestMat: output BGR-format matrix.
img: Image object containing buffer data and dimensions.
Return Value0 for success, -1 for failure (empty data)
APIint v4l2_get_mat_ori(cv::Mat &destMat, Image img)
DescriptionConverts image data from Image into a BGR-format cv::Mat (preserves padding, no cropping). Designed for the 6490 QL platform.
ParametersdestMat: output BGR-format matrix.
img: Image object containing buffer data and dimensions.
Return Value0 for success, -1 for failure (empty data)

Start Audio Stream

APIint start_audio_stream(std::string stream_id, GetImageCB &cb)
DescriptionStarts audio stream processing, used alongside video streams.
Parametersstream_id: unique stream identifier.
cb: callback function.
Return Value0 for success, -1 for failure

Start Split Stream

APIint start_split_stream(std::string stream_id_1, GetImageCB &cb1, std::string stream_id_2, GetImageCB &cb2)
DescriptionStarts a single input stream that splits into two output streams. Both stream_id values must share the same parent stream identifier (p_stream_id) and input configuration.
Parametersstream_id_1: first output stream identifier.
cb1: callback for the first stream.
stream_id_2: second output stream identifier.
cb2: callback for the second stream.
Return Value0 for success, -1 for failure