GstInterpipe - Example 1: CCTV

From RidgeRun Developer Connection
Revision as of 19:01, 3 July 2017 by Dgarbanzo (talk | contribs) (Created page with "{{GstInterpipe Page| Interpipesrc Detailed Description| Advance Examples| This page...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Interpipesrc Detailed Description


Home

Advance Examples



This page contains an example to demonstrate the usage of the interpipesink and interpipesrc elements.

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 (simulating different real cameras connected to a system). 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 3 s) change the source pipeline it is listening to, so you will see a different video pattern on the rendering screen.

As you can view from the sample code, to change the the source pipeline that the sink pipeline is listening to, is as easy as change the value of the interpipesrc element "listen-to" property with the name of the desired interpipesink to be listened.

The below diagram illustrates the concept.


CCTV Example (Dynamic Switching) diagram


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. Build and install GStreamer Daemon (gstd): Building GStreamer Daemon.
  2. Copy the script code in a file
  3. Change the file permissions to be executable (chmod 777 <file.sh>)
  4. Run the script: ./<file.sh>




Interpipesrc Detailed Description


Home

Advance Examples