8193f7c03bfc8bebd9ef0c40f669f1a358cc5e56
[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 #ifdef HAVE_CONFIG_H
37 #include "config.h"
38 #endif
39
40 /*
41  * GST_MAGIC_BINARY_REGISTRY_STR:
42  *
43  * A tag, written at the beginning of the file
44  */
45 #define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
46 /*
47  * GST_MAGIC_BINARY_REGISTRY_LEN:
48  *
49  * length of the header tag.
50  */
51 #define GST_MAGIC_BINARY_REGISTRY_LEN (4)
52
53 /*
54  * GST_MAGIC_BINARY_VERSION_STR:
55  *
56  * The current version of the binary registry format.
57  * This _must_ be updated whenever the registry format changes,
58  * we currently use the core version where this change happened.
59  */
60 #define GST_MAGIC_BINARY_VERSION_STR ("0.10.18.1")
61
62 /*
63  * GST_MAGIC_BINARY_VERSION_LEN:
64  *
65  * length of the version string.
66  */
67 #define GST_MAGIC_BINARY_VERSION_LEN (64)
68
69 typedef struct _GstBinaryRegistryMagic
70 {
71   gchar magic[GST_MAGIC_BINARY_REGISTRY_LEN];
72   gchar version[GST_MAGIC_BINARY_VERSION_LEN];
73 } GstBinaryRegistryMagic;
74
75 /*
76  * we reference strings directly from the plugins and in this case set CONST to
77  * avoid freeing them
78  */
79 enum {
80   GST_BINARY_REGISTRY_FLAG_NONE = 0,
81   GST_BINARY_REGISTRY_FLAG_CONST = 1
82 };
83
84 /*
85  * GstBinaryChunk:
86  *
87  * Header for binary blobs
88  */
89 typedef struct _GstBinaryChunk
90 {
91   gpointer data;
92   guint size;
93   guint flags;
94   gboolean align;
95 } GstBinaryChunk;
96
97 /*
98  * GstBinaryPluginElement:
99  *
100  * @nfeatures: says how many binary plugin feature structures we will have
101  * right after the structure itself.
102  *
103  * A structure containing (staticely) every information needed for a plugin
104  */
105
106 typedef struct _GstBinaryPluginElement
107 {
108   gulong file_size;
109   gulong file_mtime;
110
111   guint nfeatures;
112 } GstBinaryPluginElement;
113
114
115 /*
116  * GstBinaryPluginFeature:
117  * @rank: rank of the feature
118  *
119  * A structure containing the plugin features
120  */
121 typedef struct _GstBinaryPluginFeature
122 {
123   gulong rank;
124 } GstBinaryPluginFeature;
125
126 /*
127  * GstBinaryElementFactory:
128  * @npadtemplates: stores the number of GstBinaryPadTemplate structures
129  * following the structure
130  * @ninterfaces: stores the number of interface names following the structure
131  * @nuriprotocols: stores the number of protocol strings following the structure
132  *
133  * A structure containing the element factory fields
134  */
135 typedef struct _GstBinaryElementFactory
136 {
137   GstBinaryPluginFeature plugin_feature;
138
139   guint npadtemplates;
140   guint ninterfaces;
141   guint nuriprotocols;
142 } GstBinaryElementFactory;
143
144 /*
145  * GstBinaryTypeFindFactory:
146  * @nextensions: stores the number of typefind extensions
147  *
148  * A structure containing the element factory fields
149  */
150 typedef struct _GstBinaryTypeFindFactory
151 {
152   GstBinaryPluginFeature plugin_feature;
153
154   guint nextensions;
155 } GstBinaryTypeFindFactory;
156
157 /*
158  * GstBinaryPadTemplate:
159  *
160  * A structure containing the static pad templates of a plugin feature
161  */
162 typedef struct _GstBinaryPadTemplate
163 {
164   guint direction;                     /* Either 0:"sink" or 1:"src" */
165   GstPadPresence presence;
166 } GstBinaryPadTemplate;
167
168
169 /* Function prototypes */
170 gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
171 gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
172
173 #endif /* !__GST_REGISTRYBINARY_H__ */
174