- Removed unused locking from the cothreads
[platform/upstream/gstreamer.git] / gst / gsttype.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gsttype.h: Header for type management
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_TYPE_H__
25 #define __GST_TYPE_H__
26
27 #include <gst/gstbuffer.h>
28 #include <gst/gstcaps.h>
29 #include <gst/gstpluginfeature.h>
30
31 G_BEGIN_DECLS
32
33 /* type of function used to check a stream for equality with type */
34 typedef GstCaps *(*GstTypeFindFunc) (GstBuffer *buf, gpointer priv);
35
36 typedef struct _GstType GstType;
37 typedef struct _GstTypeDefinition GstTypeDefinition;
38 typedef struct _GstTypeFactory GstTypeFactory;
39 typedef struct _GstTypeFactoryClass GstTypeFactoryClass;
40
41 struct _GstType {
42   guint16 id;                   /* type id (assigned) */
43
44   gchar *mime;                  /* MIME type */
45   gchar *exts;                  /* space-delimited list of extensions */
46
47   GSList *factories;            /* factories providing this type */
48 };
49
50 struct _GstTypeDefinition {
51   gchar *name;
52   gchar *mime;
53   gchar *exts;
54   GstTypeFindFunc typefindfunc;
55 };
56
57 #define GST_TYPE_TYPE_FACTORY \
58   (gst_type_factory_get_type())
59 #define GST_TYPE_FACTORY(obj) \
60   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TYPE_FACTORY,GstTypeFactory))
61 #define GST_TYPE_FACTORY_CLASS(klass) \
62   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TYPE_FACTORY,GstTypeFactoryClass))
63 #define GST_IS_TYPE_FACTORY(obj) \
64   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TYPE_FACTORY))
65 #define GST_IS_TYPE_FACTORY_CLASS(klass) \
66   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TYPE_FACTORY))
67
68 struct _GstTypeFactory {
69   GstPluginFeature feature;
70
71   gchar *mime;
72   gchar *exts;
73   GstTypeFindFunc typefindfunc;
74 };
75
76 struct _GstTypeFactoryClass {
77   GstPluginFeatureClass parent;
78 };
79
80
81 GType                   gst_type_factory_get_type       (void);
82
83 GstTypeFactory*         gst_type_factory_new            (GstTypeDefinition *definition);
84
85 GstTypeFactory*         gst_type_factory_find           (const gchar *name);
86
87
88 /* create a new type, or find/merge an existing one */
89 guint16                 gst_type_register               (GstTypeFactory *factory);
90
91 /* look up a type by mime or extension */
92 guint16                 gst_type_find_by_mime           (const gchar *mime);
93 guint16                 gst_type_find_by_ext            (const gchar *ext);
94
95 /* get GstType by id */
96 GstType*                gst_type_find_by_id             (guint16 id);
97
98 /* get the list of registered types (returns list of GstType!) */
99 const GList*            gst_type_get_list               (void);
100
101 G_END_DECLS
102
103 #endif /* __GST_TYPE_H__ */