Question about and appsink pipeline

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about and appsink pipeline

W. Michael Petullo
I have been having trouble building an appsink pipeline in C. I was able
to get it to work, but now have a question.

I have two ways to initialize my pipeline. One works and the other does
not. Could someone tell me why?

This does not work:

        stream->priv->src     = gst_element_factory_make ("giosrc", "src");
        stream->priv->decode  = gst_element_factory_make ("decodebin",
"decode");
        stream->priv->convert = gst_element_factory_make ("audioconvert",
"convert");
        stream->priv->encode  = gst_element_factory_make ("lame", "encode");
        stream->priv->sink    = gst_element_factory_make ("appsink", "sink");

        gst_bin_add_many (GST_BIN (stream->priv->pipeline),
                          stream->priv->src,
                          stream->priv->decode,
                          stream->priv->convert,
                          stream->priv->encode,
                          stream->priv->sink,
                          NULL);

        gst_element_link_many (stream->priv->src,
                               stream->priv->decode,
                               stream->priv->convert,
                               stream->priv->encode,
                               stream->priv->sink,
                               NULL);

        g_object_set (G_OBJECT (stream->priv->src), "location", uri, NULL);

This does work:

        string = g_strdup_printf ("giosrc location=\"%s\" ! decodebin !
audioconvert ! lame ! appsink name=\"sink\"", uri);
        stream->priv->pipeline = gst_parse_launch (string, NULL);
        g_free (string);

I do not understand why they would be different.

Mike


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Question about and appsink pipeline

Tim-Philipp Müller-2
On Sun, 2009-02-01 at 03:56 -0500, W. Michael Petullo wrote:

Hi,

> I have two ways to initialize my pipeline. One works and the other does
> not. Could someone tell me why?
>
> This does not work:
>
>   (...)
>
>         gst_element_link_many (stream->priv->src,
>                                stream->priv->decode,
>                                stream->priv->convert,
>                                stream->priv->encode,
>                                stream->priv->sink,
>                                NULL);

This will fail, because decodebin does not have any source pads yet at
this point, so you can't link decodebin to audioconvert yet. Decodebin
has 'dynamic pads' which are created only once data flows through the
pipline, so you need to defer linking decodebin to audioconvert to the
new-decoded-pad callback. Have a look at the application developer's
manual and/or
http://www.jonobacon.org/2006/11/03/gstreamer-dynamic-pads-explained/
for more info.


> This does work:
>
>         string = g_strdup_printf ("giosrc location=\"%s\" ! decodebin !
> audioconvert ! lame ! appsink name=\"sink\"", uri);
>         stream->priv->pipeline = gst_parse_launch (string, NULL);
>         g_free (string);
>
> I do not understand why they would be different.

gst_parse_launch() handles dynamic pads automagically for you, which can
be great, but can also backfire at times, e.g. if you make it wait for
pads that'll never be created.

Cheers
 -Tim



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Question about and appsink pipeline

W. Michael Petullo
>> I have two ways to initialize my pipeline. One works and the other  
>> does
>> not. Could someone tell me why?
>>
>> This does not work:
>>
>>   (...)
>>
>>         gst_element_link_many (stream->priv->src,
>>                                stream->priv->decode,
>>                                stream->priv->convert,
>>                                stream->priv->encode,
>>                                stream->priv->sink,
>>                                NULL);
>
> This will fail, because decodebin does not have any source pads yet at
> this point, so you can't link decodebin to audioconvert yet. Decodebin
> has 'dynamic pads' which are created only once data flows through the
> pipline, so you need to defer linking decodebin to audioconvert to the
> new-decoded-pad callback. Have a look at the application developer's
> manual and/or
> http://www.jonobacon.org/2006/11/03/gstreamer-dynamic-pads-explained/
> for more info.

That makes perfect sense, thank you. I linked the dynamic pad using  
the "new-decoded-pad" callback and the application works now.

Mike

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel