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 * @factory: the factory to register
52 * Register the factory.
54 * Returns: The registered capability
57 gst_caps_register (GstCapsFactory factory)
59 GstCapsFactoryEntry tag;
64 g_return_val_if_fail (factory != NULL, NULL);
68 g_return_val_if_fail (tag != NULL, NULL);
70 typeid = get_type_for_mime ((gchar *)tag);
72 caps = g_new0 (GstCaps, 1);
73 g_return_val_if_fail (caps != NULL, NULL);
76 caps->properties = gst_props_register (&factory[i]);
83 * gst_caps_check_compatibility:
84 * @fromcaps: a capabilty
85 * @tocaps: a capabilty
87 * Checks whether two capabilities are compatible
89 * Returns: true if compatible, false otherwise
92 gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps)
94 g_return_val_if_fail (fromcaps != NULL, FALSE);
95 g_return_val_if_fail (tocaps != NULL, FALSE);
97 if (fromcaps->id != tocaps->id)
100 return gst_props_check_compatibility (fromcaps->properties, tocaps->properties);
105 gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent)
109 g_return_val_if_fail (caps != NULL, NULL);
111 xmlNewChild (parent, NULL, "type", gst_type_find_by_id (caps->id)->mime);
112 if (caps->properties) {
113 subtree = xmlNewChild (parent, NULL, "properties", NULL);
115 gst_props_save_thyself (caps->properties, subtree);
122 gst_caps_load_thyself (xmlNodePtr parent)
124 GstCaps *caps = g_new0 (GstCaps, 1);
125 xmlNodePtr field = parent->childs;
128 if (!strcmp (field->name, "type")) {
129 caps->id = get_type_for_mime (xmlNodeGetContent (field));
131 else if (!strcmp (field->name, "properties")) {
132 caps->properties = gst_props_load_thyself (field);