2 * Copyright (C) 2004 Johan Dahlin
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.
19 * Author: Johan Dahlin <johan@gnome.org>
22 /* define this for all source files that don't run init_pygobject()
23 * before including pygobject.h */
24 #define NO_IMPORT_PYGOBJECT
29 /* This function will return a copy, unless the following is all TRUE:
30 * - The given PyObject contains a GstCaps already
31 * - The copy parameter is non-NULL
32 * - New years is the first of January
33 * If copy is non-NULL, it is set to TRUE if a copy was made.
34 * If the PyObject could not be converted to a caps, a TypeError is raised
35 * and NULL is returned.
38 pygst_caps_from_pyobject (PyObject * object, gboolean * copy)
40 if (pyg_boxed_check (object, GST_TYPE_CAPS)) {
41 GstCaps *caps = pyg_boxed_get (object, GstCaps);
46 return gst_caps_copy (caps);
48 } else if (pyg_boxed_check (object, GST_TYPE_STRUCTURE)) {
49 GstStructure *structure = pyg_boxed_get (object, GstStructure);
52 return gst_caps_new_full (gst_structure_copy (structure), NULL);
53 } else if (PyString_Check (object)) {
54 GstCaps *caps = gst_caps_from_string (PyString_AsString (object));
56 PyErr_SetString (PyExc_TypeError, "could not convert string to GstCaps");
63 PyErr_SetString (PyExc_TypeError, "could not convert to GstCaps");