2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
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.
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.
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.
20 //#define DEBUG_ENABLED
26 _gst_caps_initialize (void)
31 get_type_for_mime (gchar *mime)
35 typeid = gst_type_find_by_mime (mime);
37 GstTypeFactory *factory = g_new0 (GstTypeFactory, 1);
39 factory->mime = g_strdup (mime);
41 factory->typefindfunc = NULL;
43 typeid = gst_type_register (factory);
50 * @mime: the mime type to attach to the capability
52 * create a new capability with the given mime type
54 * Returns: a new capability
57 gst_caps_new (gchar *mime)
61 g_return_val_if_fail (mime != NULL, NULL);
63 caps = g_new0 (GstCaps, 1);
64 caps->id = get_type_for_mime (mime);
71 * @factory: the factory to register
73 * Register the factory.
75 * Returns: The registered capability
78 gst_caps_register (GstCapsFactory *factory)
80 GstCapsFactoryEntry tag;
85 g_return_val_if_fail (factory != NULL, NULL);
87 tag = (*factory)[i++];
89 g_return_val_if_fail (tag != NULL, NULL);
91 typeid = get_type_for_mime ((gchar *)tag);
93 caps = g_new0 (GstCaps, 1);
94 g_return_val_if_fail (caps != NULL, NULL);
97 caps->properties = gst_props_register (&(*factory)[i]);
104 * gst_caps_check_compatibility:
105 * @fromcaps: a capabilty
106 * @tocaps: a capabilty
108 * Checks whether two capabilities are compatible
110 * Returns: true if compatible, false otherwise
113 gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps)
115 g_return_val_if_fail (fromcaps != NULL, FALSE);
116 g_return_val_if_fail (tocaps != NULL, FALSE);
118 if (fromcaps->id != tocaps->id)
121 return gst_props_check_compatibility (fromcaps->properties, tocaps->properties);
126 gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent)
130 g_return_val_if_fail (caps != NULL, NULL);
132 xmlNewChild (parent, NULL, "type", gst_type_find_by_id (caps->id)->mime);
133 if (caps->properties) {
134 subtree = xmlNewChild (parent, NULL, "properties", NULL);
136 gst_props_save_thyself (caps->properties, subtree);
143 gst_caps_load_thyself (xmlNodePtr parent)
145 GstCaps *caps = g_new0 (GstCaps, 1);
146 xmlNodePtr field = parent->childs;
149 if (!strcmp (field->name, "type")) {
150 caps->id = get_type_for_mime (xmlNodeGetContent (field));
152 else if (!strcmp (field->name, "properties")) {
153 caps->properties = gst_props_load_thyself (field);