GStreamer Daemon - Receiving Messages from the Bus
← Flush start/Flush stop |
⌂ Home |
→ Enabling the Debug Subsystem |
A GStreamer bus takes care of forwarding messages from a pipeline. A bus is needed so applications do not need to be thread-aware, even though the underlying pipeline is heavily threaded. For GStreamer Daemon, the concept of a bus is not important, but we use the terminology to maintain consistency with GStreamer. What is important is a pipeline can generate messages and GStreamer Daemon allows those messages to flow back to the client application.
This wiki describes the basics on how to interact with GStreamer bus properties. Specifically, how to receiving messages from the bus. You'll find that the family of commands used to interact with pipelines are prefixed with bus_<action>.
Read bus
In order to read a bus use the following command:
bus_read <name> Read the bus of the pipeline.
Read and filter bus
Sometimes is important to read and filter some messages from the bus, Gstd has the capability to read and filter (ie:error+warning+eos), In order to read and filter use the following command:
bus_filter <name> <filter> Read and filter the bus of the pipeline.
Bus timeout
This command will block while waiting for messages set with the bus_filter command. You can specify a maximum time with the timeout parameter, the time argument is set on nanoseconds.
bus_timeout <name> <time in nanoseconds> bus timeout of the pipeline.
Messages
There are lots of bus messages that are defined. The documentation tends to lag the implementation, so if you want the latest, most complete list of support bus messages, look at the table in gstd_msg_type.c.
The following table lists the supported bus messages. You can use either a hyphen or underscore in the bus message name.
Bus Message | Version | Meaning |
---|---|---|
eos | all | |
error | all | |
warning | all | |
info | all | |
tag | all | |
buffering | all | |
state_changed | all | |
state_dirty | all | |
step_done | all | |
clock_provide | all | |
clock_lost | all | |
new_clock | all | |
structure_change | all | |
stream_status | all | |
application | all | |
element | all | |
segment_start | all | |
segment_done | all | |
duration_changed | all | |
latency | all | |
async_start | all | |
async_done | all | |
request_state | all | |
step_start | all | |
qos | all | |
progress | all | |
toc | all | |
reset_time | all | |
stream_start | all | |
need_context | minor > 2 | |
have_context | minor > 2 | |
extended | minor > 4 | |
device_added | minor > 4 | |
device_removed | minor > 4 | |
property_notify | minor > 10 | |
stream_collection | minor > 10 | |
streams_selected | minor > 10 | |
redirect | minor > 10 |
Examples Application
A very useful application using a bus filter is when is needed to known if there is an error or EOS. These examples show how to use the bus filter and bus read.
Error bus filter
This example only filter errors with an infinite timeout.
⇒ Gstd Commands:
# Create the pipeline that generate an error pipeline_create p filesrc location=/tmp/test.avi ! identity error-after=2000 ! avidemux ! avdec_mpeg4 ! fpsdisplaysink # Filter only a message error bus_filter p error # Play the pipeline pipeline_play p # Waiting until bus read a message error bus_read p
Error bus filter and timeout
This example only filter errors with a 100s of timeout. If did get an error message it returns
⇒ Gstd Commands:
# Create the pipeline that generate an error pipeline_create p filesrc location=/tmp/test.avi ! identity error-after=2000 ! avidemux ! avdec_mpeg4 ! fpsdisplaysink # Filter only a message error bus_filter p error # wait 100s to read message error, if not, returns bus_timeout p 100000000000 # Play the pipeline pipeline_play p # Waiting until bus read a message error bus_read p
Error+EOS bus filter
This example filter errors and eos messages with an infinite timeout.
⇒ Gstd Commands:
# Create the pipeline that generate an eos pipeline_create p filesrc location=/tmp/test.avi ! avidemux ! avdec_mpeg4 ! fpsdisplaysink # Filter a message error and EOS message bus_filter p error+eos # Play the pipeline pipeline_play p # Waiting until bus read a message error or eos message bus_read p
← Flush start/Flush stop |
⌂ Home |
→ Enabling the Debug Subsystem |
- GStreamer Daemon Basics
- Building GStreamer Daemon
- Quick Start Guide
- Interacting with Pipelines
- Modifying Element Properties
- Sending Events
- Receiving Messages from the Bus
- Receiving Signals
- Enabling the Debug Subsystem
- Low-level Implementation for Applications
- Response Format
- API Reference
- Simple Examples
- Advanced Examples
- Troubleshooting
- Releases
- Licensing
- FAQ
- Contact Us