GNOME Bugzilla – Bug 424143
Hello world too complicated
Last modified: 2011-03-08 07:45:47 UTC
The manual of gstreamer provides a hello-world example. It was a good example in the days before the great playbin element, but for today's gstreamer it is too complicated - in my opinion. What about replacing it with an example really just demonstrating the usage of playbin in a C program?
Created attachment 85515 [details] hello-gst.c That's how my "Hello World" example would look like. Maybe even the "bus_call" should be stripped out, or be replaced by something just calling g_loop_quit. Error handling could go into a separate example demonstrating error handling. Same for the current "Hello World" example: It could serve as example for building a custom pipeline.
Its this one; http://cgit.freedesktop.org/gstreamer/gstreamer/tree/tests/examples/helloworld/helloworld.c and I think its a good idea. Your example needs small cleanups. Anyone else +1 for this?
Created attachment 182703 [details] [review] updated hello world example
Hmm, the one I patched is not referenced from the application developers manaual. Matthias did you menat to update: http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/manual/basics-helloworld.xml#n59 ? That we probably better keep as it is (there is also a picture that would need an update).
Looks good to me. Niggles: - argv[1] needs to be a URI, but the help string says 'media file'. Maybe add some kind of if (gst_uri_is_valid (argv[1])) uri = g_strdup (argv[1]); else uri = gst_filename_to_uri (argv[1], NULL); (this is also something that trips up people quite a lot, so might be worth having in a hello world). - wonder if for a first version it would be even better to get rid of the main loop, and just do a while ((msg = gst_bus_*()) { ... } instead. (Many people don't understand main loops, or are confused by them).
(In reply to comment #5) > Looks good to me. Niggles: > > - argv[1] needs to be a URI, but the help string > says 'media file'. Maybe add some kind of > > if (gst_uri_is_valid (argv[1])) > uri = g_strdup (argv[1]); > else > uri = gst_filename_to_uri (argv[1], NULL); > > (this is also something that trips up > people quite a lot, so might be worth > having in a hello world). good idea. Fixed. > > - wonder if for a first version it would be even > better to get rid of the main loop, and > just do a > > while ((msg = gst_bus_*()) { > ... > } > > instead. (Many people don't understand > main loops, or are confused by them). I added a couple of comment lines instead. I think the main-loop is as short as the usual event_loop helper we use, but I think its better to have a 'proper example'.
Comment on attachment 182703 [details] [review] updated hello world example Committed with small changes: commit bdee46249443531118f119cd3f7d7d5bf794ee6b Author: Stefan Kost <ensonic@users.sf.net> Date: Mon Mar 7 12:24:30 2011 +0200 pluginfeature: avoid duplication feature->name The feature name is not supposed to change over time anyway. In order to enforce this parentize features to the registry and make the feature->name pointing to GstObject:name. In 0.11 we could consider of removing the feature->name variable (FIXME comment added). Fixes: #459466