Split out documentation into subfolders.
[platform/upstream/gstreamer.git] / examples / tutorials / basic-tutorial-2.c
similarity index 94%
rename from tutorials/basic-tutorial-2.c
rename to examples/tutorials/basic-tutorial-2.c
index 984442b..e900416 100644 (file)
@@ -1,76 +1,76 @@
-#include <gst/gst.h>\r
-  \r
-int main(int argc, char *argv[]) {\r
-  GstElement *pipeline, *source, *sink;\r
-  GstBus *bus;\r
-  GstMessage *msg;\r
-  GstStateChangeReturn ret;\r
-  \r
-  /* Initialize GStreamer */\r
-  gst_init (&argc, &argv);\r
-   \r
-  /* Create the elements */\r
-  source = gst_element_factory_make ("videotestsrc", "source");\r
-  sink = gst_element_factory_make ("autovideosink", "sink");\r
-   \r
-  /* Create the empty pipeline */\r
-  pipeline = gst_pipeline_new ("test-pipeline");\r
-   \r
-  if (!pipeline || !source || !sink) {\r
-    g_printerr ("Not all elements could be created.\n");\r
-    return -1;\r
-  }\r
-  \r
-  /* Build the pipeline */\r
-  gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);\r
-  if (gst_element_link (source, sink) != TRUE) {\r
-    g_printerr ("Elements could not be linked.\n");\r
-    gst_object_unref (pipeline);\r
-    return -1;\r
-  }\r
-  \r
-  /* Modify the source's properties */\r
-  g_object_set (source, "pattern", 0, NULL);\r
-  \r
-  /* Start playing */\r
-  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);\r
-  if (ret == GST_STATE_CHANGE_FAILURE) {\r
-    g_printerr ("Unable to set the pipeline to the playing state.\n");\r
-    gst_object_unref (pipeline);\r
-    return -1;\r
-  }\r
-  \r
-  /* Wait until error or EOS */\r
-  bus = gst_element_get_bus (pipeline);\r
-  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);\r
-  \r
-  /* Parse message */\r
-  if (msg != NULL) {\r
-    GError *err;\r
-    gchar *debug_info;\r
-    \r
-    switch (GST_MESSAGE_TYPE (msg)) {\r
-      case GST_MESSAGE_ERROR:\r
-        gst_message_parse_error (msg, &err, &debug_info);\r
-        g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);\r
-        g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");\r
-        g_clear_error (&err);\r
-        g_free (debug_info);\r
-        break;\r
-      case GST_MESSAGE_EOS:\r
-        g_print ("End-Of-Stream reached.\n");\r
-        break;\r
-      default:\r
-        /* We should not reach here because we only asked for ERRORs and EOS */\r
-        g_printerr ("Unexpected message received.\n");\r
-        break;\r
-    }\r
-    gst_message_unref (msg);\r
-  }\r
-  \r
-  /* Free resources */\r
-  gst_object_unref (bus);\r
-  gst_element_set_state (pipeline, GST_STATE_NULL);\r
-  gst_object_unref (pipeline);\r
-  return 0;\r
+#include <gst/gst.h>
+
+int main(int argc, char *argv[]) {
+  GstElement *pipeline, *source, *sink;
+  GstBus *bus;
+  GstMessage *msg;
+  GstStateChangeReturn ret;
+
+  /* Initialize GStreamer */
+  gst_init (&argc, &argv);
+
+  /* Create the elements */
+  source = gst_element_factory_make ("videotestsrc", "source");
+  sink = gst_element_factory_make ("autovideosink", "sink");
+
+  /* Create the empty pipeline */
+  pipeline = gst_pipeline_new ("test-pipeline");
+
+  if (!pipeline || !source || !sink) {
+    g_printerr ("Not all elements could be created.\n");
+    return -1;
+  }
+
+  /* Build the pipeline */
+  gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
+  if (gst_element_link (source, sink) != TRUE) {
+    g_printerr ("Elements could not be linked.\n");
+    gst_object_unref (pipeline);
+    return -1;
+  }
+
+  /* Modify the source's properties */
+  g_object_set (source, "pattern", 0, NULL);
+
+  /* Start playing */
+  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  if (ret == GST_STATE_CHANGE_FAILURE) {
+    g_printerr ("Unable to set the pipeline to the playing state.\n");
+    gst_object_unref (pipeline);
+    return -1;
+  }
+
+  /* Wait until error or EOS */
+  bus = gst_element_get_bus (pipeline);
+  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
+
+  /* Parse message */
+  if (msg != NULL) {
+    GError *err;
+    gchar *debug_info;
+
+    switch (GST_MESSAGE_TYPE (msg)) {
+      case GST_MESSAGE_ERROR:
+        gst_message_parse_error (msg, &err, &debug_info);
+        g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);
+        g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");
+        g_clear_error (&err);
+        g_free (debug_info);
+        break;
+      case GST_MESSAGE_EOS:
+        g_print ("End-Of-Stream reached.\n");
+        break;
+      default:
+        /* We should not reach here because we only asked for ERRORs and EOS */
+        g_printerr ("Unexpected message received.\n");
+        break;
+    }
+    gst_message_unref (msg);
+  }
+
+  /* Free resources */
+  gst_object_unref (bus);
+  gst_element_set_state (pipeline, GST_STATE_NULL);
+  gst_object_unref (pipeline);
+  return 0;
 }
\ No newline at end of file