Why does this working gst-launch pipeline not work when compiled?

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

Why does this working gst-launch pipeline not work when compiled?

Wes Miller
Administrator
I have this pipeline working in linux and windows:

gst-Launch -e souphttpsrc location="my_url" ! multipartdemux ! matroskamux ! filesink location="my_file"

When I code this up in C, no signal handlers, no callback, just 4 elements, add-many-ed and link-many -ed.

When I get to setting the pipeline to playing it returns 2 - asynch event.

So, I'm just completely confused.  Why does it work at a command prompt and not in a program?  What's supposed to catch what asynch event?  I know I'll need a callback for errors, but what will it need to be hooked to?  This all seems so simple except it isn't.

Wes
Reply | Threaded
Open this post in threaded view
|

Re: Why does this working gst-launch pipeline not work when compiled?

Tim-Philipp Müller-2
On Mon, 2010-04-12 at 10:56 -0800, Wes Miller wrote:

> I have this pipeline working in linux and windows:
>
> gst-Launch -e souphttpsrc location="my_url" ! multipartdemux ! matroskamux !
> filesink location="my_file"
>
> When I code this up in C, no signal handlers, no callback, just 4 elements,
> add-many-ed and link-many -ed.

That sounds like you already know that that's not going to work ;-)

multipartdemux has sometimes pads, and matroskamux has request pads, so
you can't just link them all from the start (you did check the return
value of _link_many()?)

Alternatively, create the pipeline using gst_parse_launch() - that will
handle these things automagically for you in the same way gst-launch
does.


> When I get to setting the pipeline to playing it returns 2 - async event.

There is no "event" in the GStreamer sense involved here, it's just a
return value. An ASYNC return value is expected when you set a pipeline
to PAUSED or PLAYING state.

See e.g.:
http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-overview.txt


> So, I'm just completely confused.  Why does it work at a command prompt and
> not in a program?

Because gst_parse_launch() does some 'magic' under the hood.


> What's supposed to catch what async event?

Not sure what you mean here. The ASYNC return value tells you that the
pipeline isn't ready to be e.g. seeked yet.

You will be notified when the requested state change completed via a
state-changed message on the pipeline's GstBus, see e.g.:

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-bus.html


> I know I'll need a callback for errors, but what will it need to be
>  hooked to?

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-bus.html


> This all seems so simple except it isn't.

No doubt there's a bit of a learning curve and our docs could be both
better and more complete, but frankly, it doesn't look like you've even
worked through the basics of the Application Developer's Manual.

Cheers
 -Tim



------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Why does this working gst-launch pipeline not work when compiled?

Wes Miller
Administrator
Sadly, I have read the book and I still don't get it.  I'll pose simple questions and figure out the bits that don't click.

I DID!!!! get my pipe to work with gst_parse_launch() thanks to the example at https://vcs.maemo.org/svn/maemoexamples/tags/maemo_4.1/maemo-examples/example_wavlaunch.c

One simple question still needs answered.  The example expects to get a "stop" sent in from a button click in the gui.  I don't have a gui - my stuff needs to run unseen -- so I need to know how to stop it cleanly, i.e. as if I'd coded a -e in the gst-launch command line.  It is possible to tell the loop to catch ctrl-c or will I need a C signal handler?  

Wes  
Reply | Threaded
Open this post in threaded view
|

Re: Why does this working gst-launch pipeline not work when compiled?

Tim-Philipp Müller-2
On Tue, 2010-04-13 at 11:18 -0800, Wes Miller wrote:

> One simple question still needs answered.  The example expects to get a
> "stop" sent in from a button click in the gui.  I don't have a gui - my
> stuff needs to run unseen -- so I need to know how to stop it cleanly, i.e.
> as if I'd coded a -e in the gst-launch command line.  It is possible to tell
> the loop to catch ctrl-c or will I need a C signal handler?  

See:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-libs/html/GstBaseSrc.html#id484395

Basically:

  gst_element_send_event (pipeline, gst_event_new_eos ());

  ... wait for EOS to appear on pipeline's GstBus,
      then set_state to NULL

This is what gst-launch -e does (see gst-launch.c code).

Cheers
 -Tim


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Why does this working gst-launch pipeline not work when compiled?

Wes Miller
Administrator
In reply to this post by Tim-Philipp Müller-2
Tim-Phillip Muller replied:

> That sounds like you already know that that's not going to work ;-)

> multipartdemux has sometimes pads, and matroskamux has request pads, so
> you can't just link them all from the start (you did check the return
> value of _link_many()?)


I finally got my head around what is going on here, mostly.  But my solution is still not quite right.  I get an output file, but it won't "play".

I want to turn this gst-launch pipeline into C code.

     gst-Launch souphttpsrc location="my_url" ! multipartdemux ! matroskamux ! filesink location="my_file"

I have all the elements built and added to the pipeline.  The souphttpsrc is linked to the multipartdemux.
The matroskamux is linked to the filesink.  All return codes are ok.

I have a signal connected to the demuxer tied to a callback function.  The callback is being called.

In the callback I have tried just hooking the pad from the src (demuxer sometimes pad) to a compatible on-requestsink pad in the muxer using the src pad's default caps  I have also tried setting the src pad's caps to image/jpeg then getting the compatible pad.  Both configs will produce am output file. but neither file can be played back using this playback pipe:

     gst-launch filesrec ! matroskademux ! jpegdec ! ffmpegcolorspace ! autovideosink.


How should I configure my caps and/or what pad should I be asking for?


Wes