gst-launch pipeline vs its exact C analog

Sergei Vorobyov sergei.vorobyov at facilitylabs.com
Wed Mar 28 05:28:33 PDT 2012


Right, instead of

gst_element_link (dec, conv)

which does not work because dec ("decodebin2") has dynamic source
pads, I should have linked with

g_signal_connect (dec, "pad-added", G_CALLBACK (on_pad_added), conv);

where

void on_pad_added (GstElement *src_element,
		   GstPad *pad, // dynamic source pad
		   gpointer target_element)
{
  GstElement *target = (GstElement*) target_element;
  g_print ("*** Linking a dynamic source pad of %s to the static sink
pad of %s...\n",
	   GST_OBJECT_NAME (src_element), GST_OBJECT_NAME (target));
  GstPad *sinkpad = gst_element_get_static_pad (target, "sink");
  gst_pad_link (pad, sinkpad);
  gst_object_unref (sinkpad);
}

and this works as expected.

Many thanks!

On Wed, Mar 28, 2012 at 12:50 PM, Stefan Sauer <ensonic at hora-obscura.de> wrote:
> On 03/28/2012 11:13 AM, Sergei Vorobyov wrote:
>> Hi!
>>
>> Your help will be greatly appreciated.
>>
>> I am struggling to understand and wondering why
>>
>> gst-launch filesrc location=file.avi ! decodebin2 ! ffmpegcolorspace !
>> autovideosink
>>
>> works just fine as expected, whereas its straightforward C-programmed analog
>>
>>   src = gst_element_factory_make ("filesrc", "source");
>>   g_object_set (src, "location", "file.avi", NULL);
>>
>>   dec = gst_element_factory_make ("decodebin2", "decoder"); // won't
>> link to the next
>>   conv = gst_element_factory_make ("ffmpegcolorspace", "ffmpeg-colorspace");
>>   sink = gst_element_factory_make ("autovideosink", "sink");
>>
>>   gst_bin_add_many (GST_BIN (pipeline),
>>                   src,
>>                   dec,
>>                   conv,
>>                   sink, NULL);
>>
>>   if (!gst_element_link (src, dec)) {
>>     g_print("cannot link src and dec\n");
>>     return -1;
>>   }
>>
>>   if (!gst_element_link (dec, conv)) { // FAILS here
>>     g_print("cannot link dec and conv\n");
>>     return -1;
>>   }
>>
>> reports "cannot link dec and conv", i.e., gst_element_link (dec, conv) FAILS.
> FAQ. Please read up on sometimes pads and look at the docs for the
> GstElement pad-added signal.
>
> Stefan
>
>> If I take away return -1, allowing it to proceed, it results in:
>>
>> Error from element avidemux0: Internal data stream error.
>> Debug: gstavidemux.c(5204): gst_avi_demux_loop ():
>> /GstPipeline:length/GstDecodeBin2:decoder/GstAviDemux:avidemux0:
>> streaming stopped, reason not-linked
>>
>> caught in the callback for the loop/pipeline
>>
>>
>>     if (msg_type & GST_MESSAGE_ERROR) {
>>       g_print ("ERROR message\n");
>>       gchar *debug;
>>       GError *err;
>>
>>       gst_message_parse_error (msg, &err, &debug);
>>       g_free (debug);
>>
>>       g_print ("Error from element %s: %s\n",
>>              GST_OBJECT_NAME (msg->src),
>>              err->message);
>>       g_print ("Debug: %s\n", (debug) ? debug : "none");
>>       g_error_free (err);
>>       g_free (debug);
>>
>>       g_main_loop_quit (loop);
>>     }
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


More information about the gstreamer-devel mailing list