mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
update to do the new error handling and notification
Original commit message from CVS: update to do the new error handling and notification
This commit is contained in:
parent
d8a26dcd5a
commit
fd09a5765a
1 changed files with 28 additions and 71 deletions
|
@ -31,80 +31,36 @@ gst_factories_at_most_templates(GList *factories, GstPadDirection dir, guint max
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1:1 copy of gstpropsprivate.h, needed for INFO events */
|
static void
|
||||||
|
property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec)
|
||||||
#define GST_PROPS_ENTRY_IS_VARIABLE(a) (((GstPropsEntry*)(a))->propstype > GST_PROPS_VAR_ID)
|
|
||||||
|
|
||||||
typedef struct _GstPropsEntry GstPropsEntry;
|
|
||||||
|
|
||||||
struct _GstPropsEntry {
|
|
||||||
GQuark propid;
|
|
||||||
GstPropsId propstype;
|
|
||||||
|
|
||||||
union {
|
|
||||||
/* flat values */
|
|
||||||
gboolean bool_data;
|
|
||||||
guint32 fourcc_data;
|
|
||||||
gint int_data;
|
|
||||||
gfloat float_data;
|
|
||||||
|
|
||||||
/* structured values */
|
|
||||||
struct {
|
|
||||||
GList *entries;
|
|
||||||
} list_data;
|
|
||||||
struct {
|
|
||||||
gchar *string;
|
|
||||||
} string_data;
|
|
||||||
struct {
|
|
||||||
gint min;
|
|
||||||
gint max;
|
|
||||||
} int_range_data;
|
|
||||||
struct {
|
|
||||||
gfloat min;
|
|
||||||
gfloat max;
|
|
||||||
} float_range_data;
|
|
||||||
} data;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* end gstpropsprivate.h */
|
|
||||||
|
|
||||||
/* property output, stolen from gst-launch */
|
|
||||||
static void
|
|
||||||
print_props (gpointer data, gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GstPropsEntry *entry = (GstPropsEntry *)data;
|
GValue value = { 0, }; /* the important thing is that value.type = 0 */
|
||||||
GstElement *element = GST_ELEMENT (user_data);
|
gchar *str = 0;
|
||||||
|
|
||||||
g_print ("%s: %s: ", gst_element_get_name (element),
|
if (pspec->flags & G_PARAM_READABLE) {
|
||||||
g_quark_to_string (entry->propid));
|
g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||||
switch (entry->propstype) {
|
g_object_get_property (G_OBJECT (orig), pspec->name, &value);
|
||||||
case GST_PROPS_INT_ID:
|
if (G_IS_PARAM_SPEC_STRING (pspec))
|
||||||
g_print ("%d\n", entry->data.int_data);
|
str = g_value_dup_string (&value);
|
||||||
break;
|
else if (G_IS_PARAM_SPEC_ENUM (pspec))
|
||||||
case GST_PROPS_STRING_ID:
|
str = g_strdup_printf ("%d", g_value_get_enum (&value));
|
||||||
g_print ("%s\n", entry->data.string_data.string);
|
else if (G_IS_PARAM_SPEC_INT64 (pspec))
|
||||||
break;
|
str = g_strdup_printf ("%lld", g_value_get_int64 (&value));
|
||||||
case GST_PROPS_FLOAT_ID:
|
else
|
||||||
g_print ("%f\n", entry->data.float_data);
|
str = g_strdup_value_contents (&value);
|
||||||
break;
|
|
||||||
default:
|
g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str);
|
||||||
g_print ("unknown\n");
|
g_free (str);
|
||||||
|
g_value_unset(&value);
|
||||||
|
} else {
|
||||||
|
g_warning ("Parameter not readable. What's up with that?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_func (GstElement *element, GstEvent *event)
|
error_callback (GObject *object, GstObject *orig, gchar *error)
|
||||||
{
|
{
|
||||||
GstProps *props;
|
g_print ("ERROR: %s: %s\n", GST_OBJECT_NAME (orig), error);
|
||||||
|
|
||||||
if (event == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (GST_EVENT_TYPE (event) == GST_EVENT_INFO) {
|
|
||||||
props = GST_EVENT_INFO_PROPS (event);
|
|
||||||
|
|
||||||
g_list_foreach (props->properties, print_props, GST_EVENT_SRC (event));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,8 +84,9 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
/* create a new bin to hold the elements */
|
/* create a new bin to hold the elements */
|
||||||
bin = gst_pipeline_new("pipeline");
|
bin = gst_pipeline_new("pipeline");
|
||||||
g_signal_connect (G_OBJECT (bin), "event", G_CALLBACK (event_func), NULL);
|
g_signal_connect (bin, "deep_notify", G_CALLBACK (property_change_callback), NULL);
|
||||||
|
g_signal_connect (bin, "error", G_CALLBACK (error_callback), NULL);
|
||||||
|
|
||||||
/* create a disk reader */
|
/* create a disk reader */
|
||||||
filesrc = gst_elementfactory_make("filesrc", "disk_source");
|
filesrc = gst_elementfactory_make("filesrc", "disk_source");
|
||||||
g_object_set(G_OBJECT(filesrc),"location", argv[1], NULL);
|
g_object_set(G_OBJECT(filesrc),"location", argv[1], NULL);
|
||||||
|
|
Loading…
Reference in a new issue