From: Ronald S. Bultje Date: Mon, 29 Nov 2004 17:02:09 +0000 (+0000) Subject: gst/: Deprecate _type_is_fixed, use _value_is_fixed instead, since the fixedness... X-Git-Tag: RELEASE-0_8_8~58 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d61d9045d12c47e284694fe62dee5d38f728ff7;p=platform%2Fupstream%2Fgstreamer.git gst/: Deprecate _type_is_fixed, use _value_is_fixed instead, since the fixedness depends on the content. Original commit message from CVS: * gst/gstcaps.c: (gst_caps_is_fixed_foreach): * gst/gstpad.c: (_gst_pad_default_fixate_value), (_gst_pad_default_fixate_foreach): * gst/gstvalue.c: (gst_type_is_fixed), (gst_value_is_fixed): * gst/gstvalue.h: Deprecate _type_is_fixed, use _value_is_fixed instead, since in some cases (arrays), the fixedness depends on the content. * gst/gstqueue.c: (gst_queue_handle_src_query): Check for availability before doing something. --- diff --git a/ChangeLog b/ChangeLog index 3ab02d8e..6e73931 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-11-29 Ronald S. Bultje + + * gst/gstcaps.c: (gst_caps_is_fixed_foreach): + * gst/gstpad.c: (_gst_pad_default_fixate_value), + (_gst_pad_default_fixate_foreach): + * gst/gstvalue.c: (gst_type_is_fixed), (gst_value_is_fixed): + * gst/gstvalue.h: + Deprecate _type_is_fixed, use _value_is_fixed instead, since + in some cases (arrays), the fixedness depends on the content. + * gst/gstqueue.c: (gst_queue_handle_src_query): + Check for availability before doing something. + 2004-11-29 Wim Taymans * testsuite/threads/Makefile.am: diff --git a/gst/gstcaps.c b/gst/gstcaps.c index a7d29f3..e84263e 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -553,9 +553,7 @@ gst_caps_is_chained (const GstCaps * caps) static gboolean gst_caps_is_fixed_foreach (GQuark field_id, GValue * value, gpointer unused) { - GType type = G_VALUE_TYPE (value); - - return gst_type_is_fixed (type); + return gst_value_is_fixed (value); } /** diff --git a/gst/gstpad.c b/gst/gstpad.c index b412f22..9c2ba11 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2073,32 +2073,57 @@ gst_pad_get_ghost_pad_list (GstPad * pad) } static gboolean -_gst_pad_default_fixate_foreach (GQuark field_id, GValue * value, gpointer s) +_gst_pad_default_fixate_value (const GValue * value, GValue * dest) { - GstStructure *structure = (GstStructure *) s; GType type = G_VALUE_TYPE (value); - if (gst_type_is_fixed (type)) + if (gst_value_is_fixed (value)) return TRUE; if (type == GST_TYPE_INT_RANGE) { - gst_structure_set (structure, g_quark_to_string (field_id), - G_TYPE_INT, gst_value_get_int_range_min (value), NULL); - return FALSE; - } - if (type == GST_TYPE_DOUBLE_RANGE) { - gst_structure_set (structure, g_quark_to_string (field_id), - G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL); - return FALSE; - } - if (type == GST_TYPE_LIST) { - gst_structure_set_value (structure, g_quark_to_string (field_id), - gst_value_list_get_value (value, 0)); - return FALSE; + g_value_init (dest, G_TYPE_INT); + g_value_set_int (dest, gst_value_get_int_range_min (value)); + } else if (type == GST_TYPE_DOUBLE_RANGE) { + g_value_init (dest, G_TYPE_DOUBLE); + g_value_set_double (dest, gst_value_get_double_range_min (value)); + } else if (type == GST_TYPE_LIST) { + gst_value_init_and_copy (dest, gst_value_list_get_value (value, 0)); + } else if (type == GST_TYPE_FIXED_LIST) { + gint size, n; + GValue dest_kid = { 0 }; + const GValue *kid; + + /* check recursively */ + g_value_init (dest, GST_TYPE_FIXED_LIST); + size = gst_value_list_get_size (value); + for (n = 0; n < size; n++) { + kid = gst_value_list_get_value (value, n); + if (_gst_pad_default_fixate_value (kid, &dest_kid)) { + gst_value_list_append_value (dest, kid); + } else { + gst_value_list_append_value (dest, &dest_kid); + g_value_unset (&dest_kid); + } + } + } else { + g_critical ("Don't know how to fixate value type %s", g_type_name (type)); } - g_critical ("don't know how to fixate type %s", g_type_name (type)); - return TRUE; + return FALSE; +} + +static gboolean +_gst_pad_default_fixate_foreach (GQuark field_id, GValue * value, gpointer s) +{ + GstStructure *structure = (GstStructure *) s; + GValue dest = { 0 }; + + if (_gst_pad_default_fixate_value (value, &dest)) + return TRUE; + gst_structure_id_set_value (structure, field_id, &dest); + g_value_unset (&dest); + + return FALSE; } static GstCaps * diff --git a/gst/gstqueue.c b/gst/gstqueue.c index c38b12f..8e18cf7 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -953,10 +953,10 @@ gst_queue_handle_src_query (GstPad * pad, GstQueryType type, GstFormat * fmt, gint64 * value) { GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad)); - gboolean res; - res = gst_pad_query (GST_PAD_PEER (queue->sinkpad), type, fmt, value); - if (!res) + if (!GST_PAD_PEER (queue->sinkpad)) + return FALSE; + if (!gst_pad_query (GST_PAD_PEER (queue->sinkpad), type, fmt, value)) return FALSE; if (type == GST_QUERY_POSITION) { diff --git a/gst/gstvalue.c b/gst/gstvalue.c index 0cd297f..a11a3d8 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -2360,8 +2360,8 @@ gst_type_is_fixed (GType type) type == GST_TYPE_LIST) { return FALSE; } - if (G_TYPE_IS_FUNDAMENTAL (type) && - type < G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_GLIB_LAST)) { + if (G_TYPE_FUNDAMENTAL (type) <= + G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_GLIB_LAST)) { return TRUE; } if (type == GST_TYPE_BUFFER || type == GST_TYPE_FOURCC @@ -2372,6 +2372,41 @@ gst_type_is_fixed (GType type) return FALSE; } +/** + * gst_value_is_fixed: + * @value: the #GValue to check + * + * Tests if the given GValue, if available in a GstStructure (or any other + * container) contains a "fixed" (which means: one value) or an "unfixed" + * (which means: multiple possible values, such as data lists or data + * ranges) value. + * + * Returns: true if the value is "fixed". + */ + +gboolean +gst_value_is_fixed (const GValue * value) +{ + GType type = G_VALUE_TYPE (value); + + if (type == GST_TYPE_FIXED_LIST) { + gboolean fixed = TRUE; + gint size, n; + const GValue *kid; + + /* check recursively */ + size = gst_value_list_get_size (value); + for (n = 0; n < size; n++) { + kid = gst_value_list_get_value (value, n); + fixed &= gst_value_is_fixed (kid); + } + + return fixed; + } + + return gst_type_is_fixed (type); +} + /************ * fraction * ************/ diff --git a/gst/gstvalue.h b/gst/gstvalue.h index 9bd0e79..617566c 100644 --- a/gst/gstvalue.h +++ b/gst/gstvalue.h @@ -181,6 +181,7 @@ void gst_value_register_subtract_func (GType minuend_type, /* fixation */ gboolean gst_type_is_fixed (GType type); +gboolean gst_value_is_fixed (const GValue *value); /* private */ void _gst_value_initialize (void); diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index c38b12f..8e18cf7 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -953,10 +953,10 @@ gst_queue_handle_src_query (GstPad * pad, GstQueryType type, GstFormat * fmt, gint64 * value) { GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad)); - gboolean res; - res = gst_pad_query (GST_PAD_PEER (queue->sinkpad), type, fmt, value); - if (!res) + if (!GST_PAD_PEER (queue->sinkpad)) + return FALSE; + if (!gst_pad_query (GST_PAD_PEER (queue->sinkpad), type, fmt, value)) return FALSE; if (type == GST_QUERY_POSITION) {