Skip to content

Commit

Permalink
Trying to simplify (and document) the pipelines in gstcase{.h,.c}
Browse files Browse the repository at this point in the history
  • Loading branch information
mithro committed Dec 27, 2014
1 parent 9cf4cf5 commit 01c92b6
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 7 deletions.
22 changes: 15 additions & 7 deletions run-demo.sh
Expand Up @@ -4,24 +4,32 @@

cd tools

./gst-switch-srv &
sleep 5
./gst-switch-ui &
./gst-switch-srv -v &
sleep 5
gst-launch-1.0 videotestsrc pattern=1 is-live=1 \
! timeoverlay \
! video/x-raw, width=300, height=200 \
! gdppay \
! tcpclientsink port=3000 \
&

sleep 20

gst-launch-1.0 videotestsrc pattern=18 is-live=1 \
! timeoverlay \
! video/x-raw, width=300, height=200 \
! gdppay \
! tcpclientsink port=3000 \
&
gst-launch-1.0 videotestsrc pattern=5 is-live=1 \
! timeoverlay \
! video/x-raw, width=300, height=200 \
! gdppay \
! tcpclientsink port=3000 \
&
gst-launch-1.0 videotestsrc pattern=6 is-live=1 \
! timeoverlay \
! video/x-raw, width=300, height=200 \
! gdppay \
! tcpclientsink port=3000 \
&


./gst-switch-ui -v &
sleep 5
193 changes: 193 additions & 0 deletions tools/gstcase.c
Expand Up @@ -277,10 +277,203 @@ gst_case_set_property (GstCase * cas, guint property_id,
* @return A GString instance representing the pipeline string.
*
* Retreiving the GstCase pipeline string, it's invoked by GstWorker.
--case(input_xxx)--
TCP server (source) -> gdpdepay -> input_xxx
--case(X)--
input_xxx -\
+-> branch_xxx
+-> composite_(a|b|audio)
--case(branch_xxx)--
branch_xxx -\
*-> preview video -> gdppay -> TCP server (sink)
*-> preview audio -> gdppay -> TCP server (sink)
--composite+scale--
X -> composite_a -> composite_a_scaled -\
+-> composite_out
+-> composite_video
X -> composite_b -> composite_b_scaled -/
--recorder--
composite_video -> video output (mjpg) -\ /-> TCP server (sink)
>- mux -> tee -+
composite_audio -> audio output (aac) -/ \-> File output
---
*/
static GString *
gst_case_get_pipeline_string (GstCase * cas)
{
// These restrictions come from the interaudiosink
const char* audio_restriction =
" audio/x-raw,format=S16LE,rate=48000,channels=2 !";

// Video restrictions are set by the video format and the intervideosink
const char* video_restriction =
" video/x-raw,width=%d,height=%d !", cas->width, cas->height;
// format: I420
// width: [ 1, 2147483647 ]
// height: [ 1, 2147483647 ]
// framerate: [ 0/1, 2147483647/1 ]


// input_3003:
// giostreamsrc name=source
// interaudiosink name=sink channel=input_3003
// source. ! sink.

// case-0:
// interaudiosrc do-timestamp=true name=source channel=input_3003
// source. ! tee name=s
// s. ! queue2 ! interaudiosink name=sink2 channel=composite_audio
// s. ! queue2 ! interaudiosink name=sink1 channel=branch_3003

// branch_3003:
// interaudiosrc do-timestamp=true name=source channel=branch_3003
// tcpserversink name=sink port=300
// source. ! voaacenc ! gdppay ! sink.

// scale:
// intervideosrc name=source_a channel=composite_a
// intervideosrc name=source_b channel=composite_b
// intervideosink name=sink_a sync=false channel=composite_a_scaled
// intervideosink name=sink_b sync=false channel=composite_b_scaled
//
// source_a. ! video/x-raw,width=300,height=200 ! queue2 !
// videoscale ! video/x-raw,width=150,height=100 ! sink_a.
//
// source_b. ! video/x-raw,width=300,height=200 ! queue2 !
// videoscale ! video/x-raw,width=150,height=100 ! sink_b.

// composite:
// intervideosrc name=source_a channel=composite_a_scaled
// intervideosrc name=source_b channel=composite_b_scaled
// intervideosink name=out channel=composite_out

// source_a. !
// video/x-raw,width=150,height=100 !
// queue2 ! mix.sink_0
// source_b. !
// video/x-raw,width=150,height=100 !
// queue2 ! mix.sink_1

// videomixer name=mix
// sink_0::xpos=0 sink_0::ypos=50 sink_0::zorder=0
// sink_1::xpos=151 sink_1::ypos=50 sink_1::zorder=1
// mix. ! video/x-raw,width=300,height=200 ! tee name=result

// result. ! queue2 ! out.

// output:
// intervideosrc name=source channel=composite_out
// tcpserversink name=sink port=3001
// source. ! video/x-raw,width=300,height=200 ! gdppay ! sink.

// recorder:
// intervideosrc name=source_video channel=composite_video
// interaudiosrc name=source_audio channel=composite_audio
//
// source_video. ! video/x-raw,width=300,height=200 ! queue2 ! vp8enc ! mux.
// source_audio. ! queue2 ! voaacenc ! mux.
// avimux name=mux ! tee name=result
//
// result. ! queue2 ! ...
// result. ! queue2 ! gdppay ! tcp_sink.
// tcpserversink name=tcp_sink sync=false port=3002



switch (cas->type) {
case GST_CASE_INPUT_AUDIO:
ASSERT_EQ(cas->serve_type, GST_SERVE_AUDIO_STREAM);

" giostreamsrc name=source ! gdpdepay !"
audio_restriction,
" intervideosink name=sink channel=input_%d ", cas->sink_port

break;
case GST_CASE_INPUT_VIDEO:
ASSERT_EQ(cas->serve_type, GST_SERVE_AUDIO_STREAM);

" giostreamsrc name=source ! gdpdepay !"
video_restriction,
" intervideosink name=sink channel=input_%d", cas->sink_port

break;

case GST_CASE_COMPOSITE_VIDEO_A:
width = cas->a_width;
height = cas->a_height;
channel = "a";
break;

case GST_CASE_COMPOSITE_VIDEO_B:
width = cas->b_width;
height = cas->b_height;
channel = "b";
break;

" intervideosrc name=sink channel=input_%d ! "
" videoscale ! video/x-raw,width=%d,height=%d", width, height

// channel in ["a", "b", "audio"]
"tee name=s"
" s. ! queue2 ! intervideosink name=sink1 channel=branch_%d", cas->sink_port
" s. ! queue2 ! intervideosink name=sink2 channel=composite_%s", channel


case GST_CASE_COMPOSITE_AUDIO:
" interaudiosrc name=source channel=%s_%d !"

"tee name=s"
" s. ! queue2 ! interaudiosink name=sink1 channel=branch_%d", cas->sink_port
" s. ! queue2 ! interaudiosink name=sink2 channel=composite_audio", channel

break;


case GST_CASE_PREVIEW:


case GST_CASE_BRANCH_VIDEO_A:
case GST_CASE_BRANCH_VIDEO_B:
case GST_CASE_BRANCH_PREVIEW:
"intervideosrc name=source channel=branch_%d ! "
"gdppay ! "
"tcpserversink name=sink port=%d ",

case GST_CASE_BRANCH_AUDIO:
"intervideosrc name=source channel=branch_%d ! "
"voaacenc ! "
"gdppay ! "
"tcpserversink name=sink port=%d ",


break;
default:
ERROR ("unknown case %d", cas->type);
break;
}


case GST_CASE_COMPOSITE_VIDEO_A:
case GST_CASE_COMPOSITE_VIDEO_B:
case GST_CASE_COMPOSITE_AUDIO:
case GST_CASE_PREVIEW:
srctype = "input";
break;

case GST_CASE_BRANCH_VIDEO_A:
case GST_CASE_BRANCH_VIDEO_B:
case GST_CASE_BRANCH_PREVIEW:

case GST_CASE_BRANCH_AUDIO:
srctype = "branch";
break;


GString *desc;
gchar *channel = NULL;
gchar *caps = NULL;
Expand Down
25 changes: 25 additions & 0 deletions tools/gstcase.h
Expand Up @@ -45,17 +45,42 @@ typedef struct _GstCaseClass GstCaseClass;
*/
typedef enum
{
/**
Input
* TCP server (source) -> gdpdepay -> input -> intersink
* intersrc ->
intersrc -> scale -> mix
/-> preview
composite -+
\-> video output
video output (mjpg) -\ /- TCP server (sink)
>- mux -+
audio output (aac) -/ \- File output
preview video -> gdppay -> TCP server (sink)
preview audio -> gdppay -> TCP server (sink)
*/


GST_CASE_UNKNOWN, /*!< unknown case */

//
GST_CASE_COMPOSITE_VIDEO_A, /*!< special case for composite channel A */
GST_CASE_COMPOSITE_VIDEO_B, /*!< special case for composite channel B */
GST_CASE_COMPOSITE_AUDIO, /*!< special case for composite channel audio */
GST_CASE_PREVIEW, /*!< special case for previews */

GST_CASE_INPUT_AUDIO, /*!< Audio input from TCP socket */
GST_CASE_INPUT_VIDEO, /*!< Video input from TCP socket */

GST_CASE_BRANCH_VIDEO_A, /*!< special case for branching channel A to output */
GST_CASE_BRANCH_VIDEO_B, /*!< special case for branching channel B to output */
GST_CASE_BRANCH_AUDIO, /*!< special case for branching active audio to output */
GST_CASE_BRANCH_PREVIEW, /*!< special case for branching preview to output */

GST_CASE__LAST_TYPE = GST_CASE_BRANCH_PREVIEW
} GstCaseType;

Expand Down

0 comments on commit 01c92b6

Please sign in to comment.