2000-08-18 20:38:54 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
static gboolean
|
|
|
|
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
|
examples/: Update a couple of the examples to work again.
Original commit message from CVS:
* examples/Makefile.am:
* examples/helloworld/helloworld.c: (event_loop), (main):
* examples/queue/queue.c: (event_loop), (main):
* examples/queue2/queue2.c: (main):
Update a couple of the examples to work again.
* gst/base/gstbasesink.c: (gst_base_sink_preroll_queue_empty),
(gst_base_sink_preroll_queue_flush), (gst_base_sink_handle_event):
Spelling corrections and extra debug.
* gst/gstbin.c: (gst_bin_class_init), (gst_bin_init), (is_eos),
(gst_bin_add_func), (bin_element_is_sink), (gst_bin_get_state),
(gst_bin_change_state), (gst_bin_dispose), (bin_bus_handler):
* gst/gstbin.h:
* gst/gstpipeline.c: (gst_pipeline_init), (gst_pipeline_dispose),
(gst_pipeline_change_state):
* gst/gstpipeline.h:
Move the bus handler for children to the GstBin, and create a
separate bus for receiving messages from children to the one the
bus sends 'upwards' on.
2005-07-06 16:22:47 +00:00
|
|
|
{
|
2011-03-07 14:21:47 +00:00
|
|
|
GMainLoop *loop = (GMainLoop *) data;
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:{
|
|
|
|
g_print ("End-of-stream\n");
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
examples/: Update a couple of the examples to work again.
Original commit message from CVS:
* examples/Makefile.am:
* examples/helloworld/helloworld.c: (event_loop), (main):
* examples/queue/queue.c: (event_loop), (main):
* examples/queue2/queue2.c: (main):
Update a couple of the examples to work again.
* gst/base/gstbasesink.c: (gst_base_sink_preroll_queue_empty),
(gst_base_sink_preroll_queue_flush), (gst_base_sink_handle_event):
Spelling corrections and extra debug.
* gst/gstbin.c: (gst_bin_class_init), (gst_bin_init), (is_eos),
(gst_bin_add_func), (bin_element_is_sink), (gst_bin_get_state),
(gst_bin_change_state), (gst_bin_dispose), (bin_bus_handler):
* gst/gstbin.h:
* gst/gstpipeline.c: (gst_pipeline_init), (gst_pipeline_dispose),
(gst_pipeline_change_state):
* gst/gstpipeline.h:
Move the bus handler for children to the GstBin, and create a
separate bus for receiving messages from children to the one the
bus sends 'upwards' on.
2005-07-06 16:22:47 +00:00
|
|
|
}
|
2011-03-07 14:21:47 +00:00
|
|
|
case GST_MESSAGE_ERROR:{
|
|
|
|
gchar *debug;
|
|
|
|
GError *err;
|
examples/: Update a couple of the examples to work again.
Original commit message from CVS:
* examples/Makefile.am:
* examples/helloworld/helloworld.c: (event_loop), (main):
* examples/queue/queue.c: (event_loop), (main):
* examples/queue2/queue2.c: (main):
Update a couple of the examples to work again.
* gst/base/gstbasesink.c: (gst_base_sink_preroll_queue_empty),
(gst_base_sink_preroll_queue_flush), (gst_base_sink_handle_event):
Spelling corrections and extra debug.
* gst/gstbin.c: (gst_bin_class_init), (gst_bin_init), (is_eos),
(gst_bin_add_func), (bin_element_is_sink), (gst_bin_get_state),
(gst_bin_change_state), (gst_bin_dispose), (bin_bus_handler):
* gst/gstbin.h:
* gst/gstpipeline.c: (gst_pipeline_init), (gst_pipeline_dispose),
(gst_pipeline_change_state):
* gst/gstpipeline.h:
Move the bus handler for children to the GstBin, and create a
separate bus for receiving messages from children to the one the
bus sends 'upwards' on.
2005-07-06 16:22:47 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
gst_message_parse_error (msg, &err, &debug);
|
2012-05-22 11:27:48 +00:00
|
|
|
g_printerr ("Debugging info: %s\n", (debug) ? debug : "none");
|
2011-03-07 14:21:47 +00:00
|
|
|
g_free (debug);
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
g_print ("Error: %s\n", err->message);
|
|
|
|
g_error_free (err);
|
|
|
|
|
|
|
|
g_main_loop_quit (loop);
|
2001-01-03 19:12:21 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2000-08-18 20:38:54 +00:00
|
|
|
}
|
2011-03-07 14:21:47 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
gint
|
|
|
|
main (gint argc, gchar * argv[])
|
|
|
|
{
|
|
|
|
GstElement *playbin;
|
|
|
|
GMainLoop *loop;
|
|
|
|
GstBus *bus;
|
2012-09-06 14:06:08 +00:00
|
|
|
guint bus_watch_id;
|
2011-03-07 14:21:47 +00:00
|
|
|
gchar *uri;
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
gst_init (&argc, &argv);
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
g_print ("usage: %s <media file or uri>\n", argv[0]);
|
|
|
|
return 1;
|
2002-01-06 19:00:14 +00:00
|
|
|
}
|
2006-05-18 08:48:21 +00:00
|
|
|
|
2012-05-22 11:27:48 +00:00
|
|
|
playbin = gst_element_factory_make ("playbin", NULL);
|
2011-03-07 14:21:47 +00:00
|
|
|
if (!playbin) {
|
2012-05-22 11:27:48 +00:00
|
|
|
g_print ("'playbin' gstreamer plugin missing\n");
|
2011-03-07 14:21:47 +00:00
|
|
|
return 1;
|
2006-05-18 08:48:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
/* take the commandline argument and ensure that it is a uri */
|
|
|
|
if (gst_uri_is_valid (argv[1]))
|
|
|
|
uri = g_strdup (argv[1]);
|
|
|
|
else
|
|
|
|
uri = gst_filename_to_uri (argv[1], NULL);
|
|
|
|
g_object_set (playbin, "uri", uri, NULL);
|
|
|
|
g_free (uri);
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2018-04-27 16:40:31 +00:00
|
|
|
/* create an event loop and feed gstreamer bus messages to it */
|
2011-03-07 14:21:47 +00:00
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
bus = gst_element_get_bus (playbin);
|
2012-09-06 14:06:08 +00:00
|
|
|
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
|
2020-04-20 13:21:10 +00:00
|
|
|
gst_object_unref (bus);
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
/* start play back and listed to events */
|
|
|
|
gst_element_set_state (playbin, GST_STATE_PLAYING);
|
|
|
|
g_main_loop_run (loop);
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
/* cleanup */
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
2020-04-20 13:21:10 +00:00
|
|
|
gst_object_unref (playbin);
|
2012-09-06 14:06:08 +00:00
|
|
|
g_source_remove (bus_watch_id);
|
2011-09-25 15:10:53 +00:00
|
|
|
g_main_loop_unref (loop);
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2011-03-07 14:21:47 +00:00
|
|
|
return 0;
|
2000-08-18 20:38:54 +00:00
|
|
|
}
|