X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgstcaps.c;h=d036db173e0c799925113aa16c8be5a77a986400;hb=a143d9cb0caee85bbe0c5e8b86e9f05918153c9d;hp=0d00926bf19ce4a09beac86bafffd40853e32ada;hpb=2c272d74fd173148ce6c4137a454bc70cf71a911;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 0d00926..d036db1 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -19,6 +19,7 @@ /** * SECTION:gstcaps + * @title: GstCaps * @short_description: Structure describing sets of media formats * @see_also: #GstStructure, #GstMiniObject * @@ -34,7 +35,7 @@ * handle or produce at runtime. * * A #GstCaps can be constructed with the following code fragment: - * |[ + * |[ * GstCaps *caps = gst_caps_new_simple ("video/x-raw", * "format", G_TYPE_STRING, "I420", * "framerate", GST_TYPE_FRACTION, 25, 1, @@ -145,6 +146,15 @@ _priv_gst_caps_initialize (void) G_TYPE_STRING, gst_caps_transform_to_string); } +void +_priv_gst_caps_cleanup (void) +{ + gst_caps_unref (_gst_caps_any); + _gst_caps_any = NULL; + gst_caps_unref (_gst_caps_none); + _gst_caps_none = NULL; +} + GstCapsFeatures * __gst_caps_get_features_unchecked (const GstCaps * caps, guint idx) { @@ -206,6 +216,11 @@ _gst_caps_free (GstCaps * caps) #ifdef DEBUG_REFCOUNT GST_CAT_TRACE (GST_CAT_CAPS, "freeing caps %p", caps); #endif + +#ifdef USE_POISONING + memset (caps, 0xff, sizeof (GstCapsImpl)); +#endif + g_slice_free1 (sizeof (GstCapsImpl), caps); } @@ -385,9 +400,10 @@ G_DEFINE_POINTER_TYPE (GstStaticCaps, gst_static_caps); * * Converts a #GstStaticCaps to a #GstCaps. * - * Returns: (transfer full): a pointer to the #GstCaps. Unref after usage. - * Since the core holds an additional ref to the returned caps, - * use gst_caps_make_writable() on the returned caps to modify it. + * Returns: (transfer full) (nullable): a pointer to the #GstCaps. Unref + * after usage. Since the core holds an additional ref to the + * returned caps, use gst_caps_make_writable() on the returned caps + * to modify it. */ GstCaps * gst_static_caps_get (GstStaticCaps * static_caps) @@ -415,8 +431,13 @@ gst_static_caps_get (GstStaticCaps * static_caps) *caps = gst_caps_from_string (string); /* convert to string */ - if (G_UNLIKELY (*caps == NULL)) + if (G_UNLIKELY (*caps == NULL)) { g_critical ("Could not convert static caps \"%s\"", string); + goto done; + } + + /* Caps generated from static caps are usually leaked */ + GST_MINI_OBJECT_FLAG_SET (*caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); GST_CAT_TRACE (GST_CAT_CAPS, "created %p from string %s", static_caps, string); @@ -498,8 +519,8 @@ gst_caps_remove_and_get_structure (GstCaps * caps, guint idx) * Retrieves the structure with the given index from the list of structures * contained in @caps. The caller becomes the owner of the returned structure. * - * Returns: (transfer full): a pointer to the #GstStructure corresponding - * to @index. + * Returns: (transfer full) (nullable): a pointer to the #GstStructure + * corresponding to @index. */ GstStructure * gst_caps_steal_structure (GstCaps * caps, guint index) @@ -841,8 +862,8 @@ gst_caps_get_structure (const GstCaps * caps, guint index) * You do not need to free or unref the structure returned, it * belongs to the #GstCaps. * - * Returns: (transfer none): a pointer to the #GstCapsFeatures corresponding - * to @index + * Returns: (transfer none) (nullable): a pointer to the #GstCapsFeatures + * corresponding to @index * * Since: 1.2 */ @@ -912,6 +933,39 @@ gst_caps_set_features (GstCaps * caps, guint index, GstCapsFeatures * features) } /** + * gst_caps_set_features_simple: + * @caps: a #GstCaps + * @features: (allow-none) (transfer full): the #GstCapsFeatures to set + * + * Sets the #GstCapsFeatures @features for all the structures of @caps. + * + * Since: 1.16 + */ +void +gst_caps_set_features_simple (GstCaps * caps, GstCapsFeatures * features) +{ + guint i; + guint n; + + g_return_if_fail (caps != NULL); + g_return_if_fail (IS_WRITABLE (caps)); + + n = gst_caps_get_size (caps); + + for (i = 0; i < n; i++) { + GstCapsFeatures *f; + + /* Transfer ownership of @features to the last structure */ + if (features && i < n - 1) + f = gst_caps_features_copy (features); + else + f = features; + + gst_caps_set_features (caps, i, f); + } +} + +/** * gst_caps_copy_nth: * @caps: the #GstCaps to copy * @nth: the nth structure to copy @@ -1028,6 +1082,7 @@ gst_caps_set_simple_valist (GstCaps * caps, const char *field, va_list varargs) G_VALUE_COLLECT_INIT (&value, type, varargs, 0, &err); if (G_UNLIKELY (err)) { g_critical ("%s", err); + g_free (err); return; } @@ -1754,8 +1809,8 @@ gst_caps_structure_subtract (GSList ** into, const GstStructure * minuend, * @subtrahend: #GstCaps to subtract * * Subtracts the @subtrahend from the @minuend. - * This function does not work reliably if optional properties for caps - * are included on one caps and omitted on the other. + * > This function does not work reliably if optional properties for caps + * > are included on one caps and omitted on the other. * * Returns: (transfer full): the resulting caps */ @@ -2163,7 +2218,7 @@ gst_caps_fixate (GstCaps * caps) * can be converted back to a #GstCaps by gst_caps_from_string(). * * For debugging purposes its easier to do something like this: - * |[ + * |[ * GST_LOG ("caps are %" GST_PTR_FORMAT, caps); * ]| * This prints the caps in human readable form. @@ -2346,7 +2401,7 @@ gst_caps_from_string_inplace (GstCaps * caps, const gchar * string) * The current implementation of serialization will lead to unexpected results * when there are nested #GstCaps / #GstStructure deeper than one level. * - * Returns: (transfer full): a newly allocated #GstCaps + * Returns: (transfer full) (nullable): a newly allocated #GstCaps */ GstCaps * gst_caps_from_string (const gchar * string) @@ -2524,3 +2579,23 @@ gst_caps_filter_and_map_in_place (GstCaps * caps, GstCapsFilterMapFunc func, } } } + +/** + * gst_caps_copy: + * @caps: a #GstCaps. + * + * Creates a new #GstCaps as a copy of the old @caps. The new caps will have a + * refcount of 1, owned by the caller. The structures are copied as well. + * + * Note that this function is the semantic equivalent of a gst_caps_ref() + * followed by a gst_caps_make_writable(). If you only want to hold on to a + * reference to the data, you should use gst_caps_ref(). + * + * When you are finished with the caps, call gst_caps_unref() on it. + * + * Returns: the new #GstCaps + */ +GstCaps *(gst_caps_copy) (const GstCaps * caps) +{ + return GST_CAPS (gst_mini_object_copy (GST_MINI_OBJECT_CAST (caps))); +}