gst-inspect: fix unused-const-variable error in windows
[platform/upstream/gstreamer.git] / gst / gstcaps.h
index 2262a1c..603422f 100644 (file)
@@ -13,8 +13,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifndef __GST_CAPS_H__
 #include <gst/gstconfig.h>
 #include <gst/gstminiobject.h>
 #include <gst/gststructure.h>
+#include <gst/gstcapsfeatures.h>
 #include <gst/glib-compat.h>
 
 G_BEGIN_DECLS
 
-extern GType _gst_caps_type;
+GST_API 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 +39,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;
 
 /**
@@ -71,8 +72,6 @@ typedef enum {
  * another element's caps priority order when intersecting with its own caps.
  * Example: If caps1 is [A, B, C] and caps2 is [E, B, D, A], the result
  * would be [A, B], maintaining the first caps priority on the intersection.
- *
- * Since: 0.10.33
  */
 typedef enum {
   GST_CAPS_INTERSECT_ZIG_ZAG            =  0,
@@ -83,16 +82,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 +128,7 @@ typedef enum {
  */
 #define GST_STATIC_CAPS(string) \
 { \
-  /* miniobject */ { { 0, 0, 0, 0, NULL, NULL, NULL }, \
-  /* caps */ NULL }, \
+  /* caps */ NULL, \
   /* string */ string, \
   GST_PADDING_INIT \
 }
@@ -136,6 +136,9 @@ typedef enum {
 typedef struct _GstCaps GstCaps;
 typedef struct _GstStaticCaps GstStaticCaps;
 
+GST_API GstCaps * _gst_caps_any;
+
+GST_API GstCaps * _gst_caps_none;
 /**
  * GST_CAPS_FLAGS:
  * @caps: a #GstCaps.
@@ -201,10 +204,6 @@ typedef struct _GstStaticCaps GstStaticCaps;
  *
  * Returns: the same #GstCaps object.
  */
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC GstCaps * gst_caps_ref (GstCaps * caps);
-#endif
-
 static inline GstCaps *
 gst_caps_ref (GstCaps * caps)
 {
@@ -218,48 +217,43 @@ gst_caps_ref (GstCaps * caps)
  * Unref a #GstCaps and and free all its structures and the
  * structures' values when the refcount reaches 0.
  */
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC void gst_caps_unref (GstCaps * caps);
-#endif
-
 static inline void
 gst_caps_unref (GstCaps * caps)
 {
   gst_mini_object_unref (GST_MINI_OBJECT_CAST (caps));
 }
 
-/* copy caps */
 /**
- * gst_caps_copy:
- * @caps: a #GstCaps.
+ * gst_clear_caps: (skip)
+ * @caps_ptr: a pointer to a #GstCaps reference
  *
- * 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.
+ * Clears a reference to a #GstCaps.
  *
- * 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().
+ * @caps_ptr must not be %NULL.
  *
- * When you are finished with the caps, call gst_caps_unref() on it.
+ * If the reference is %NULL then this function does nothing. Otherwise, the
+ * reference count of the caps is decreased and the pointer is set to %NULL.
  *
- * Returns: the new #GstCaps
+ * Since: 1.16
  */
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC GstCaps * gst_caps_copy (const GstCaps * caps);
-#endif
-
-static inline GstCaps *
-gst_caps_copy (const GstCaps * caps)
+static inline void
+gst_clear_caps (GstCaps ** caps_ptr)
 {
-  return GST_CAPS (gst_mini_object_copy (GST_MINI_OBJECT_CAST (caps)));
+  gst_clear_mini_object ((GstMiniObject **) caps_ptr);
 }
 
+/* copy caps */
+GST_API
+GstCaps * gst_caps_copy (const GstCaps * caps);
+
+#define gst_caps_copy(caps) 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.
+ * there is only one owner of the caps - ie, the object is writable.
  */
 #define         gst_caps_is_writable(caps)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (caps))
 
@@ -286,24 +280,44 @@ gst_caps_copy (const GstCaps * caps)
 
 /**
  * gst_caps_replace:
- * @ocaps: (inout) (transfer full): pointer to a pointer to a #GstCaps to be
- *     replaced.
- * @ncaps: (transfer none) (allow-none): pointer to a #GstCaps that will
- *     replace the caps pointed to by @ocaps.
+ * @old_caps: (inout) (transfer full) (nullable): 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 @old_caps.
  *
  * 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.
+ * Either @new_caps or the #GstCaps pointed to by @old_caps may be %NULL.
+ *
+ * Returns: %TRUE if @new_caps was different from @old_caps
  */
-#define         gst_caps_replace(ocaps,ncaps) \
-G_STMT_START {                                                                \
-  GstCaps **___ocapsaddr = (GstCaps **)(ocaps);         \
-  gst_mini_object_replace ((GstMiniObject **)___ocapsaddr, \
-      GST_MINI_OBJECT_CAST (ncaps));                       \
-} G_STMT_END
+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 @old_caps.
+ *
+ * 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
+ */
+static inline gboolean
+gst_caps_take (GstCaps **old_caps, GstCaps *new_caps)
+{
+    return gst_mini_object_take ((GstMiniObject **) old_caps, (GstMiniObject *) new_caps);
+}
 
 /**
  * GstCaps:
@@ -313,9 +327,6 @@ G_STMT_START {                                                                \
  */
 struct _GstCaps {
   GstMiniObject mini_object;
-
-  /*< private >*/
-  gpointer     priv;
 };
 
 /**
@@ -329,94 +340,242 @@ struct _GstCaps {
  */
 struct _GstStaticCaps {
   /*< public >*/
-  GstCaps caps;
+  GstCaps *caps;
   const char *string;
 
   /*< private >*/
   gpointer _gst_reserved[GST_PADDING];
 };
 
+/**
+ * GstCapsForeachFunc:
+ * @features: the #GstCapsFeatures
+ * @structure: the #GstStructure
+ * @user_data: user data
+ *
+ * A function that will be called in gst_caps_foreach(). The function may
+ * not modify @features or @structure.
+ *
+ * Returns: %TRUE if the foreach operation should continue, %FALSE if
+ * the foreach operation should stop with %FALSE.
+ *
+ * Since: 1.6
+ */
+typedef gboolean (*GstCapsForeachFunc) (GstCapsFeatures *features,
+                                        GstStructure    *structure,
+                                        gpointer         user_data);
+
+/**
+ * GstCapsMapFunc:
+ * @features: the #GstCapsFeatures
+ * @structure: the #GstStructure
+ * @user_data: user data
+ *
+ * A function that will be called in gst_caps_map_in_place(). The function
+ * may modify @features and @structure.
+ *
+ * Returns: %TRUE if the map operation should continue, %FALSE if
+ * the map operation should stop with %FALSE.
+ */
+typedef gboolean (*GstCapsMapFunc)     (GstCapsFeatures *features,
+                                        GstStructure    *structure,
+                                        gpointer         user_data);
+
+/**
+ * GstCapsFilterMapFunc:
+ * @features: the #GstCapsFeatures
+ * @structure: the #GstStructure
+ * @user_data: user data
+ *
+ * A function that will be called in gst_caps_filter_and_map_in_place().
+ * The function may modify @features and @structure, and both will be
+ * removed from the caps if %FALSE is returned.
+ *
+ * Returns: %TRUE if the features and structure should be preserved,
+ * %FALSE if it should be removed.
+ */
+typedef gboolean (*GstCapsFilterMapFunc) (GstCapsFeatures *features,
+                                          GstStructure    *structure,
+                                          gpointer user_data);
+
+
+GST_API
 GType             gst_caps_get_type                (void);
 
+GST_API
 GstCaps *         gst_caps_new_empty               (void);
+
+GST_API
 GstCaps *         gst_caps_new_any                 (void);
-GstCaps *         gst_caps_new_empty_simple        (const char    *media_type);
+
+GST_API
+GstCaps *         gst_caps_new_empty_simple        (const char    *media_type) G_GNUC_WARN_UNUSED_RESULT;
+
+GST_API
 GstCaps *         gst_caps_new_simple              (const char    *media_type,
                                                     const char    *fieldname,
-                                                    ...) G_GNUC_NULL_TERMINATED;
+                                                    ...) G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT;
+GST_API
 GstCaps *         gst_caps_new_full                (GstStructure  *struct1,
-                                                    ...) G_GNUC_NULL_TERMINATED;
+                                                    ...) G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT;
+GST_API
 GstCaps *         gst_caps_new_full_valist         (GstStructure  *structure,
-                                                    va_list        var_args);
-
+                                                    va_list        var_args) G_GNUC_WARN_UNUSED_RESULT;
+GST_API
 GType             gst_static_caps_get_type         (void);
+
+GST_API
 GstCaps *         gst_static_caps_get              (GstStaticCaps *static_caps);
+
+GST_API
 void              gst_static_caps_cleanup          (GstStaticCaps *static_caps);
 
 /* manipulation */
+
+GST_API
 void              gst_caps_append                  (GstCaps       *caps1,
                                                     GstCaps       *caps2);
-void              gst_caps_merge                   (GstCaps       *caps1,
-                                                    GstCaps       *caps2);
+GST_API
 void              gst_caps_append_structure        (GstCaps       *caps,
                                                     GstStructure  *structure);
+GST_API
+void              gst_caps_append_structure_full   (GstCaps       *caps,
+                                                    GstStructure  *structure,
+                                                    GstCapsFeatures *features);
+GST_API
 void              gst_caps_remove_structure        (GstCaps       *caps, guint idx);
-void              gst_caps_merge_structure         (GstCaps       *caps,
-                                                    GstStructure  *structure);
+
+GST_API
+GstCaps *         gst_caps_merge                   (GstCaps       *caps1,
+                                                    GstCaps       *caps2) G_GNUC_WARN_UNUSED_RESULT;
+GST_API
+GstCaps *         gst_caps_merge_structure         (GstCaps       *caps,
+                                                    GstStructure  *structure) G_GNUC_WARN_UNUSED_RESULT;
+GST_API
+GstCaps *         gst_caps_merge_structure_full    (GstCaps       *caps,
+                                                    GstStructure  *structure,
+                                                    GstCapsFeatures *features) G_GNUC_WARN_UNUSED_RESULT;
+
+GST_API
 guint             gst_caps_get_size                (const GstCaps *caps);
+
+GST_API
 GstStructure *    gst_caps_get_structure           (const GstCaps *caps,
                                                     guint          index);
-GstStructure *    gst_caps_steal_structure         (GstCaps *caps,
+GST_API
+GstStructure *    gst_caps_steal_structure         (GstCaps       *caps,
+                                                    guint          index) G_GNUC_WARN_UNUSED_RESULT;
+GST_API
+void              gst_caps_set_features            (GstCaps *caps,
+                                                    guint          index,
+                                                    GstCapsFeatures * features);
+GST_API
+void              gst_caps_set_features_simple        (GstCaps *caps,
+                                                       GstCapsFeatures * features);
+
+GST_API
+GstCapsFeatures * gst_caps_get_features            (const GstCaps *caps,
                                                     guint          index);
-GstCaps *         gst_caps_copy_nth                (const GstCaps *caps, guint nth);
-void              gst_caps_truncate                (GstCaps       *caps);
+GST_API
+GstCaps *         gst_caps_copy_nth                (const GstCaps *caps, guint nth) G_GNUC_WARN_UNUSED_RESULT;
+
+GST_API
+GstCaps *         gst_caps_truncate                (GstCaps       *caps) G_GNUC_WARN_UNUSED_RESULT;
+
+GST_API
 void              gst_caps_set_value               (GstCaps       *caps,
                                                     const char    *field,
                                                     const GValue  *value);
+GST_API
 void              gst_caps_set_simple              (GstCaps       *caps,
                                                     const char    *field, ...) G_GNUC_NULL_TERMINATED;
+GST_API
 void              gst_caps_set_simple_valist       (GstCaps       *caps,
                                                     const char    *field,
                                                     va_list        varargs);
+GST_API
+gboolean          gst_caps_foreach                 (const GstCaps       *caps,
+                                                    GstCapsForeachFunc   func,
+                                                    gpointer             user_data);
+GST_API
+gboolean          gst_caps_map_in_place            (GstCaps        *caps,
+                                                    GstCapsMapFunc  func,
+                                                    gpointer        user_data);
+GST_API
+void              gst_caps_filter_and_map_in_place (GstCaps              *caps,
+                                                    GstCapsFilterMapFunc  func,
+                                                    gpointer              user_data);
 
 /* tests */
+
+GST_API
 gboolean          gst_caps_is_any                  (const GstCaps *caps);
+
+GST_API
 gboolean          gst_caps_is_empty                (const GstCaps *caps);
+
+GST_API
 gboolean          gst_caps_is_fixed                (const GstCaps *caps);
+
+GST_API
 gboolean          gst_caps_is_always_compatible    (const GstCaps *caps1,
                                                     const GstCaps *caps2);
+GST_API
 gboolean          gst_caps_is_subset              (const GstCaps *subset,
                                                    const GstCaps *superset);
+GST_API
 gboolean          gst_caps_is_subset_structure     (const GstCaps *caps,
                                                     const GstStructure *structure);
+GST_API
+gboolean          gst_caps_is_subset_structure_full (const GstCaps *caps,
+                                                     const GstStructure *structure,
+                                                     const GstCapsFeatures *features);
+GST_API
 gboolean          gst_caps_is_equal               (const GstCaps *caps1,
                                                    const GstCaps *caps2);
+GST_API
 gboolean          gst_caps_is_equal_fixed          (const GstCaps *caps1,
                                                    const GstCaps *caps2);
+GST_API
 gboolean          gst_caps_can_intersect           (const GstCaps * caps1,
                                                    const GstCaps * caps2);
+GST_API
 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);
 
-void              gst_caps_fixate                  (GstCaps       *caps);
+GST_API
+GstCaps *         gst_caps_intersect               (GstCaps *caps1,
+                                                   GstCaps *caps2) G_GNUC_WARN_UNUSED_RESULT;
+GST_API
+GstCaps *         gst_caps_intersect_full          (GstCaps *caps1,
+                                                   GstCaps *caps2,
+                                                    GstCapsIntersectMode mode) G_GNUC_WARN_UNUSED_RESULT;
+GST_API
+GstCaps *         gst_caps_subtract               (GstCaps *minuend,
+                                                   GstCaps *subtrahend) G_GNUC_WARN_UNUSED_RESULT;
+GST_API
+GstCaps *         gst_caps_normalize               (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT;
+
+GST_API
+GstCaps *         gst_caps_simplify                (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT;
+
+GST_API
+GstCaps *         gst_caps_fixate                  (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT;
 
 /* utility */
-gchar *           gst_caps_to_string               (const GstCaps *caps);
-GstCaps *         gst_caps_from_string             (const gchar   *string);
+
+GST_API
+gchar *           gst_caps_to_string               (const GstCaps *caps) G_GNUC_MALLOC;
+
+GST_API
+GstCaps *         gst_caps_from_string             (const gchar   *string) G_GNUC_WARN_UNUSED_RESULT;
+
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstCaps, gst_caps_unref)
+#endif
 
 G_END_DECLS