rookie question for writing a simple video player

신승배 sbshin80 at gmail.com
Wed Dec 14 00:46:44 PST 2011


Hi,
It seems that you are trying to link decodebin with queue element directly.
Try to link them by handling "new-decoded-pad" signal from decodebin.
Please refer below link which is official gstreamer document.
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-components-decodebin.html
Thank you.



On Tue, Dec 13, 2011 at 10:40 PM, jaeyong yoo <y.jaeyong at gmail.com> wrote:

> Hello,
>
> I just read gstreamer application development manual (0.10.35.1) and want
> to write a very simple video player.
>
> I can play a video (mpeg2-encoded) using playbin in test/examples/manual
> folder thus I tried to strip out the parts that handle the required
> elements to play the particular video and wrote the code as follows.
>
>
> #include <gst/gst.h>
>
>
> static void handoff (GstElement * identity, GstBuffer * frame, gpointer
> data)
> {
>     printf("handoff called\n");
> }
>
> static gboolean my_bus_callback (GstBus * bus, GstMessage * msg, gpointer
> data)
> {
>     GMainLoop *loop = (GMainLoop *) data;
>
>     switch (GST_MESSAGE_TYPE (msg)) {
>         case GST_MESSAGE_EOS:
>         {
>             g_print ("End-of-stream\n");
>             g_main_loop_quit (loop);
>             printf("JYD: bus_call: GST_MESSAGE_EOS\n");
>             break;
>         }
>         case GST_MESSAGE_ERROR:
>         {
>             gchar *debug;
>             GError *err;
>             printf("JYD: bus_call: GST_MESSAGE_ERROR\n");
>             gst_message_parse_error (msg, &err, &debug);
>             g_free (debug);
>             g_print ("Error:: %s\n", err->message);
>             g_error_free (err);
>             g_main_loop_quit (loop);
>             break;
>         }
>         case GST_MESSAGE_WARNING:
>         {
>             char buf[1024];
>             sprintf( buf, "%s",  GST_MESSAGE_SRC_NAME(msg) );
>             printf("JYD: bus_call: %s %s\n", GST_MESSAGE_TYPE_NAME(msg),
> buf);
>
>             break;
>         }
>
>         case GST_MESSAGE_STATE_CHANGED:
>         {
>             printf("JYD: bus_call: (%s: %d)\n",
> GST_MESSAGE_TYPE_NAME(msg), GST_MESSAGE_TYPE(msg));
>             /* TODO: how to see the changed element state? */
>             break;
>         }
>         default:
>             printf("JYD: bus_call: default (%s: %d)\n",
> GST_MESSAGE_TYPE_NAME(msg), GST_MESSAGE_TYPE(msg));
>             break;
>     }
>     return TRUE;
> }
>
> gint main (gint argc, gchar * argv[])
> {
>     GstElement *scale;
>     GstElement *identity;
>     GstElement *pipeline, *queue;
>     GstElement *src, *dec, *conv, *sink;
>     GMainLoop *loop;
>     GstBus *bus;
>
>     gst_init (&argc, &argv);
>
>     if (argc < 2) {
>         g_print ("usage: %s <media file or uri>\n", argv[0]);
>         return 1;
>     }
>
>     /* create and event loop and feed gstreamer bus mesages to it */
>     loop = g_main_loop_new (NULL, FALSE);
>
>     /* create pipeline */
>     pipeline = gst_pipeline_new ("pipeline");
>     bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>     gst_bus_add_watch(bus, my_bus_callback, loop);
>     gst_object_unref (bus);
>
>     /* create an element for file-reading */
>     src = gst_element_factory_make ("filesrc", "source");
>     g_object_set (G_OBJECT (src), "location", argv[1], NULL);
>     dec = gst_element_factory_make ("decodebin", "decode");
>     queue = gst_element_factory_make ("queue", "preroll_video_src0" );
>     sink = gst_element_factory_make ("autovideosink", "videosink");
>     conv = gst_element_factory_make ("ffmpegcolorspace", "vconv");
>     scale = gst_element_factory_make ("videoscale", "vscale");
>     identity = gst_element_factory_make ("identity", "identity-for-what");
>     g_object_set (identity, "silent", TRUE, NULL);
>     g_signal_connect (identity, "handoff", G_CALLBACK (handoff), NULL);
>
>     /* add elements to a bin */
>     gst_bin_add_many( GST_BIN (pipeline), src, dec, queue, conv, scale,
> identity, sink, NULL );
>
>     /* link the elements in the bin */
>     gst_element_link( src, dec );
>     gst_element_link( dec, queue );
>     gst_element_link( queue, identity );
>     gst_element_link( identity, conv );
>     gst_element_link( conv, scale );
>     gst_element_link( scale, sink );
>
>
>     /* start the bin */
>     gst_element_set_state (pipeline, GST_STATE_PLAYING);
>
>     /* start play back and listed to events */
>     printf("go to main loop\n"); /* XXX you may start debugging here */
>     g_main_loop_run (loop);
>     printf("return from main loop\n");
>
>     /* cleanup */
>     g_object_unref (pipeline);
>     g_object_unref (loop);
>
>     return 0;
> }
>
>
> and the results give me the following
>
> Error:: Internal data flow error.
> return from main loop
>
> (lt-myvideoplayer:26621): GStreamer-CRITICAL **:
> Trying to dispose element videosink, but it is in PAUSED instead of the
> NULL state.
> You need to explicitly set elements to the NULL state before
> dropping the final reference, to allow them to clean up.
> This problem may also be caused by a refcounting bug in the
> application or some element.
>
>
> (lt-myvideoplayer:26621): GStreamer-CRITICAL **:
> Trying to dispose element identity-for-what, but it is in PAUSED instead
> of the NULL state.
> You need to explicitly set elements to the NULL state before
> dropping the final reference, to allow them to clean up.
> This problem may also be caused by a refcounting bug in the
> application or some element.
>
>
> (lt-myvideoplayer:26621): GStreamer-CRITICAL **:
> Trying to dispose element vscale, but it is in PAUSED instead of the NULL
> state.
> You need to explicitly set elements to the NULL state before
> dropping the final reference, to allow them to clean up.
> This problem may also be caused by a refcounting bug in the
> application or some element.
>
>
> (lt-myvideoplayer:26621): GStreamer-CRITICAL **:
> Trying to dispose element vconv, but it is in PAUSED instead of the NULL
> state.
> You need to explicitly set elements to the NULL state before
> dropping the final reference, to allow them to clean up.
> This problem may also be caused by a refcounting bug in the
> application or some element.
>
>
> (lt-myvideoplayer:26621): GStreamer-CRITICAL **:
> Trying to dispose element preroll_video_src0, but it is in PAUSED instead
> of the NULL state.
> You need to explicitly set elements to the NULL state before
> dropping the final reference, to allow them to clean up.
> This problem may also be caused by a refcounting bug in the
> application or some element.
>
>
> GThread-ERROR **: file
> /build/buildd/glib2.0-2.30.0/./gthread/gthread-posix.c: line 171
> (g_mutex_free_posix_impl): error 'Device or resource busy' during
> 'pthread_mutex_destroy ((pthread_mutex_t *) mutex)'
> Trace/breakpoint trap
>
>
> I'm stcuked in this phase.
> Please help me.
> Any comments, reading recommendations, would be very appreciated.
>
> jaeyong
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20111214/a0a0abdd/attachment-0001.htm>


More information about the gstreamer-devel mailing list