title: How to retrieve error messages from gstreamer? (C API)
body: <p>I am trying to initialize a gstreamer pipeline via the C API. The code looks similar to this:</p>
  
  <pre><code>[...]
  
  pipeline = (GstPipeline*)gst_pipeline_new(nullptr);
  if(!pipeline) {
      //error
      return;
  }
  
  [...]
  
  sink     = gst_element_factory_make("autoaudiosink", nullptr);
  if(!sink) {
      //error
      return;
  }
  
  if(!gst_bin_add((GstBin*)pipeline, sink)) {
      //error
      return;
  }
  
  [...]
  
  GstBus* bus = gst_pipeline_get_bus(pipeline);
  gst_bus_add_watch(bus, (GstBusFunc)bus_callback, this);
  gst_object_unref(bus);
  
  GstStateChangeReturn state = gst_element_set_state((GstElement*)pipeline, GST_STATE_PLAYING);
  
  if(!state) {
      //error2
      return;
  }
  [...]
  </code></pre>
  
  <p>Although errors appear in the cout I would like to retrieve the errors as a C string (or any format that I can process). How do I do that?</p>
  
  <p>I have read that errors are posted to the bus of the pipeline, yet when calling gst_element_set_state my bus callback isn't called. Maybe because the glib main loop is not running yet?</p>
  
  <p>Sorry, I am pretty new to the gstreamer/glib libraries and I couldn't find a clear answer in the (overwhelming) documentation.</p>