- implement FLOATING flag on caps/props
[platform/upstream/gstreamer.git] / gst / gstcaps.h
index cabd478..2168bc9 100644 (file)
@@ -30,28 +30,43 @@ G_BEGIN_DECLS
 
 typedef struct _GstCaps GstCaps;
 
+#define        GST_CAPS_TRACE_NAME "GstCaps"
+
 extern GType _gst_caps_type;
 
 #define GST_TYPE_CAPS  (_gst_caps_type)
 
+typedef enum {
+  GST_CAPS_FIXED       = (1 << 0),     /* caps has no variable properties */
+  GST_CAPS_FLOATING    = (1 << 1)      /* caps is floating */
+} GstCapsFlags;
 
 #define GST_CAPS(caps)         ((GstCaps *)(caps))
 
-#define GST_CAPS_IS_FIXED(caps)                ((caps)->fixed)
-#define GST_CAPS_IS_CHAINED(caps)      ((caps)->next)
+#define GST_CAPS_FLAGS(caps)           ((caps)->flags)
+#define GST_CAPS_FLAG_IS_SET(caps,flag)        (GST_CAPS_FLAGS (caps) & flag)
+#define GST_CAPS_FLAG_SET(caps,flag)   (GST_CAPS_FLAGS (caps) |= (flag))
+#define GST_CAPS_FLAG_UNSET(caps,flag) (GST_CAPS_FLAGS (caps) &= ~(flag))
+
+#define GST_CAPS_REFCOUNT(caps)                ((caps)->refcount)
+#define GST_CAPS_PROPERTIES(caps)      ((caps)->properties)
+#define GST_CAPS_NEXT(caps)            ((caps)->next)
+
+#define GST_CAPS_IS_FIXED(caps)                (GST_CAPS_FLAGS (caps) & GST_CAPS_FIXED)
+#define GST_CAPS_IS_FLOATING(caps)     (GST_CAPS_FLAGS (caps) & GST_CAPS_FLOATING)
+#define GST_CAPS_IS_CHAINED(caps)      (GST_CAPS_NEXT (caps) != NULL)
 
-/* CR1: id is an int corresponding to the quark for the mime type because
- * it's really fast when doing a first-pass check for caps compatibility */
 struct _GstCaps {
+  /* --- public --- */
   gchar        *name;                  /* the name of this caps */
-  guint16      id;                     /* type id (major type) representing 
-                                          the mime type */
+  guint16       id;                    /* type id (major type) representing 
+                                          the mime type, it's stored as a GQuark 
+                                          for speed/space reasons */
 
-  guint        refcount;               
-  gboolean     fixed;                  /* this caps doesn't contain variable properties */
+  guint16       flags;                 /* flags */
+  guint         refcount;              
 
   GstProps     *properties;            /* properties for this capability */
-
   GstCaps      *next;                  /* not with a GList for efficiency */
 };
 
@@ -97,21 +112,30 @@ factoryname (void)                              \
 }
 #endif
 
+/* get caps from a factory */
 #define GST_CAPS_GET(fact) (fact)()
 
 
 /* initialize the subsystem */
 void           _gst_caps_initialize                    (void);
 
+/* creating new caps */
 GstCaps*       gst_caps_new                            (const gchar *name, const gchar *mime, GstProps *props);
 GstCaps*       gst_caps_new_id                         (const gchar *name, const guint16 id, GstProps *props);
+/* replace pointer to caps, doing proper refcounting */
+void           gst_caps_replace                        (GstCaps **oldcaps, GstCaps *newcaps);
+void           gst_caps_replace_sink                   (GstCaps **oldcaps, GstCaps *newcaps);
 
+/* caps lifecycle control */
 GstCaps*       gst_caps_unref                          (GstCaps *caps);
 GstCaps*       gst_caps_ref                            (GstCaps *caps);
+void           gst_caps_sink                           (GstCaps *caps);
 void           gst_caps_destroy                        (GstCaps *caps);
 
+/* write debug lines to the log */
 void           gst_caps_debug                          (GstCaps *caps, const gchar *label);
 
+/* copy caps */
 GstCaps*       gst_caps_copy                           (GstCaps *caps);
 GstCaps*       gst_caps_copy_1                         (GstCaps *caps);
 GstCaps*       gst_caps_copy_on_write                  (GstCaps *caps);
@@ -148,12 +172,18 @@ GstProps* gst_caps_get_props                      (GstCaps *caps);
 
 GstCaps*       gst_caps_get_by_name                    (GstCaps *caps, const gchar *name);
 
+/* use and construct chained caps */
+GstCaps*       gst_caps_next                           (GstCaps *caps); 
 GstCaps*       gst_caps_chain                          (GstCaps *caps, ...); 
 GstCaps*       gst_caps_append                         (GstCaps *caps, GstCaps *capstoadd); 
 GstCaps*       gst_caps_prepend                        (GstCaps *caps, GstCaps *capstoadd); 
 
+/* see if fromcaps is a subset of tocaps */
 gboolean       gst_caps_is_always_compatible           (GstCaps *fromcaps, GstCaps *tocaps);
+
+/* operations on caps */
 GstCaps*       gst_caps_intersect                      (GstCaps *caps1, GstCaps *caps2);
+GstCaps*       gst_caps_union                          (GstCaps *caps1, GstCaps *caps2);
 GstCaps*       gst_caps_normalize                      (GstCaps *caps);
 
 #ifndef GST_DISABLE_LOADSAVE