18e150cecd4ca9ef1c4a4d031f600b277adc600e
[platform/upstream/gstreamer.git] / gst / gstregistrybinary.h
1 /* GStreamer
2  * Copyright (C) 2006 Josep Torra <josep@fluendo.com>
3  * Copyright (C) 2006 Mathieu Garcia  <matthieu@fluendo.com>
4  * Copyright (C) 2006 Stefan Kost <ensonic@sonicpulse.de>
5  *
6  * gstregistrybinary.h: Header for registry handling
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 /* SUGGESTIONS AND TODO :
25 ** ====================
26 ** - Use a compressed registry, but would induce performance loss
27 ** - Encrypt the registry, for security purpose, but would also reduce performances
28 */
29
30 #ifndef __GST_REGISTRYBINARY_H__
31 #define __GST_REGISTRYBINARY_H__
32
33 #include <gst/gstpad.h>
34 #include <gst/gstregistry.h>
35
36 /*
37  * GST_MAGIC_BINARY_REGISTRY_STR:
38  *
39  * A tag, written at the beginning of the file
40  */
41 #define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
42 /*
43  * GST_MAGIC_BINARY_REGISTRY_LEN:
44  *
45  * length of the header tag.
46  */
47 #define GST_MAGIC_BINARY_REGISTRY_LEN (4)
48
49 /*
50  * GST_MAGIC_BINARY_VERSION_STR:
51  *
52  * The current version of the binary registry format.
53  * This _must_ be updated whenever the registry format changes,
54  * we currently use the core version where this change happened.
55  */
56 #define GST_MAGIC_BINARY_VERSION_STR ("0.10.23.1")
57
58 /*
59  * GST_MAGIC_BINARY_VERSION_LEN:
60  *
61  * length of the version string.
62  */
63 #define GST_MAGIC_BINARY_VERSION_LEN (64)
64
65 typedef struct _GstBinaryRegistryMagic
66 {
67   gchar magic[GST_MAGIC_BINARY_REGISTRY_LEN];
68   gchar version[GST_MAGIC_BINARY_VERSION_LEN];
69 } GstBinaryRegistryMagic;
70
71 /*
72  * we reference strings directly from the plugins and in this case set CONST to
73  * avoid freeing them
74  */
75 enum {
76   GST_BINARY_REGISTRY_FLAG_NONE = 0,
77   GST_BINARY_REGISTRY_FLAG_CONST = 1
78 };
79
80 /*
81  * GstBinaryChunk:
82  *
83  * Header for binary blobs
84  */
85 typedef struct _GstBinaryChunk
86 {
87   gpointer data;
88   guint size;
89   guint flags;
90   gboolean align;
91 } GstBinaryChunk;
92
93 /*
94  * GstBinaryPluginElement:
95  *
96  * @nfeatures: says how many binary plugin feature structures we will have
97  * right after the structure itself.
98  *
99  * A structure containing (staticely) every information needed for a plugin
100  */
101
102 typedef struct _GstBinaryPluginElement
103 {
104   gulong file_size;
105   gulong file_mtime;
106
107   guint n_deps;
108
109   guint nfeatures;
110 } GstBinaryPluginElement;
111
112 /* GstBinaryDep:
113  */
114 typedef struct _GstBinaryDep
115 {
116   guint flags;
117   guint n_env_vars;
118   guint n_paths;
119   guint n_names;
120
121   guint env_hash;
122   guint stat_hash;
123 } GstBinaryDep;
124
125 /*
126  * GstBinaryPluginFeature:
127  * @rank: rank of the feature
128  *
129  * A structure containing the plugin features
130  */
131 typedef struct _GstBinaryPluginFeature
132 {
133   gulong rank;
134 } GstBinaryPluginFeature;
135
136 /*
137  * GstBinaryElementFactory:
138  * @npadtemplates: stores the number of GstBinaryPadTemplate structures
139  * following the structure
140  * @ninterfaces: stores the number of interface names following the structure
141  * @nuriprotocols: stores the number of protocol strings following the structure
142  *
143  * A structure containing the element factory fields
144  */
145 typedef struct _GstBinaryElementFactory
146 {
147   GstBinaryPluginFeature plugin_feature;
148
149   guint npadtemplates;
150   guint ninterfaces;
151   guint nuriprotocols;
152 } GstBinaryElementFactory;
153
154 /*
155  * GstBinaryTypeFindFactory:
156  * @nextensions: stores the number of typefind extensions
157  *
158  * A structure containing the element factory fields
159  */
160 typedef struct _GstBinaryTypeFindFactory
161 {
162   GstBinaryPluginFeature plugin_feature;
163
164   guint nextensions;
165 } GstBinaryTypeFindFactory;
166
167 /*
168  * GstBinaryPadTemplate:
169  *
170  * A structure containing the static pad templates of a plugin feature
171  */
172 typedef struct _GstBinaryPadTemplate
173 {
174   guint direction;                     /* Either 0:"sink" or 1:"src" */
175   GstPadPresence presence;
176 } GstBinaryPadTemplate;
177
178
179 /* Function prototypes */
180 gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
181 gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
182
183 #endif /* !__GST_REGISTRYBINARY_H__ */
184