X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgstcaps.h;h=f229742fa285480f78bbf0ed4db8413eeb77b3c1;hb=272142089e415474e55ca85b47b7a8f14dbee3d2;hp=caf42677771feba88b5dbc074187f0347a11924c;hpb=007b16b02497a1dd4816c224e04710bcd3653537;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstcaps.h b/gst/gstcaps.h index caf4267..f229742 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS -extern GType _gst_caps_type; +GST_EXPORT GType _gst_caps_type; #define GST_TYPE_CAPS (_gst_caps_type) #define GST_IS_CAPS(obj) (GST_IS_MINI_OBJECT_TYPE((obj), GST_TYPE_CAPS)) @@ -38,13 +38,13 @@ extern GType _gst_caps_type; /** * GstCapsFlags: - * @GST_CAPS_FLAGS_ANY: Caps has no specific content, but can contain + * @GST_CAPS_FLAG_ANY: Caps has no specific content, but can contain * anything. * * Extra flags for a caps. */ typedef enum { - GST_CAPS_FLAGS_ANY = (GST_MINI_OBJECT_FLAG_LAST << 0) + GST_CAPS_FLAG_ANY = (GST_MINI_OBJECT_FLAG_LAST << 0) } GstCapsFlags; /** @@ -83,16 +83,18 @@ typedef enum { * GST_CAPS_ANY: * * Means that the element/pad can output 'anything'. Useful for elements - * that output unknown media, such as filesrc. + * that output unknown media, such as filesrc. This macro returns a singleton and + * should not be unreffed. */ -#define GST_CAPS_ANY gst_caps_new_any() +#define GST_CAPS_ANY _gst_caps_any /** * GST_CAPS_NONE: * * The opposite of %GST_CAPS_ANY: it means that the pad/element outputs an - * undefined media type that can not be detected. + * undefined media type that can not be detected. This macro returns a singleton + * and should not be unreffed. */ -#define GST_CAPS_NONE gst_caps_new_empty() +#define GST_CAPS_NONE _gst_caps_none /** * GST_STATIC_CAPS_ANY: @@ -127,8 +129,7 @@ typedef enum { */ #define GST_STATIC_CAPS(string) \ { \ - /* miniobject */ { { 0, 0, 0, 0, NULL, NULL, NULL }, \ - /* caps */ NULL, GST_PADDING_INIT }, \ + /* caps */ NULL, \ /* string */ string, \ GST_PADDING_INIT \ } @@ -136,6 +137,8 @@ typedef enum { typedef struct _GstCaps GstCaps; typedef struct _GstStaticCaps GstStaticCaps; +GST_EXPORT GstCaps * _gst_caps_any; +GST_EXPORT GstCaps * _gst_caps_none; /** * GST_CAPS_FLAGS: * @caps: a #GstCaps. @@ -163,7 +166,7 @@ typedef struct _GstStaticCaps GstStaticCaps; /** * GST_CAPS_FLAG_IS_SET: * @caps: a #GstCaps. - * @flag: the #GstCapsFlag to check. + * @flag: the #GstCapsFlags to check. * * Gives the status of a specific flag on a caps. */ @@ -171,7 +174,7 @@ typedef struct _GstStaticCaps GstStaticCaps; /** * GST_CAPS_FLAG_SET: * @caps: a #GstCaps. - * @flag: the #GstCapsFlag to set. + * @flag: the #GstCapsFlags to set. * * Sets a caps flag on a caps. */ @@ -179,7 +182,7 @@ typedef struct _GstStaticCaps GstStaticCaps; /** * GST_CAPS_FLAG_UNSET: * @caps: a #GstCaps. - * @flag: the #GstCapsFlag to clear. + * @flag: the #GstCapsFlags to clear. * * Clears a caps flag. */ @@ -254,6 +257,84 @@ gst_caps_copy (const GstCaps * caps) return GST_CAPS (gst_mini_object_copy (GST_MINI_OBJECT_CAST (caps))); } +/** + * gst_caps_is_writable: + * @caps: a #GstCaps + * + * Tests if you can safely modify @caps. It is only safe to modify caps when + * there is only one owner of the caps - ie, the refcount is 1. + */ +#define gst_caps_is_writable(caps) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (caps)) + +/** + * gst_caps_make_writable: + * @caps: (transfer full): a #GstCaps + * + * Returns a writable copy of @caps. + * + * If there is only one reference count on @caps, the caller must be the owner, + * and so this function will return the caps object unchanged. If on the other + * hand there is more than one reference on the object, a new caps object will + * be returned. The caller's reference on @caps will be removed, and instead the + * caller will own a reference to the returned object. + * + * In short, this function unrefs the caps in the argument and refs the caps + * that it returns. Don't access the argument after calling this function. See + * also: gst_caps_ref(). + * + * Returns: (transfer full): a writable caps which may or may not be the + * same as @caps + */ +#define gst_caps_make_writable(caps) GST_CAPS_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (caps))) + +/** + * gst_caps_replace: + * @old_caps: (inout) (transfer full): pointer to a pointer to a #GstCaps to be + * replaced. + * @new_caps: (transfer none) (allow-none): pointer to a #GstCaps that will + * replace the caps pointed to by @ocaps. + * + * Modifies a pointer to a #GstCaps to point to a different #GstCaps. The + * modification is done atomically (so this is useful for ensuring thread safety + * in some cases), and the reference counts are updated appropriately (the old + * caps is unreffed, the new is reffed). + * + * Either @ncaps or the #GstCaps pointed to by @ocaps may be NULL. + * + * Returns: TRUE if @new_caps was different from @old_caps + */ +#ifdef _FOOL_GTK_DOC_ +G_INLINE_FUNC gboolean gst_caps_replace (GstCaps **old_caps, GstCaps *new_caps); +#endif + +static inline gboolean +gst_caps_replace (GstCaps **old_caps, GstCaps *new_caps) +{ + return gst_mini_object_replace ((GstMiniObject **) old_caps, (GstMiniObject *) new_caps); +} + +/** + * gst_caps_take: + * @old_caps: (inout) (transfer full): pointer to a pointer to a #GstCaps to be + * replaced. + * @new_caps: (transfer full) (allow-none): pointer to a #GstCaps that will + * replace the caps pointed to by @ocaps. + * + * Modifies a pointer to a #GstCaps to point to a different #GstCaps. This + * function is similar to gst_caps_replace() except that it takes ownership + * of @new_caps. + * + * Returns: TRUE if @new_caps was different from @old_caps + */ +#ifdef _FOOL_GTK_DOC_ +G_INLINE_FUNC gboolean gst_caps_take (GstCaps **old_caps, GstCaps *new_caps); +#endif + +static inline gboolean +gst_caps_take (GstCaps **old_caps, GstCaps *new_caps) +{ + return gst_mini_object_take ((GstMiniObject **) old_caps, (GstMiniObject *) new_caps); +} /** * GstCaps: @@ -263,12 +344,6 @@ gst_caps_copy (const GstCaps * caps) */ struct _GstCaps { GstMiniObject mini_object; - - /*< private >*/ - GPtrArray *structs; - - /*< private >*/ - gpointer _gst_reserved[GST_PADDING]; }; /** @@ -282,45 +357,47 @@ struct _GstCaps { */ struct _GstStaticCaps { /*< public >*/ - GstCaps caps; + GstCaps *caps; const char *string; /*< private >*/ gpointer _gst_reserved[GST_PADDING]; }; +GType gst_caps_get_type (void); + GstCaps * gst_caps_new_empty (void); GstCaps * gst_caps_new_any (void); +GstCaps * gst_caps_new_empty_simple (const char *media_type) G_GNUC_WARN_UNUSED_RESULT; GstCaps * gst_caps_new_simple (const char *media_type, const char *fieldname, - ...); -GstCaps * gst_caps_new_full (GstStructure *struct1, ...); + ...) G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_new_full (GstStructure *struct1, + ...) G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT; GstCaps * gst_caps_new_full_valist (GstStructure *structure, - va_list var_args); - -/* reference counting */ -GstCaps * gst_caps_make_writable (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT; + va_list var_args) G_GNUC_WARN_UNUSED_RESULT; GType gst_static_caps_get_type (void); GstCaps * gst_static_caps_get (GstStaticCaps *static_caps); +void gst_static_caps_cleanup (GstStaticCaps *static_caps); /* manipulation */ void gst_caps_append (GstCaps *caps1, GstCaps *caps2); -void gst_caps_merge (GstCaps *caps1, - GstCaps *caps2); void gst_caps_append_structure (GstCaps *caps, GstStructure *structure); void gst_caps_remove_structure (GstCaps *caps, guint idx); -void gst_caps_merge_structure (GstCaps *caps, - GstStructure *structure); +GstCaps * gst_caps_merge (GstCaps *caps1, + GstCaps *caps2) G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_merge_structure (GstCaps *caps, + GstStructure *structure) G_GNUC_WARN_UNUSED_RESULT; guint gst_caps_get_size (const GstCaps *caps); GstStructure * gst_caps_get_structure (const GstCaps *caps, guint index); -GstStructure * gst_caps_steal_structure (GstCaps *caps, - guint index); -GstCaps * gst_caps_copy_nth (const GstCaps *caps, guint nth); -void gst_caps_truncate (GstCaps *caps); +GstStructure * gst_caps_steal_structure (GstCaps *caps, + guint index) G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_copy_nth (const GstCaps *caps, guint nth) G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_truncate (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT; void gst_caps_set_value (GstCaps *caps, const char *field, const GValue *value); @@ -338,32 +415,34 @@ gboolean gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2); gboolean gst_caps_is_subset (const GstCaps *subset, const GstCaps *superset); +gboolean gst_caps_is_subset_structure (const GstCaps *caps, + const GstStructure *structure); gboolean gst_caps_is_equal (const GstCaps *caps1, const GstCaps *caps2); gboolean gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2); gboolean gst_caps_can_intersect (const GstCaps * caps1, const GstCaps * caps2); +gboolean gst_caps_is_strictly_equal (const GstCaps *caps1, + const GstCaps *caps2); /* operations */ -GstCaps * gst_caps_intersect (const GstCaps *caps1, - const GstCaps *caps2); -GstCaps * gst_caps_intersect_full (const GstCaps *caps1, - const GstCaps *caps2, - GstCapsIntersectMode mode); -GstCaps * gst_caps_subtract (const GstCaps *minuend, - const GstCaps *subtrahend); -GstCaps * gst_caps_union (const GstCaps *caps1, - const GstCaps *caps2); -GstCaps * gst_caps_normalize (const GstCaps *caps); -gboolean gst_caps_do_simplify (GstCaps *caps); +GstCaps * gst_caps_intersect (GstCaps *caps1, + GstCaps *caps2) G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_intersect_full (GstCaps *caps1, + GstCaps *caps2, + GstCapsIntersectMode mode) G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_subtract (GstCaps *minuend, + GstCaps *subtrahend) G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_normalize (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT; +GstCaps * gst_caps_simplify (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT; + +GstCaps * gst_caps_fixate (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT; /* utility */ -void gst_caps_replace (GstCaps **caps, - GstCaps *newcaps); -gchar * gst_caps_to_string (const GstCaps *caps); -GstCaps * gst_caps_from_string (const gchar *string); +gchar * gst_caps_to_string (const GstCaps *caps) G_GNUC_MALLOC; +GstCaps * gst_caps_from_string (const gchar *string) G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS