Difference between revisions of "GStreamer Daemon - Receiving Messages from the Bus"

From RidgeRun Developer Connection
Jump to: navigation, search
m
Line 29: Line 29:
  
 
The following table lists the supported bus messages.  You can use either a hyphen or underscore in the bus message name.
 
The following table lists the supported bus messages.  You can use either a hyphen or underscore in the bus message name.
<nowiki>
+
 
{| border=2 </nowiki>
+
{| border=2
 
! Bus Message !! Version !! Meaning
 
! Bus Message !! Version !! Meaning
 
|-
 
|-

Revision as of 18:12, 29 January 2018


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:

 1 # Create the pipeline that generate an error  
 2 pipeline_create p filesrc location=/tmp/test.avi ! identity error-after=2000 ! avidemux ! avdec_mpeg4 ! fpsdisplaysink 
 3 
 4 # Filter only a message error
 5 bus_filter p error
 6 
 7 # Play the pipeline
 8 pipeline_play p
 9 
10 # Waiting until bus read a message error 
11 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:

 1 # Create the pipeline that generate an error  
 2 pipeline_create p filesrc location=/tmp/test.avi ! identity error-after=2000 ! avidemux ! avdec_mpeg4 ! fpsdisplaysink 
 3 
 4 # Filter only a message error
 5 bus_filter p error
 6 
 7 # wait 100s to read message error, if not, returns 
 8 bus_timeout p 100000000000 
 9 
10 # Play the pipeline
11 pipeline_play p
12 
13 # Waiting until bus read a message error 
14 bus_read p

Error+EOS bus filter

This example filter errors and eos messages with an infinite timeout.


Gstd Commands:

 1 # Create the pipeline that generate an eos  
 2 pipeline_create p filesrc location=/tmp/test.avi  ! avidemux ! avdec_mpeg4 ! fpsdisplaysink 
 3 
 4 # Filter a message error and EOS message
 5 bus_filter p error+eos
 6 
 7 # Play the pipeline
 8 pipeline_play p
 9 
10 # Waiting until bus read a message error or eos message
11 bus_read p


Flush start/Flush stop

Home

Enabling the Debug Subsystem