ce5a6d9cc7585cbbb558968704107741ee4aa6b4
[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.2")
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   guint32 crc32;
74 } GstBinaryRegistryMagic;
75
76 /*
77  * we reference strings directly from the plugins and in this case set CONST to
78  * avoid freeing them
79  */
80 enum {
81   GST_BINARY_REGISTRY_FLAG_NONE = 0,
82   GST_BINARY_REGISTRY_FLAG_CONST = 1
83 };
84
85 /*
86  * GstBinaryChunk:
87  *
88  * Header for binary blobs
89  */
90 typedef struct _GstBinaryChunk
91 {
92   gpointer data;
93   guint size;
94   guint flags;
95   gboolean align;
96 } GstBinaryChunk;
97
98 /*
99  * GstBinaryPluginElement:
100  *
101  * @nfeatures: says how many binary plugin feature structures we will have
102  * right after the structure itself.
103  *
104  * A structure containing (staticely) every information needed for a plugin
105  */
106
107 typedef struct _GstBinaryPluginElement
108 {
109   gulong file_size;
110   gulong file_mtime;
111
112   guint nfeatures;
113 } GstBinaryPluginElement;
114
115
116 /*
117  * GstBinaryPluginFeature:
118  * @rank: rank of the feature
119  *
120  * A structure containing the plugin features
121  */
122 typedef struct _GstBinaryPluginFeature
123 {
124   gulong rank;
125 } GstBinaryPluginFeature;
126
127 /*
128  * GstBinaryElementFactory:
129  * @npadtemplates: stores the number of GstBinaryPadTemplate structures
130  * following the structure
131  * @ninterfaces: stores the number of interface names following the structure
132  * @nuriprotocols: stores the number of protocol strings following the structure
133  *
134  * A structure containing the element factory fields
135  */
136 typedef struct _GstBinaryElementFactory
137 {
138   GstBinaryPluginFeature plugin_feature;
139
140   guint npadtemplates;
141   guint ninterfaces;
142   guint nuriprotocols;
143 } GstBinaryElementFactory;
144
145 /*
146  * GstBinaryTypeFindFactory:
147  * @nextensions: stores the number of typefind extensions
148  *
149  * A structure containing the element factory fields
150  */
151 typedef struct _GstBinaryTypeFindFactory
152 {
153   GstBinaryPluginFeature plugin_feature;
154
155   guint nextensions;
156 } GstBinaryTypeFindFactory;
157
158 /*
159  * GstBinaryPadTemplate:
160  *
161  * A structure containing the static pad templates of a plugin feature
162  */
163 typedef struct _GstBinaryPadTemplate
164 {
165   guint direction;                     /* Either 0:"sink" or 1:"src" */
166   GstPadPresence presence;
167 } GstBinaryPadTemplate;
168
169
170 /* Function prototypes */
171 gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
172 gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
173
174 #endif /* !__GST_REGISTRYBINARY_H__ */
175