parse_error
Description:
Extracts the GError and debug string from the GstMessage.
The values returned in the output arguments are copies; the caller must free them when done.
Typical usage of this function might be:
...
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR: {
GError *err = NULL;
gchar *dbg_info = NULL;
gst_message_parse_error (msg, &err, &dbg_info);
g_printerr ("ERROR from element %s: %s\n",
GST_OBJECT_NAME (msg->src), err->message);
g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
g_error_free (err);
g_free (dbg_info);
break;
}
...
}
...
MT safe.
Example: GStreamer concepts:
// See http://docs.gstreamer.com/x/ZgAF
// for a detailed description
public static int main (string[] args) {
// Initialize GStreamer:
Gst.init (ref args);
// Create the elements:
Gst.Element source = Gst.ElementFactory.make ("videotestsrc", "source");
Gst.Element sink = Gst.ElementFactory.make ("autovideosink", "sink");
// Create the empty pipeline:
Gst.Pipeline pipeline = new Gst.Pipeline ("test-pipeline");
if (source == null || sink == null || pipeline == null) {
stderr.puts ("Not all elements could be created.\n");
return -1;
}
// Build the pipeline:
pipeline.add_many (source, sink);
if (source.link (sink) != true) {
stderr.puts ("Elements could not be linked.\n");
return -1;
}
// Modify the source's properties:
source.set ("pattern", 0);
// Start playing:
Gst.StateChangeReturn ret = pipeline.set_state (Gst.State.PLAYING);
if (ret == Gst.StateChangeReturn.FAILURE) {
stderr.puts ("Unable to set the pipeline to the playing state.\n");
return -1;
}
// Wait until error or EOS:
Gst.Bus bus = pipeline.get_bus ();
Gst.Message msg = bus.timed_pop_filtered (Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS);
// Parse message:
if (msg != null) {
switch (msg.type) {
case Gst.MessageType.ERROR:
GLib.Error err;
string debug_info;
msg.parse_error (out err, out debug_info);
stderr.printf ("Error received from element %s: %s\n", msg.src.name, err.message);
stderr.printf ("Debugging information: %s\n", (debug_info != null)? debug_info : "none");
break;
case Gst.MessageType.EOS:
print ("End-Of-Stream reached.\n");
break;
default:
// We should not reach here because we only asked for ERRORs and EOS:
assert_not_reached ();
}
}
// Free resources:
pipeline.set_state (Gst.State.NULL);
return 0;
}
valac --pkg gstreamer-1.0 concepts.vala
Parameters:
this |
A valid Message of type GST_MESSAGE_ERROR. |
gerror |
location for the GError |
debug |
location for the debug message, or |