GStreamer Daemon - Receiving Signals

From RidgeRun Developer Wiki



Previous: Flush start/Flush stop Index Next: Enabling the Debug Subsystem




Some GStreamer elements emit signals to notify events to the applications. GStreamer Daemon offers the capability to connect to a signal and wait for the signal event to happen. You must be aware that the GStreamer Daemon signal support is just a means of notification, you cannot provide any response to the signal and some argument types may not have any sense on the client context.

This wiki describes the basics of how to interact with GStreamer element signals. Specifically, how to wait for a signal. You'll find that the family of commands used to interact with signals are prefixed with signal_<action>.

List Element Signals

In order to know the signals available for an element use the following command:

 list_signals pipeline element 
     List the signals of element in pipeline.

Connect to Signal

To connect to a signal use the following command:

 signal_connect pipeline element signal 
     Connect and wait for signal of element in pipeline.

Please notice this command blocks until the signal is emitted or the timeout is reached.

Signal Timeout

You can specify a maximum wait time for a signal with the timeout parameter, the time argument is set on microseconds.

 signal_timeout pipeline element signal timeout
     Wait timeout for signal of element in pipeline.

Disconnect from Signal

If you want to stop waiting for a signal before the timeout time you can use the following command:

 signal_disconnect pipeline element signal 
     Disconnect from signal of element in pipeline.

Examples

Following is an example showing how to use GStreamer Daemon signals support


Gstd Client Commands:

# Create the pipeline that waits 10s between frames  
pipeline_create p videotestsrc is-live=true ! identity sleep-time=10000000 signal-handoffs=true name=identity ! xvimagesink

# List identity signals
list_signals p identity

# Play the pipeline
pipeline_play p

# Waiting until identity pushes a buffer, connecting to handoff signal
signal_connect p identity handoff



Response

signal_connect p identity handoff
{
  "code" : 0,
  "description" : "Success",
  "response" : {
    "name" : "handoff",
    "arguments" : [
        {
            "type" : "GstIdentity",
            "value" : "(GstIdentity) identity"
        },
        {
            "type" : "GstBuffer",
            "value" : "((GstBuffer*) 0x7fd9d41452e0)"
        }
    ]
}
}

API Summary

High Level Command Low Level CRUD Description
list_signals <pipeline> <element> read /pipelines/<pipeline>/elements/<element>/signals List the signals of an element in a pipeline.
signal_connect <pipeline> <element> <signal> read /pipelines/<pipeline>/elements/<element>/signals/<signal>/callback Waits for the signal of the element in pipeline to occurs and returns its arguments.
signal_timeout <pipeline> <element> <signal> <value> update /pipelines/<pipeline>/elements/<element>/signals/<signal>/timeout <value> Change signal wait timeout to value
signal_disconnect <pipeline> <element> <signal> read /pipelines/<pipeline>/elements/<element>/signals/<signal>/disconnect Disconnect from signal of the element in pipeline.



Previous: Flush start/Flush stop Index Next: Enabling the Debug Subsystem