GStreamer Daemon - Receiving Messages from the Bus

From RidgeRun Developer Connection
Revision as of 15:24, 29 June 2017 by Acervantes (talk | contribs)
Jump to: navigation, search

Flush start/Flush stop

Home

Enabling the Debug Subsystem


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 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.


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