separated the properties from the capabilities as we might use the properties for...
[platform/upstream/gstreamer.git] / gst / gstcaps.c
1 /* Gnome-Streamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 //#define DEBUG_ENABLED
21
22 #include <stdarg.h>
23 #include <gst/gst.h>
24
25 void 
26 _gst_caps_initialize (void) 
27 {
28 }
29 /**
30  * gst_caps_register:
31  * @factory: the factory to register
32  *
33  * Register the factory. 
34  *
35  * Returns: The registered capability
36  */
37 GstCaps *
38 gst_caps_register (GstCapsFactory factory)
39 {
40   GstCapsFactoryEntry tag;
41   gint i = 0;
42   guint16 typeid;
43   GstCaps *caps;
44   
45   g_return_val_if_fail (factory != NULL, NULL);
46
47   tag = factory[i++];
48
49   g_return_val_if_fail (tag != NULL, NULL);
50   
51   typeid = gst_type_find_by_mime ((gchar *)tag);
52   if (typeid == 0) {
53      GstTypeFactory *factory = g_new0 (GstTypeFactory, 1);
54
55      factory->mime = g_strdup ((gchar *)tag);
56      factory->exts = NULL;
57      factory->typefindfunc = NULL;
58
59      typeid = gst_type_register (factory);
60   }
61
62   caps = g_new0 (GstCaps, 1);
63   g_return_val_if_fail (caps != NULL, NULL);
64
65   caps->id = typeid;
66   caps->properties = gst_props_register (&factory[i]);
67
68   return caps;
69 }
70
71
72 /**
73  * gst_caps_dump:
74  * @caps: the capability to dump
75  *
76  * Dumps the contents of the capabilty one the console
77  */
78 void
79 gst_caps_dump (GstCaps *caps)
80 {
81   g_return_if_fail (caps != NULL);
82
83   g_print("gstcaps: {\ngstcaps:  mime type \"%d\"\n", caps->id);
84
85   gst_props_dump (caps->properties);
86
87   g_print("gstcaps: }\n");
88 }
89         
90
91 /**
92  * gst_caps_check_compatibility:
93  * @fromcaps: a capabilty
94  * @tocaps: a capabilty
95  *
96  * Checks whether two capabilities are compatible
97  *
98  * Returns: true if compatible, false otherwise
99  */
100 gboolean
101 gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps)
102 {
103   g_return_val_if_fail (fromcaps != NULL, FALSE);
104   g_return_val_if_fail (tocaps != NULL, FALSE);
105         
106   if (fromcaps->id != tocaps->id)
107     return FALSE;
108
109   return gst_props_check_compatibility (fromcaps->properties, tocaps->properties);
110 }
111