Difference between revisions of "GStreamer Daemon - Receiving Signals"

From RidgeRun Developer Connection
Jump to: navigation, search
(Created page with "{{GStreamer Daemon Page Top|Flush start/Flush stop|GStreamer Daemon - Enabling the Debug Subsystem|Enabling the Debug Subsystem...")
 
m
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{GStreamer Daemon Page Top|[[GStreamer Daemon - Flush start/Flush stop|Flush start/Flush stop]]|[[GStreamer Daemon - Enabling the Debug Subsystem|Enabling the Debug Subsystem]]|}}
+
{{GStreamer Daemon/Head | previous=Flush start/Flush stop | 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 mean of nofication, you cannot provide any response to the signal and some argument types may not have any sense on the client context.
+
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 on 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>.
+
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>.
  
{{GStreamer Daemon Page Bottom|[[GStreamer Daemon - Flush start/Flush stop|Flush start/Flush stop]]|[[GStreamer Daemon - Enabling the Debug Subsystem|Enabling the Debug Subsystem]]|}}
+
== List Element Signals ==
 +
In order to know the signals available for an element use the following command:
 +
  <b>list_signals <i>pipeline</i> <i>element</i> </b>
 +
      List the signals of <i>element</i> in <i>pipeline</i>.
 +
 
 +
== Connect to Signal ==
 +
To connect to a signal use the following command:
 +
  <b>signal_connect <i>pipeline</i> <i>element</i> <i>signal</i> </b>
 +
      Connect and wait for <i>signal</i> of <i>element</i> in <i>pipeline</i>.
 +
 
 +
Please notice this command blocks until the <i>signal</i> 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.
 +
  <b>signal_timeout <i>pipeline</i> <i>element</i> <i>signal</i> <i>timeout</i></b>
 +
      Wait timeout for <i>signal</i> of <i>element</i> in <i>pipeline</i>.
 +
 
 +
== Disconnect from Signal  ==
 +
If you want to stop waiting for a signal before the timeout time you can use the following command:
 +
  <b>signal_disconnect <i>pipeline</i> <i>element</i> <i>signal</i> </b>
 +
      Disconnect from <i>signal</i> of <i>element</i> in <i>pipeline</i>.
 +
 
 +
== Examples ==
 +
Following is an example showing how to use GStreamer Daemon signals support
 +
 
 +
<br>&rArr; ''Gstd Client Commands:''
 +
<syntaxhighlight lang="bash" line="line" style="background-color:lavender">
 +
# 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
 +
 
 +
</syntaxhighlight>
 +
 
 +
 
 +
<br>&rArr; '' Response ''
 +
<pre>
 +
signal_connect p identity handoff
 +
{
 +
  "code" : 0,
 +
  "description" : "Success",
 +
  "response" : {
 +
    "name" : "handoff",
 +
    "arguments" : [
 +
        {
 +
            "type" : "GstIdentity",
 +
            "value" : "(GstIdentity) identity"
 +
        },
 +
        {
 +
            "type" : "GstBuffer",
 +
            "value" : "((GstBuffer*) 0x7fd9d41452e0)"
 +
        }
 +
    ]
 +
}
 +
}
 +
 
 +
</pre>
 +
 
 +
== API Summary ==
 +
 
 +
<html>
 +
<table class="wikitable">
 +
  <tr>
 +
    <th>High Level Command</th>
 +
    <th>Low Level CRUD</th>
 +
    <th>Description</th>
 +
  </tr>
 +
  <tr>
 +
    <td> list_signals &#60;pipeline&#62; &#60;element&#62;</td>
 +
    <td>read /pipelines/&#60;pipeline&#62;/elements/&#60;element&#62;/signals</td>
 +
    <td>List the signals of an element in a pipeline.</td>
 +
  </tr>
 +
<tr>
 +
  <td> signal_connect &#60;pipeline&#62; &#60;element&#62; &#60;signal&#62;  </td>
 +
  <td> read /pipelines/&#60;pipeline&#62;/elements/&#60;element&#62;/signals/&#60;signal&#62;/callback </td>
 +
  <td> Waits for the signal of the element in pipeline to occurs and returns its arguments.  </td>
 +
</tr>
 +
<tr>
 +
  <td> signal_timeout &#60;pipeline&#62; &#60;element&#62; &#60;signal&#62; &#60;value&#62;</td>
 +
  <td> update /pipelines/&#60;pipeline&#62;/elements/&#60;element&#62;/signals/&#60;signal&#62;/timeout &#60;value&#62;</td>
 +
  <td> Change signal wait timeout to value </td>
 +
</tr>
 +
<tr>
 +
  <td> signal_disconnect &#60;pipeline&#62; &#60;element&#62; &#60;signal&#62;  </td>
 +
  <td> read /pipelines/&#60;pipeline&#62;/elements/&#60;element&#62;/signals/&#60;signal&#62;/disconnect </td>
 +
  <td> Disconnect from signal of the element in pipeline.  </td>
 +
</tr>
 +
</table>
 +
</html>
 +
 
 +
 
 +
{{GStreamer Daemon/Foot | previous=Flush start/Flush stop | next=Enabling the Debug Subsystem}}

Latest revision as of 15:09, 31 August 2020


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:

 1 # Create the pipeline that waits 10s between frames  
 2 pipeline_create p videotestsrc is-live=true ! identity sleep-time=10000000 signal-handoffs=true name=identity ! xvimagesink
 3 
 4 # List identity signals
 5 list_signals p identity
 6 
 7 # Play the pipeline
 8 pipeline_play p
 9 
10 # Waiting until identity pushes a buffer, connecting to handoff signal
11 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