mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
c2f41a8906
Original commit message from CVS: Next big merge. Added GstBus for mainloop integration. Added GstMessage for sending notifications on the bus. Added GstTask as an abstraction for pipeline entry points. Removed GstThread. Removed Schedulers. Simplified GstQueue for multithreaded core. Made _link threadsafe, removed old capsnego. Added STREAM_LOCK and PREROLL_LOCK in GstPad. Added pad blocking functions. Reworked scheduling functions in GstPad to prepare for scheduling updates soon. Moved events out of data stream. Simplified GstEvent types. Added return values to push/pull. Removed clocking from GstElement. Added prototypes for state change function for next merge. Removed iterate from bins and state change management. Fixed some elements, disabled others for now. Fixed -inspect and -launch. Added check for GstBus.
113 lines
2.7 KiB
C
113 lines
2.7 KiB
C
#ifdef HAVE_CONFIG_H
|
|
# include "config.h"
|
|
#endif
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <gst/gst.h>
|
|
#include <locale.h>
|
|
|
|
/* blocking */
|
|
static gboolean
|
|
event_loop (GstElement * pipeline)
|
|
{
|
|
GstBus *bus;
|
|
GstMessageType revent;
|
|
GstMessage *message = NULL;
|
|
|
|
bus = gst_element_get_bus (GST_ELEMENT (pipeline));
|
|
|
|
while (TRUE) {
|
|
revent = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
message = gst_bus_pop (bus);
|
|
g_return_val_if_fail (message != NULL, TRUE);
|
|
|
|
switch (revent) {
|
|
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);
|
|
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
|
|
g_error_free (gerror);
|
|
g_free (debug);
|
|
return TRUE;
|
|
}
|
|
default:
|
|
gst_message_unref (message);
|
|
break;
|
|
}
|
|
}
|
|
|
|
g_assert_not_reached ();
|
|
return TRUE;
|
|
}
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
GstElement *pipeline = NULL;
|
|
GError *error = NULL;
|
|
GstElement *md5sink;
|
|
gchar **argvn;
|
|
gchar *md5string = g_malloc0 (33);
|
|
|
|
free (malloc (8)); /* -lefence */
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
argvn = g_new0 (char *, argc);
|
|
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
|
|
pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
|
|
if (!pipeline) {
|
|
if (error) {
|
|
g_warning ("pipeline could not be constructed: %s\n", error->message);
|
|
g_error_free (error);
|
|
} else
|
|
g_warning ("pipeline could not be constructed\n");
|
|
return 1;
|
|
}
|
|
|
|
md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
|
|
if (md5sink == NULL) {
|
|
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;
|
|
}
|
|
|
|
if (!pipeline) {
|
|
if (error) {
|
|
g_warning ("pipeline could not be constructed: %s\n", error->message);
|
|
g_error_free (error);
|
|
} else
|
|
g_warning ("pipeline could not be constructed\n");
|
|
return 1;
|
|
}
|
|
|
|
if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
|
|
g_warning ("pipeline doesn't want to play\n");
|
|
return 1;
|
|
}
|
|
|
|
event_loop (pipeline);
|
|
|
|
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);
|
|
|
|
gst_object_unref (GST_OBJECT (pipeline));
|
|
|
|
return 0;
|
|
}
|