macos: Add wrapper API to run a NSApplication in the main thread
[platform/upstream/gstreamer.git] / subprojects / gst-docs / examples / tutorials / basic-tutorial-1.c
1 #include <gst/gst.h>
2
3 #ifdef __APPLE__
4 #include <TargetConditionals.h>
5 #endif
6
7 int
8 tutorial_main (int argc, char *argv[])
9 {
10   GstElement *pipeline;
11   GstBus *bus;
12   GstMessage *msg;
13
14   /* Initialize GStreamer */
15   gst_init (&argc, &argv);
16
17   /* Build the pipeline */
18   pipeline =
19       gst_parse_launch
20       ("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm",
21       NULL);
22
23   /* Start playing */
24   gst_element_set_state (pipeline, GST_STATE_PLAYING);
25
26   /* Wait until error or EOS */
27   bus = gst_element_get_bus (pipeline);
28   msg =
29       gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
30       GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
31
32   /* See next tutorial for proper error message handling/parsing */
33   if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
34     g_error ("An error occurred! Re-run with the GST_DEBUG=*:WARN environment "
35         "variable set for more details.");
36   }
37
38   /* Free resources */
39   gst_message_unref (msg);
40   gst_object_unref (bus);
41   gst_element_set_state (pipeline, GST_STATE_NULL);
42   gst_object_unref (pipeline);
43   return 0;
44 }
45
46 int
47 main (int argc, char *argv[])
48 {
49 #if defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE
50   return gst_macos_main (tutorial_main, argc, argv, NULL);
51 #else
52   return tutorial_main (argc, argv);
53 #endif
54 }