GstInterpipe - Dynamic Switching

From RidgeRun Developer Wiki




Previous: Buffer Forwarding Index Next: Caps Negotiation




This page contains a detailed description of the GstInterpipe Dynamic Switching feature.


One of the greatest strengths of GstInterpipe is the ability of an interpipesrc to switch between different interpipesinks at runtime. To do so, change the listen-to property. Similarly, disconnections and reconnections can be performed by clearing and setting the property accordingly. When performing dynamic switching, caps must be taken into consideration. Specifically, a switch can be performed to a node in two scenarios:

No other listeners
Caps are re-negotiated between the two pipelines, looking for the optimum caps.
Existing listeners
The sink pipeline must support the caps already configured by the node and listeners, otherwise, it'll fail.

The following figure illustrates this concept:

Dynamic Switch Scenarios


The caps re-negotiation capability can be disabled with the allow-renegotiation property. The following table summarizes the involved property:

Property
Element interpipesrc
Name allow-renegotiation
Description Allow the interpipesrc to renegotiate caps when attached to an interpipesink with different caps
Special Values
Table 1. Interpipesrc "allow-renegotiation" property description


The switch can be disabled entirely by setting the block-switch property. The following table summarizes the involved property:

Property
Element interpipesrc
Name block-switch
Description Allow changing the node a listener is currently listening to
Special Values
Table 2. Interpipesrc "block-switch" property description


Programatically, the dynamic switch can be performed as the following:

/* Create pipelines */
GstElement *pipe1 = gst_parse_launch ("videotestsrc ! interpipesink name=camera1", NULL);
GstElement *pipe2 = gst_parse_launch ("videotestsrc ! interpipesink name=camera2", NULL);
GstElement *pipe3 = gst_parse_launch ("interpipesrc name=src listen-to=camera1 ! fakesink", NULL);

/* Grab a reference to the interpipesrc */
GstElement *src = gst_bin_get_by_name(pipe3, "src");

/* Perform the switch */
g_object_set (src, "listen-to", "camera2", NULL);



Previous: Buffer Forwarding Index Next: Caps Negotiation