diff options
author | Thomas Vander Stichele <thomas (at) apestaart (dot) org> | 2009-06-01 22:02:47 +0200 |
---|---|---|
committer | Thomas Vander Stichele <thomas (at) apestaart (dot) org> | 2009-06-01 22:02:47 +0200 |
commit | 26fa6dd184a8d6d103eaddf5f12bd7e5144413fb (patch) | |
tree | fefbf938926ac36dbbb7f69be7f45d1deb8a41bd /gst | |
parent | 88f3323bfe15ae6aee762ba64588980b6036d4ea (diff) |
wrap gst_tag_to_vorbis_comment; fix uint tag setting
Setting gst.TAG_TRACK_NUMBER was failing because GStreamer
expects a uint while Python object -> GValue conversion was
giving an int. gst_tag_to_vorbis_comment was wrapped so
this conversion could be tested and failed on properly.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/gsttaglist.override | 18 | ||||
-rw-r--r-- | gst/tag.override | 40 |
2 files changed, 58 insertions, 0 deletions
diff --git a/gst/gsttaglist.override b/gst/gsttaglist.override index 93c902f..3775232 100644 --- a/gst/gsttaglist.override +++ b/gst/gsttaglist.override @@ -95,15 +95,33 @@ _wrap_gst_tag_list_ass_subscript(PyGObject *self, { const char *key; GstStructure* structure; + GType tagtype; structure = (GstStructure*)self->obj; key = PyString_AsString(py_key); if (py_value != NULL) { GValue v = { 0, }; + if (!pygst_value_init_for_pyobject (&v, py_value)) return -1; if (pygst_value_from_pyobject(&v, py_value)) return -1; + + /* some tags are supposed to be uint, but there is no unsigned + * int python type, so convert here if needed */ + if (gst_tag_exists (key)) { + tagtype = gst_tag_get_type (key); + + if (tagtype && tagtype != G_VALUE_TYPE (&v)) { + GValue w = { 0, }; + + g_value_init (&w, tagtype); + g_value_transform (&v, &w); + g_value_unset (&v); + g_value_init (&v, tagtype); + g_value_copy (&w, &v); + } + } gst_structure_set_value(structure, key, &v); g_value_unset(&v); } else { diff --git a/gst/tag.override b/gst/tag.override index 52ef76b..b908d5b 100644 --- a/gst/tag.override +++ b/gst/tag.override @@ -62,3 +62,43 @@ ignore-glob *init *_free *_get_type + +%% +override gst_tag_to_vorbis_comments +static PyObject * +_wrap_gst_tag_to_vorbis_comments(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *py_taglist; + const GstTagList *taglist; + const gchar *tag; + + const GList *list; + const GList *l; + PyObject *py_list; + + if (!PyArg_ParseTuple(args, "Os", &py_taglist, &tag)) + return NULL; + + if (pyg_boxed_check(py_taglist, GST_TYPE_TAG_LIST)) + taglist = pyg_boxed_get(py_taglist, GstTagList); + else { + PyErr_SetString(PyExc_TypeError, "list should be a GstTagList"); + return NULL; + } + + + pyg_begin_allow_threads; + list = gst_tag_to_vorbis_comments (taglist, tag); + pyg_end_allow_threads; + + py_list = PyList_New(0); + + for (l = list; l; l = l->next) { + gchar *pair = (gchar *)l->data; + PyObject *py_pair = PyString_FromString(pair); + PyList_Append(py_list, py_pair); + Py_DECREF(py_pair); + } + return py_list; + +} |