GstInterpipe - Simple Examples

From RidgeRun Developer Wiki
Revision as of 00:42, 1 July 2017 by Dgarbanzo (talk | contribs)



Interpipesrc Detailed Description


Home

Advance Examples



This page contains simple examples to demonstrate the usage of the interpipesink and interpipesrc elements.

GstInterpipe has many features that take place on runtime, so it is no possible to fully test it and demonstrate its capabilities using a quick gst-launch-1.0 prototype pipeline. In this case it will be necessary to develop a quick C or C++ application that integrates the GStreamer framework, but fortunately there is simpler and quicker alternative: GStreamer Daemon (Gstd-1.0). The perfect complement for the GstInterpipe is the GStreamer Daemon (Gstd-1.0). It gives the possibility to create a set of different independent pipelines, on which you can independently change their state or their element properties.

Based on the above explanation, the following samples were developed using the GStreamer Daemon (Gstd-1.0). To build and install gstd-1.0 you can follow this guide: Building GStreamer Daemon.

CCTV Example (Dynamic Switching)

This example demonstrate the usage of the dynamic switching property of the GstInterpipe. The objective of this sample is to show the simplicity that GstInterpipe offers in a real case of use where you have different source pipelines and one sink pipeline, and you want to alternate the source that is connected with the sink pipeline. For example a Closed Circuit Television (CCTV) system.

In this sample there are 3 source pipelines labeled as: scr_pipe_1, scr_pipe_2, scr_pipe_3. Each source pipeline is a videotestsrc with a different pattern. In the other side there is 1 sink pipeline, who is labeled as sink_pipe_4. This sink pipeline consists of a videosink that displays on screen the video buffers it receives.

In the sample the source pipeline periodically (each 8 s) change the source pipeline it is listening to, so you will see a different video pattern on the rendering screen.

The below diagram illustrates the concept.

!!! DIAGRAM Under Construction !!!

Sample bash script code:

#!/bin/bash

echo -e "\n ====== CCTV Example (Switch the scr_pipe to listen in runtime) ====== \n"

gstd &

sleep 2

echo -e "\n ====> Create the scr_pipe_1 \n"
gstd-client pipeline_create pipe_1_src videotestsrc pattern=ball is-live=true \
! "video/x-raw, framerate=15/1,width=640, height=480" ! queue ! interpipesink name=src_1 \
caps=video/x-raw,width=640,height=480,framerate=15/1 sync=false async=false

echo -e "\n ====> Create the scr_pipe_2 \n"
gstd-client pipeline_create pipe_2_src videotestsrc pattern=snow is-live=true \
! "video/x-raw, framerate=15/1, width=640, height=480" ! queue ! interpipesink name=src_2 \
caps=video/x-raw,width=640,height=480,framerate=15/1 sync=false async=false

echo -e "\n ====> Create the scr_pipe_3 \n"
gstd-client pipeline_create pipe_3_src videotestsrc pattern=smpte is-live=true \
! "video/x-raw, framerate=15/1, width=640, height=480" ! queue ! interpipesink name=src_3 \
caps=video/x-raw,width=640,height=480,framerate=15/1 sync=false async=false

echo -e "\n ====> Create the sink_pipe_4 (listener) \n"
gstd-client pipeline_create pipe_4_sink interpipesrc name=interpipesrc1 listen-to=src_1 \
is-live=true allow-renegotiation=true enable-sync=true ! queue \
! fpsdisplaysink async=false sync=false

echo -e "\n ====> Change to PLAYING STATE \n"
gstd-client pipeline_play pipe_1_src
gstd-client pipeline_play pipe_2_src
gstd-client pipeline_play pipe_3_src
gstd-client pipeline_play pipe_4_sink

echo -e "\n ====> Every 8 seconds the sink_pipe will change the src_pipe that is listening to \n"
echo -e "\n ====> Start listening to scr_pipe_1 \n"
sleep 8

gstd-client element_set pipe_4_sink interpipesrc1 listen-to src_2
echo -e "\n ====> Change to listening to scr_pipe_2 \n"
sleep 8

gstd-client element_set pipe_4_sink interpipesrc1 listen-to src_3
echo -e "\n ====> Change to listening to scr_pipe_3 \n"
sleep 8

gstd-client element_set pipe_4_sink interpipesrc1 listen-to src_1
echo -e "\n ====> Change to listening to scr_pipe_1 \n"
sleep 8

gstd-client element_set pipe_4_sink interpipesrc1 listen-to src_3
echo -e "\n ====> Change to listening to scr_pipe_3 \n"
sleep 8

gstd-client pipeline_delete pipe_1_src
gstd-client pipeline_delete pipe_2_src
gstd-client pipeline_delete pipe_3_src
gstd-client pipeline_delete pipe_4_sink

sleep 2

killall gstd

echo -e "\n ====> CCTV Example Finished!!! \n"


To run the sample follow this steps:

  1. Copy the script code in a file
  2. Change the file permissions to be executable (chmod 777 <file.sh>)
  3. Run the script: ./<file.sh>




Interpipesrc Detailed Description


Home

Advance Examples