2016-11-05 08:18:49 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2022-12-13 17:42:11 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <TargetConditionals.h>
|
|
|
|
#endif
|
|
|
|
|
2019-02-07 19:32:58 +00:00
|
|
|
int
|
2022-12-13 17:42:11 +00:00
|
|
|
tutorial_main (int argc, char *argv[])
|
2019-02-07 19:32:58 +00:00
|
|
|
{
|
2016-11-05 08:18:49 +00:00
|
|
|
GstElement *pipeline;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *msg;
|
|
|
|
|
|
|
|
/* Initialize GStreamer */
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
/* Build the pipeline */
|
2019-02-07 19:32:58 +00:00
|
|
|
pipeline =
|
|
|
|
gst_parse_launch
|
2023-04-06 17:28:33 +00:00
|
|
|
("playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm",
|
2019-02-07 19:32:58 +00:00
|
|
|
NULL);
|
2016-11-05 08:18:49 +00:00
|
|
|
|
|
|
|
/* Start playing */
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
/* Wait until error or EOS */
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
2019-02-07 19:32:58 +00:00
|
|
|
msg =
|
|
|
|
gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
|
|
|
|
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2021-10-18 17:20:10 +00:00
|
|
|
/* See next tutorial for proper error message handling/parsing */
|
|
|
|
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
|
|
|
|
g_error ("An error occurred! Re-run with the GST_DEBUG=*:WARN environment "
|
|
|
|
"variable set for more details.");
|
|
|
|
}
|
|
|
|
|
2016-11-05 08:18:49 +00:00
|
|
|
/* Free resources */
|
2021-10-18 17:20:10 +00:00
|
|
|
gst_message_unref (msg);
|
2016-11-05 08:18:49 +00:00
|
|
|
gst_object_unref (bus);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
return 0;
|
|
|
|
}
|
2022-12-13 17:42:11 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
#if defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE
|
2024-02-02 11:54:32 +00:00
|
|
|
return gst_macos_main ((GstMainFunc) tutorial_main, argc, argv, NULL);
|
2022-12-13 17:42:11 +00:00
|
|
|
#else
|
|
|
|
return tutorial_main (argc, argv);
|
|
|
|
#endif
|
|
|
|
}
|