Overview
Thegst-plugin-msgbroker package consists of two GStreamer elements that implement standard Publish/Subscribe messaging semantics:
qtimsgpub, which publishes messages to an external messaging backendqtimsgsub, which subsribes to messages from an external messaging backend
gst-plugin-msgbroker is a foundational messaging component in the Qualcomm QTI GStreamer plugin ecosystem. It enables seamless Pub/Sub communication by exposing a unified interface to the GStreamer pipeline.
At the architectural level, msgbroker functions as a high-level adapter that abstracts the underlying messaging protocol. Its extensible protocol adaptation layer is designed to support multiple Pub/Sub backends, allowing applications to integrate different messaging systems without changing the pipeline-facing interface.
By decoupling protocol-specific details from pipeline logic, gst-plugin-msgbroker allows GStreamer pipelines to operate cleanly as message producers or consumers while remaining portable across supported messaging implementations.
qtimsgpub: A publisher element that transmits pipeline data to an external message broker.
qtimsgsub: A subscriber element that receives external messages from the broker and injects them into the media pipeline.
-
MQTT
-
MQTT is a lightweight publish/subscribe messaging protocol optimized for machine-to-machine (M2M) telemetry in low-bandwidth environments. It uses a broker-based communication model that decouples clients from one another: publishers send messages to named topics, and subscribers receive messages from the topics to which they are subscribed.
Built on the libmosquitto Mosquitto C/C++ client library,
gst-plugin-msgbrokerabstracts the underlying complexity of the OASIS-standard MQTT protocol and provides application developers with a clean, high-level interface for integrating reliable publish/subscribe (Pub/Sub) messaging into GStreamer-based applications and pipelines.
-
MQTT is a lightweight publish/subscribe messaging protocol optimized for machine-to-machine (M2M) telemetry in low-bandwidth environments. It uses a broker-based communication model that decouples clients from one another: publishers send messages to named topics, and subscribers receive messages from the topics to which they are subscribed.
Built on the libmosquitto Mosquitto C/C++ client library,
-
KAFKA
- Kafka is a distributed streaming platform designed for building real-time data pipelines and streaming applications. Kafka uses a distributed commit log architecture where messages are persisted to disk and replicated across multiple brokers for fault tolerance. Kafka organizes messages into topics, which are partitioned and distributed across a cluster of brokers. Producers publish messages to topics, and consumers subscribe to topics as part of consumer groups, enabling scalable message processing with automatic load balancing and fault tolerance. Built on the librdkafka C client library, the kafka protocol library abstracts the underlying complexity of the Apache Kafka protocol and provides application developers with a clean, high-level interface for integrating reliable publish/subscribe (Pub/Sub) messaging into GStreamer-based applications and pipelines.

file topic to MQTT server. Subscriber pipeline receives messages from MQTT server via file topic and writes to disk.
Hierarchy
-
GObject
GstObject
GstElement
GstBaseSink
qtimsgpub -
GObject
GstObject
GstElement
GstBaseSrc
qtimsgsub
Pad Templates
- qtimsgpub plugin
- qtimsgsub plugin
Element Properties
Signals
MQTT Configuration File Options
This configuration file is provided to the element through theconfig property. The file uses a key=value format and supports comments starting with #.
Kafka Configuration File Options
This configuration file is provided to the element through theconfig property. The file uses an INI-style format with sections and supports comments starting with #.
The configuration file is organized into three sections:
[global-config]
Common configuration options that apply to both producers and consumers.[producer-config]
Configuration options specific to Kafka producers (qtimsgpub).[consumer-config]
Configuration options specific to Kafka consumers (qtimsgsub).Internal Architecture
The plugin follows a three-layer architecture that decouples the GStreamer element layer from the underlying messaging protocol: GStreamer Element Layer → Protocol Adaptor → Protocol Implementation. The adaptor layer dynamically loads protocol-specific implementations usingdlopen and dlsym, and exposes a unified interface to the element layer.

Protocol Adapter
GstMsgProtocol is responsible for loading the protocol-specific shared library based on the configured protocol name (for example, libgstqtimqttadaptor.so), resolving the unified entry symbol GST_PROTOCOL_CFUNC_SYMBOL, and forwarding upper-layer API calls to the corresponding protocol implementation.
GstProtocolCommonFunc defines the common protocol interface, including new, free, config, connect, disconnect, publish, and subscribe.
MQTT Protocol Implementation (GstMqtt)
GstMqtt (mqtt.c) implements the complete lifecycle of the Mosquitto clients and serves as the concrete MQTT protocol implementation behind the generic adaptor API.
- Dynamic Loading: The Mosquitto library is loaded at runtime using
dlopen("libmosquitto.so.1"), avoiding a hard build-time dependency. - Dual-role support: The implementation supports both publisher (
pub) and subscriber (sub) roles. The role parameter determines the operating mode and the corresponding callbacks are registered accordingly. - Asynchronous event handling: The Mosquitto network loop is started on a dedicated thread using
mosquitto_loop_start(), enabling non-blocking network I/O. - Callback flow: For subscribed messages, data is propagated through the callback chain
message_callback → gst_adaptor_sub_callback → gst_plugin_sub_callback, and is ultimately pushed into GstDataQueue for consumption by the GStreamer pipeline thread.
Message Delivery Flow
Publish Side Flow (qtimsgpub)
Subscribe Side Flow (qtimsgsub)
Kafka Protocol Implementation (GstKafka)
GstKafka (kafka.c) implements the complete lifecycle of the librdkafka client and serves as the concrete Kafka protocol implementation behind the generic adaptor API.
- Dual-role support: The implementation supports both producer (pub) and subscriber (sub) roles. The role parameter determines the operating mode, and the corresponding callbacks are registered accordingly.
-
Asynchronous event handling:
- For producers, the delivery callback (
gst_kafka_dr_msg_cb) is invoked asynchronously when messages are acknowledged by the broker. The producer usesrd_kafka_poll()to service delivery callbacks. - For consumers, a dedicated
GstTaskthread continuously polls the broker usingrd_kafka_consumer_poll()for new messages, enabling non-blocking network I/O.
- For producers, the delivery callback (
-
Callback flow: For subscribed messages, data is propagated through the callback chain:
gst_kafka_consume_message → gst_adaptor_sub_callback → gst_plugin_sub_callback, and is ultimately pushed into GstDataQueue for consumption by the GStreamer pipeline thread. - Message delivery tracking: The producer implementation uses a mutex-protected status variable to track message delivery state (submitted, success, or failure), ensuring synchronous confirmation of message delivery.
Message Delivery Flow
Publisher Side Flow(qtimsgpub)
Subscribe Side Flow(qtimsgsub)
Prerequisites & Assumptions
MQTT
- Mosquitto server installed and configured with optional username/password.
- Steps to run Mosquitto server:
- Installation steps refer to Download | Eclipse Mosquitto. (Simply:
sudo apt-get install mosquitto)
- Installation steps refer to Download | Eclipse Mosquitto. (Simply:
- Steps to run Mosquitto server:
The location of the configuration file
mosquitto.conf is displayed after this installation.mosquitto_passwd -c /etc/mosquitto/pwfile <username>, set password following the instructions on shell- Config
mosquitto.confwith below settings:
systemctl daemon-reload && systemctl restart mosquitto- Client has a valid plugin configuration file on device (/usr/local/config) with mqtt_version/username/password as needed.
- Network connectivity: client and server can ping each other; broker listens on 1883.
KAFKA
- Step 1: Get Kafka server running on a host machine.
- Download the latest Kafka release and extract it.
This has been tested with
v2.13-4.3.0- Step 2: Start the Kafka environment
- NOTE: Your local environment must have Java 17+ installed.
- Kafka can be run using local scripts and downloaded files or the docker image.
- Using downloaded files:
- Update config/server.properties.
- Generate a Cluster UUID
- Format Log Directories
- Start the Kafka Server
- Create topics with partitions based on your use case. This topic will be used to publish and consume messages later.
A topic has to be created before running any testcases.
- Step 3: Connect the device to the same netowork as the server. Server and client(qtimsgpub/qtimsgsub) should be able to ping each other.
Use Cases
1
Download Required Files
2
Copy files to device
3
Connect to device
4
Set environment variables
Run below command on your device
Subscriber pipeline should be run first and then launch the publisher pipeline from a different shell.
Publish CLI message -> Subscribe to file
This example demonstrates how a message provided through the message property is transmitted from the publisher pipeline to the subscriber pipeline.
fakesrc is used as a dummy source to establish the pipeline structure. The qtimsgpub element then publishes the literal message ("Command Message") specified through its message property to the cmd_topic topic on the configured MQTT or KAFKA broker.
Publisher Pipeline:
Use following for MQTT:
qtimsgsub to subscribe to messages published on the cmd_topic topic of the specified MQTT or KAFKA broker. The received messages are forwarded directly to filesink, which writes them to sub_message.txt.
Use following for MQTT:
Publish file contents → Subscribe to file
This example demonstrates the transmission of a text-file-based message from the publisher pipeline to the subscriber pipeline. The filemessage.txt is first created with the content "Message in file", and the publisher pipeline uses filesrc to read the file contents. The qtimsgpub element then publishes the data as a message to the file_topic topic on the configured MQTT/KAFKA broker. Similar to Use Case 1, the subscriber pipeline uses qtimsgsub to subscribe to the file_topic topic on the MQTT or KAFKA broker, and the received messages are written to sub_message.txt using filesink.

Publish AI Metadata packaged in JSON → Subscribe to AI Metadata
This example demonstrates how AI metadata produced after model inference can be transmitted from the publisher pipeline running the AI model to the subscriber pipeline. The subscriber pipeline can then implement custom logic to handle the AI event and trigger the appropriate action.
qtimsgpub publishes the resulting classification metadata to the MQTT or KAFKA broker in JSON format.
Publisher Pipeline:
Use following for MQTT:
qtimsgsub to subscribe to the detection_topic MQTT or KAFKA topic. The received data, expected to be in JSON format, is then written directly to sub.json through filesink.
Use following for MQTT:

