stuck between a tee and a frustrating place.

gstream at ccc2.com gstream at ccc2.com
Tue Feb 28 02:55:55 PST 2012


Hi All,

Can someone give advice on the code below. Compiles with no errors,
however when I run it it stalls after giving the g_print message in
on_pad_added.

if I run with debug it will output all the caps with the last two lines

 videomixer2
videomixer2.c:315:gst_videomixer2_pad_sink_setcaps:<videomixer:sink_0>
Setting caps video/x-raw-yuv, format=(fourcc)AYUV, width=(int)600,
height=(int)300, framerate=(fraction)25/1,
pixel-aspect-ratio=(fraction)1/1, bpp=(int)16, depth=(int)16,
endianness=(int)1234, interlaced=(boolean)false
0:00:07.029304050  6097      0x25d8c00 INFO             videomixer2
videomixer2.c:1403:gst_videomixer2_src_setcaps:<videomixer:src> set src
caps: video/x-raw-yuv, format=(fourcc)AYUV, width=(int)640,
height=(int)352, framerate=(fraction)25/1,
pixel-aspect-ratio=(fraction)1/1

If I comment out the pipe1a it works as expected. can you advise if I am
missing something obvious and how to fix it.

thx
Art

#include <gst/gst.h>
#include <glib-2.0/glib.h>
#include <glib-2.0/glib-object.h>
#ifndef NULL
#define NULL   ((void *) 0)
#endif

//2cam works 'TFFT'

static void
on_pad_added (GstElement *element,
              GstPad     *pad,
              gpointer    data)
{
  GstPad *sinkpad;
  GstElement *decoder = (GstElement *) data;

 g_print ("Dynamic pad created, linking out/in \n");

 sinkpad = gst_element_get_static_pad (decoder, "sink");

  gst_pad_link (pad, sinkpad);

  gst_object_unref (sinkpad);
}

int
main (int   argc,
      char *argv[])
{
  GMainLoop *loop;
  g_printerr ("its alive 333.\n");

  GstElement *pipeline;
  GstElement *source, *decoder, *ffcs, *tee;
  GstElement *que,*vidsc, *capsfout, *videobox;
  GstElement  *que1a, *vidsc1a, *capsfout1a, *videobox1a;
  GstElement *videomixer;
  GstElement *ffcs99, *vidsc99, *capsfout99, *sink;
  GstBus *bus;
  GstCaps *filtercaps, *filtercaps1a,  *filtercaps99;
  GstPad *src_0, *sink_0;
  GstPad *src_1, *sink_1;
  GstPad *src_2, *sink_2;
  GstPad *src_3, *sink_3;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("video-player");
  source   = gst_element_factory_make ("filesrc",       	"source");
  decoder  = gst_element_factory_make ("decodebin2",    	"decoder");
  ffcs     = gst_element_factory_make ("ffmpegcolorspace", 	"ffcs");
  tee 	   = gst_element_factory_make ("tee", 		        "tee");

  que      = gst_element_factory_make ("queue2", 		    "que");
  vidsc    = gst_element_factory_make ("videoscale", 		"vidsc");
  capsfout = gst_element_factory_make ("capsfilter", 		"capsfout");
  videobox =gst_element_factory_make("videobox",            "videobox");
  g_object_set(videobox,"top",0,"bottom",0,"left",-300,"right",0,NULL);

  que1a     = gst_element_factory_make ("queue2", 	     	"que2");
  vidsc1a   = gst_element_factory_make ("videoscale", 		"vidsc1a");
  capsfout1a = gst_element_factory_make ("capsfilter",      "capsfout1a");
  videobox1a=gst_element_factory_make("videobox",           "videobox1a");
  g_object_set(videobox1a,"top",0,"bottom",0,"left",0,"right",0,NULL);

  ffcs99    = gst_element_factory_make ("ffmpegcolorspace", "ffcs99");
  vidsc99    = gst_element_factory_make ("videoscale", 		"vidsc99");
  capsfout99 = gst_element_factory_make ("capsfilter", 		"capsfout99");
  sink     = gst_element_factory_make ("filesink", 			"sink");

  videomixer=gst_element_factory_make("videomixer2","videomixer");

  /* we set the input/output filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);
  g_object_set (G_OBJECT (sink), "location", argv[3], NULL);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bin_add_many (GST_BIN (pipeline),
                    source, decoder, ffcs, tee,
                    que, vidsc, capsfout, videobox,
                    que1a, vidsc1a, capsfout1a, videobox1a,
                    videomixer, ffcs99, vidsc99, capsfout99, sink, NULL);
//pipe1
  gst_element_link( source, decoder);
    gst_element_link_pads (decoder, "src", ffcs, "sink");
    gst_element_link_pads (ffcs, "src", tee, "sink");
    	src_0 = gst_element_get_request_pad (tee, "src%d");
        sink_0 = gst_element_get_static_pad (que, "sink");
            gst_pad_link (src_0,sink_0);
    gst_element_link_many (que, vidsc, capsfout, videobox, NULL);
    	src_1 = gst_element_get_static_pad (videobox, "src");
    	sink_1 = gst_element_get_request_pad (videomixer, "sink_%d");
    	    gst_pad_link (src_1,sink_1);

//pipe1a
   		src_2 = gst_element_get_request_pad (tee, "src%d");
    	sink_2 = gst_element_get_static_pad (que, "sink");
    	    gst_pad_link (src_2,sink_2);
    gst_element_link_many (que1a, vidsc1a, capsfout1a, videobox1a, NULL);
    		src_3= gst_element_get_static_pad (videobox1a, "src");
    		sink_3= gst_element_get_request_pad (videomixer, "sink_%d");
    			gst_pad_link (src_3,sink_3);


//pipeout
    gst_element_link_many ( videomixer, ffcs99, vidsc99, capsfout99, sink,
NULL);

    g_signal_connect (decoder, "pad-added", G_CALLBACK (on_pad_added), ffcs);

  filtercaps = gst_caps_new_simple("video/x-raw-yuv",
		  	  	  	  "width", G_TYPE_INT, 300,
		    	      "height", G_TYPE_INT, 300,
		    	      "framerate", GST_TYPE_FRACTION, 25, 1,
		    	      "bpp", G_TYPE_INT, 16,
					  "depth", G_TYPE_INT, 16,
					  "endianness", G_TYPE_INT, G_BYTE_ORDER,
		    	      NULL);
  filtercaps1a = gst_caps_new_simple("video/x-raw-yuv",
  		  	  	  	  "width", G_TYPE_INT, 300,
  		    	      "height", G_TYPE_INT, 300,
  		    	      "framerate", GST_TYPE_FRACTION, 25, 1,
  		    	      "bpp", G_TYPE_INT, 16,
  					  "depth", G_TYPE_INT, 16,
  					  "endianness", G_TYPE_INT, G_BYTE_ORDER,
  		    	      NULL);
  filtercaps99 = gst_caps_new_simple("video/x-raw-yuv",
		  	  	  	  "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
 	      	  	  	   "width", G_TYPE_INT, 640,
 		    	      "height", G_TYPE_INT, 352,
 		    	      "framerate", GST_TYPE_FRACTION, 25, 1,
 		    	       NULL);

  g_object_set (G_OBJECT (capsfout), "caps", filtercaps, NULL);
       gst_caps_unref (filtercaps);
  g_object_set (G_OBJECT (capsfout1a), "caps", filtercaps1a, NULL);
       gst_caps_unref (filtercaps1a);
  g_object_set (G_OBJECT (capsfout99), "caps", filtercaps99, NULL);
	   gst_caps_unref (filtercaps99);



  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);


  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;
}







More information about the gstreamer-devel mailing list