Added 1337 macros to create padtemplates and capstemplates.
[platform/upstream/gstreamer.git] / gst / gstcaps.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstcaps.h: Header for caps subsystem
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23
24 #ifndef __GST_CAPS_H__
25 #define __GST_CAPS_H__
26
27 #include <parser.h> // NOTE: this is xml-config's fault
28
29 // Include compatability defines: if libxml hasn't already defined these,
30 // we have an old version 1.x
31 #ifndef xmlChildrenNode
32 #define xmlChildrenNode childs
33 #define xmlRootNode root
34 #endif
35
36 #include <gst/gstprops.h>
37
38 typedef struct _GstCaps GstCaps;
39
40 #define GST_CAPS(caps) \
41   ((GstCaps *)(caps))
42
43 #define GST_CAPS_LOCK(caps)    (g_mutex_lock(GST_CAPS(caps)->lock))
44 #define GST_CAPS_TRYLOCK(caps) (g_mutex_trylock(GST_CAPS(caps)->lock))
45 #define GST_CAPS_UNLOCK(caps)  (g_mutex_unlock(GST_CAPS(caps)->lock))
46
47 struct _GstCaps {
48   gchar *name;                  /* the name of this caps */
49   guint16 id;                   /* type id (major type) */
50
51   guint refcount;               
52   GMutex *lock;                 /* global lock for this capability */
53
54   GstProps *properties;         /* properties for this capability */
55
56   GstCaps *next;
57 };
58
59 #define GST_CAPS_NEW(name, type, a...)          \
60 gst_caps_new (                                  \
61   name,                                         \
62   type,                                         \
63   gst_props_new (                               \
64     ##a,                                        \
65     NULL))
66
67 #define GST_CAPS_FACTORY(factoryname, a...)     \
68 static GstCaps*                                 \
69 factoryname (void)                              \
70 {                                               \
71   static GstCaps *caps = NULL;                  \
72   if (!caps) {                                  \
73     caps = gst_caps_chain (##a, NULL);          \
74   }                                             \
75   return caps;                                  \
76 }
77
78 #define GST_CAPS_GET(fact) (fact)()
79
80
81 /* initialize the subsystem */
82 void            _gst_caps_initialize                    (void);
83
84 GstCaps*        gst_caps_new                            (const gchar *name, const gchar *mime, GstProps *props);
85
86 GstCaps*        gst_caps_unref                          (GstCaps *caps);
87 GstCaps*        gst_caps_ref                            (GstCaps *caps);
88 void            gst_caps_destroy                        (GstCaps *caps);
89
90 GstCaps*        gst_caps_copy                           (GstCaps *caps);
91 GstCaps*        gst_caps_copy_on_write                  (GstCaps *caps);
92
93 const gchar*    gst_caps_get_name                       (GstCaps *caps);
94 void            gst_caps_set_name                       (GstCaps *caps, const gchar *name);
95
96 const gchar*    gst_caps_get_mime                       (GstCaps *caps);
97 void            gst_caps_set_mime                       (GstCaps *caps, const gchar *mime);
98
99 guint16         gst_caps_get_type_id                    (GstCaps *caps);
100 void            gst_caps_set_type_id                    (GstCaps *caps, guint16 type_id);
101
102 GstCaps*        gst_caps_set_props                      (GstCaps *caps, GstProps *props);
103 GstProps*       gst_caps_get_props                      (GstCaps *caps);
104
105 #define         gst_caps_set(caps, name, args...)       gst_props_set ((caps)->properties, name, args)
106
107 #define         gst_caps_get_int(caps, name)            gst_props_get_int ((caps)->properties, name)
108 #define         gst_caps_get_fourcc_int(caps, name)     gst_props_get_fourcc_int ((caps)->properties, name)
109 #define         gst_caps_get_boolean(caps, name)        gst_props_get_boolean ((caps)->properties, name)
110 #define         gst_caps_get_string(caps, name)         gst_props_get_string ((caps)->properties, name)
111
112 GstCaps*        gst_caps_get_by_name                    (GstCaps *caps, const gchar *name);
113
114 GstCaps*        gst_caps_chain                          (GstCaps *caps, ...); 
115 GstCaps*        gst_caps_append                         (GstCaps *caps, GstCaps *capstoadd); 
116 GstCaps*        gst_caps_prepend                        (GstCaps *caps, GstCaps *capstoadd); 
117
118 gboolean        gst_caps_check_compatibility            (GstCaps *fromcaps, GstCaps *tocaps);
119
120 xmlNodePtr      gst_caps_save_thyself                   (GstCaps *caps, xmlNodePtr parent);
121 GstCaps*        gst_caps_load_thyself                   (xmlNodePtr parent);
122
123 #endif /* __GST_CAPS_H__ */