2003-06-29 14:05:49 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-09-22 18:17:58 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <gst/gst.h>
|
2003-08-19 08:11:58 +00:00
|
|
|
#include <locale.h>
|
2002-09-22 18:17:58 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/* blocking */
|
|
|
|
static gboolean
|
|
|
|
event_loop (GstElement * pipeline)
|
2002-09-22 18:17:58 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *message = NULL;
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (GST_ELEMENT (pipeline));
|
|
|
|
|
|
|
|
while (TRUE) {
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
message = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (message != NULL, TRUE);
|
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
2005-03-21 17:34:02 +00:00
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
gst_message_unref (message);
|
|
|
|
return FALSE;
|
|
|
|
case GST_MESSAGE_WARNING:
|
|
|
|
case GST_MESSAGE_ERROR:{
|
|
|
|
GError *gerror;
|
|
|
|
gchar *debug;
|
|
|
|
|
|
|
|
gst_message_parse_error (message, &gerror, &debug);
|
|
|
|
gst_message_unref (message);
|
Revert unpopular change for GST_MESSAGE_SRC to GObject.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* gst/gstbin.c: (bin_bus_handler):
* gst/gstmessage.c: (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_eos), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom):
* gst/gstmessage.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
Revert unpopular change for GST_MESSAGE_SRC to GObject.
2005-08-25 10:51:14 +00:00
|
|
|
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
|
2005-03-21 17:34:02 +00:00
|
|
|
g_error_free (gerror);
|
|
|
|
g_free (debug);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
gst_message_unref (message);
|
|
|
|
break;
|
|
|
|
}
|
2002-09-22 18:17:58 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
return TRUE;
|
2002-09-22 18:17:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2003-09-11 22:44:58 +00:00
|
|
|
GstElement *pipeline = NULL;
|
2002-09-22 18:17:58 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
GstElement *md5sink;
|
2005-03-21 17:34:02 +00:00
|
|
|
gchar **argvn;
|
2002-09-22 18:17:58 +00:00
|
|
|
gchar *md5string = g_malloc0 (33);
|
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
free (malloc (8)); /* -lefence */
|
2002-09-22 18:17:58 +00:00
|
|
|
|
2003-08-19 08:11:58 +00:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_init (&argc, &argv);
|
2003-09-11 22:44:58 +00:00
|
|
|
|
|
|
|
argvn = g_new0 (char *, argc);
|
2002-09-22 18:17:58 +00:00
|
|
|
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
|
2004-03-13 15:27:01 +00:00
|
|
|
pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
|
2003-09-11 22:44:58 +00:00
|
|
|
if (!pipeline) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (error) {
|
2003-09-11 22:44:58 +00:00
|
|
|
g_warning ("pipeline could not be constructed: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else
|
2003-09-11 22:44:58 +00:00
|
|
|
g_warning ("pipeline could not be constructed\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
|
2004-03-13 15:27:01 +00:00
|
|
|
if (md5sink == NULL) {
|
2005-03-21 17:34:02 +00:00
|
|
|
g_print ("ERROR: pipeline has no element named md5sink0.\n");
|
|
|
|
g_print ("Did you forget to put an md5sink in the pipeline?\n");
|
|
|
|
return 1;
|
2003-09-11 22:44:58 +00:00
|
|
|
}
|
2002-09-22 18:17:58 +00:00
|
|
|
|
|
|
|
if (!pipeline) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (error) {
|
2002-09-22 18:17:58 +00:00
|
|
|
g_warning ("pipeline could not be constructed: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else
|
2002-09-22 18:17:58 +00:00
|
|
|
g_warning ("pipeline could not be constructed\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-09-02 15:42:00 +00:00
|
|
|
if (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS) {
|
2002-09-22 18:17:58 +00:00
|
|
|
g_warning ("pipeline doesn't want to play\n");
|
2005-03-21 17:34:02 +00:00
|
|
|
return 1;
|
2002-09-22 18:17:58 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
event_loop (pipeline);
|
2002-09-22 18:17:58 +00:00
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
|
|
|
|
/* print out md5sink here */
|
|
|
|
md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
|
|
|
|
g_assert (md5sink);
|
|
|
|
g_object_get (G_OBJECT (md5sink), "md5", &md5string, NULL);
|
|
|
|
printf ("%s\n", md5string);
|
|
|
|
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (pipeline);
|
2002-09-22 18:17:58 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|