12 event_loop (GstElement * pipeline)
15 GstMessageType revent;
16 GstMessage *message = NULL;
18 bus = gst_element_get_bus (GST_ELEMENT (pipeline));
21 revent = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
23 message = gst_bus_pop (bus);
24 g_return_val_if_fail (message != NULL, TRUE);
28 gst_message_unref (message);
30 case GST_MESSAGE_WARNING:
31 case GST_MESSAGE_ERROR:{
35 gst_message_parse_error (message, &gerror, &debug);
36 gst_message_unref (message);
37 gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
38 g_error_free (gerror);
43 gst_message_unref (message);
48 g_assert_not_reached ();
53 main (int argc, char *argv[])
55 GstElement *pipeline = NULL;
59 gchar *md5string = g_malloc0 (33);
61 free (malloc (8)); /* -lefence */
63 setlocale (LC_ALL, "");
65 gst_init (&argc, &argv);
67 argvn = g_new0 (char *, argc);
68 memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
69 pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
72 g_warning ("pipeline could not be constructed: %s\n", error->message);
75 g_warning ("pipeline could not be constructed\n");
79 md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
80 if (md5sink == NULL) {
81 g_print ("ERROR: pipeline has no element named md5sink0.\n");
82 g_print ("Did you forget to put an md5sink in the pipeline?\n");
88 g_warning ("pipeline could not be constructed: %s\n", error->message);
91 g_warning ("pipeline could not be constructed\n");
95 if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
96 g_warning ("pipeline doesn't want to play\n");
100 event_loop (pipeline);
102 gst_element_set_state (pipeline, GST_STATE_NULL);
104 /* print out md5sink here */
105 md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
107 g_object_get (G_OBJECT (md5sink), "md5", &md5string, NULL);
108 printf ("%s\n", md5string);
110 gst_object_unref (pipeline);