summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2005-11-10 12:48:49 +0000
committerEdward Hervey <bilboed@bilboed.com>2005-11-10 12:48:49 +0000
commite3beb3ed78d191c78399503b8462d1acc9140b28 (patch)
treee8e8f59bc379be4dc6d00ae1294bf3a20bf4e827
parent0ca0d997810cf3560db37f1ebd7ea269b29af815 (diff)
gst/gstmodule.c: Added GST_TAG_* string constants
Original commit message from CVS: * gst/gstmodule.c: (init_gst): Added GST_TAG_* string constants * gst/gstpad.override: Make probe handler return TRUE if the Python callback doesn't return anything. * gst/gsttaglist.override: Cleaned up gst.TagList, works as a dictionnary.
-rw-r--r--ChangeLog10
-rw-r--r--gst/gstmodule.c37
-rw-r--r--gst/gstpad.override2
-rw-r--r--gst/gsttaglist.override237
4 files changed, 81 insertions, 205 deletions
diff --git a/ChangeLog b/ChangeLog
index 281cd8c..13cb73d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-11-10 Edward Hervey <edward@fluendo.com>
+
+ * gst/gstmodule.c: (init_gst):
+ Added GST_TAG_* string constants
+ * gst/gstpad.override:
+ Make probe handler return TRUE if the Python callback doesn't return
+ anything.
+ * gst/gsttaglist.override:
+ Cleaned up gst.TagList, works as a dictionnary.
+
2005-11-08 Edward Hervey <edward@fluendo.com>
* gst/gst.defs:
diff --git a/gst/gstmodule.c b/gst/gstmodule.c
index 2333d57..e0737d1 100644
--- a/gst/gstmodule.c
+++ b/gst/gstmodule.c
@@ -205,6 +205,43 @@ init_gst (void)
PyModule_AddObject (m, "TYPE_TYPE_FIND_FACTORY",
pyg_type_wrapper_new(GST_TYPE_TYPE_FIND_FACTORY));
+ /* GStreamer core tags */
+ PyModule_AddStringConstant (m, "TAG_TITLE", GST_TAG_TITLE);
+ PyModule_AddStringConstant (m, "TAG_ARTIST", GST_TAG_ARTIST);
+ PyModule_AddStringConstant (m, "TAG_ALBUM", GST_TAG_ALBUM);
+ PyModule_AddStringConstant (m, "TAG_DATE", GST_TAG_DATE);
+ PyModule_AddStringConstant (m, "TAG_GENRE", GST_TAG_GENRE);
+ PyModule_AddStringConstant (m, "TAG_COMMENT", GST_TAG_COMMENT);
+ PyModule_AddStringConstant (m, "TAG_TRACK_NUMBER", GST_TAG_TRACK_NUMBER);
+ PyModule_AddStringConstant (m, "TAG_TRACK_COUNT", GST_TAG_TRACK_COUNT);
+ PyModule_AddStringConstant (m, "TAG_ALBUM_VOLUME_NUMBER", GST_TAG_ALBUM_VOLUME_NUMBER);
+ PyModule_AddStringConstant (m, "TAG_ALBUM_VOLUME_COUNT", GST_TAG_ALBUM_VOLUME_COUNT);
+ PyModule_AddStringConstant (m, "TAG_LOCATION", GST_TAG_LOCATION);
+ PyModule_AddStringConstant (m, "TAG_DESCRIPTION", GST_TAG_DESCRIPTION);
+ PyModule_AddStringConstant (m, "TAG_VERSION", GST_TAG_VERSION);
+ PyModule_AddStringConstant (m, "TAG_ISRC", GST_TAG_ISRC);
+ PyModule_AddStringConstant (m, "TAG_ORGANIZATION", GST_TAG_ORGANIZATION);
+ PyModule_AddStringConstant (m, "TAG_COPYRIGHT", GST_TAG_COPYRIGHT);
+ PyModule_AddStringConstant (m, "TAG_CONTACT", GST_TAG_CONTACT);
+ PyModule_AddStringConstant (m, "TAG_LICENSE", GST_TAG_LICENSE);
+ PyModule_AddStringConstant (m, "TAG_PERFORMER", GST_TAG_PERFORMER);
+ PyModule_AddStringConstant (m, "TAG_DURATION", GST_TAG_DURATION);
+ PyModule_AddStringConstant (m, "TAG_CODEC", GST_TAG_CODEC);
+ PyModule_AddStringConstant (m, "TAG_VIDEO_CODEC", GST_TAG_VIDEO_CODEC);
+ PyModule_AddStringConstant (m, "TAG_AUDIO_CODEC", GST_TAG_AUDIO_CODEC);
+ PyModule_AddStringConstant (m, "TAG_BITRATE", GST_TAG_BITRATE);
+ PyModule_AddStringConstant (m, "TAG_NOMINAL_BITRATE", GST_TAG_NOMINAL_BITRATE);
+ PyModule_AddStringConstant (m, "TAG_MINIMUM_BITRATE", GST_TAG_MINIMUM_BITRATE);
+ PyModule_AddStringConstant (m, "TAG_MAXIMUM_BITRATE", GST_TAG_MAXIMUM_BITRATE);
+ PyModule_AddStringConstant (m, "TAG_SERIAL", GST_TAG_SERIAL);
+ PyModule_AddStringConstant (m, "TAG_ENCODER", GST_TAG_ENCODER);
+ PyModule_AddStringConstant (m, "TAG_ENCODER_VERSION", GST_TAG_ENCODER_VERSION);
+ PyModule_AddStringConstant (m, "TAG_TRACK_GAIN", GST_TAG_TRACK_GAIN);
+ PyModule_AddStringConstant (m, "TAG_TRACK_PEAK", GST_TAG_TRACK_PEAK);
+ PyModule_AddStringConstant (m, "TAG_ALBUM_GAIN", GST_TAG_ALBUM_GAIN);
+ PyModule_AddStringConstant (m, "TAG_ALBUM_PEAK", GST_TAG_ALBUM_PEAK);
+ PyModule_AddStringConstant (m, "TAG_LANGUAGE_CODE", GST_TAG_LANGUAGE_CODE);
+
g_timeout_add_full (0, 100, python_do_pending_calls, NULL, NULL);
atexit(gst_deinit);
diff --git a/gst/gstpad.override b/gst/gstpad.override
index 426a899..f3e8188 100644
--- a/gst/gstpad.override
+++ b/gst/gstpad.override
@@ -147,7 +147,7 @@ probe_handler_marshal(GstPad *pad, GstMiniObject *data, gpointer user_data)
if (!ret) {
PyErr_Print();
- res = FALSE;
+ res = TRUE;
} else {
res = PyObject_IsTrue(ret);
Py_DECREF(ret);
diff --git a/gst/gsttaglist.override b/gst/gsttaglist.override
index 6932328..2c0ca14 100644
--- a/gst/gsttaglist.override
+++ b/gst/gsttaglist.override
@@ -29,61 +29,9 @@ ignore
gst_tag_list_add_values
gst_tag_list_add_valist_values
gst_tag_list_copy_value
-%%
-define GstTagList.keys noargs
-void
-tag_foreach_func_dict (const GstTagList *list,
- const gchar *tag,
- PyObject *dict)
-{
- int count;
- guint i;
- const GValue *gvalue;
- PyObject *value;
- gchar *key;
-
- count = gst_tag_list_get_tag_size(GST_TAG_LIST(list), tag);
-
- for (i = 0; i < count; i++) {
- gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(list), tag, i);
- value = pygst_value_as_pyobject(gvalue, TRUE);
- key = g_strdup (tag);
- PyDict_SetItemString(dict, key, value);
- g_free (key);
- Py_DECREF(value);
- }
-}
-void
-tag_foreach_func_list (const GstTagList *list,
- const gchar *tag,
- PyObject *py_list)
-{
- int count;
-
- count = gst_tag_list_get_tag_size(GST_TAG_LIST(list), tag);
- if (count == 0)
- PyErr_SetString(PyExc_KeyError, tag);
- else if (count == 1)
- PyList_Append(py_list, PyString_FromString(tag));
-#if 0
- else if (count > 1)
- PyErr_SetString(PyExc_TypeError, "lists are currently unspported");
-#endif
-
-}
-
-static PyObject*
-_wrap_gst_tag_list_keys(PyGObject *self)
-{
- PyObject *dict;
-
- dict = PyList_New(0);
-
- gst_tag_list_foreach(GST_TAG_LIST(self->obj),
- (GstTagForeachFunc)tag_foreach_func_list,
- (gpointer)dict);
- return dict;
-}
+ gst_tag_list_get
+ gst_tag_list_remove_tag
+ gst_tag_list_foreach
%%
override-slot GstTagList.tp_as_mapping
static int
@@ -96,17 +44,15 @@ static PyObject *
_wrap_gst_tag_list_subscript(PyGObject *self, PyObject *py_key)
{
PyObject *v = NULL;
- char *key = PyString_AsString(py_key);
+ const char *field = PyString_AsString(py_key);
- int count = gst_tag_list_get_tag_size(GST_TAG_LIST(self->obj), key);
- if (count == 0) {
- PyErr_SetObject(PyExc_KeyError, py_key);
- } else if (count == 1) {
+ if (gst_structure_has_field((GstStructure*)self->obj, field)) {
const GValue *gvalue;
- gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
+ gvalue = gst_structure_get_value((GstStructure*)self->obj, field);
+ g_assert(gvalue != NULL);
v = pygst_value_as_pyobject(gvalue, TRUE);
} else {
- PyErr_SetString(PyExc_TypeError, "lists are currently unspported");
+ PyErr_SetString(PyExc_KeyError, field);
}
if (v != NULL)
@@ -114,150 +60,33 @@ _wrap_gst_tag_list_subscript(PyGObject *self, PyObject *py_key)
return v;
}
-static PySequenceMethods _wrap_gst_tag_list_tp_as_mapping = {
- (inquiry)_wrap_gst_tag_list_length, /* mp_length */
- (binaryfunc)_wrap_gst_tag_list_subscript, /* mp_subscript */
- NULL,
-};
-
-%%
-define GstTagList.has_key args
-static PyObject*
-_wrap_gst_tag_list_has_key(PyGObject *self, PyObject *args)
-{
- gchar *key;
- const GValue *gvalue;
-
- if (!PyArg_ParseTuple(args, "s:GstTagList.has_key", &key))
- return NULL;
-
- gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
-
- return PyInt_FromLong(gvalue != NULL);
-}
-%%
-define GstTagList.get
-static PyObject *
-_wrap_gst_tag_list_get(PyGObject *self, PyObject *args)
-{
- char *key;
- PyObject *failobj = Py_None;
- PyObject *val = NULL;
- const GValue *gvalue;
-
- if (!PyArg_ParseTuple(args, "s|O:GstTagList.get", &key, &failobj))
- return NULL;
-
- gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
- if (gvalue != NULL) {
- int count = gst_tag_list_get_tag_size(GST_TAG_LIST(self->obj), key);
- if (count == 0) {
- PyErr_SetString(PyExc_KeyError, key);
- } else if (count == 1) {
- gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
- val = pygst_value_as_pyobject(gvalue, TRUE);
- } else {
- PyErr_SetString(PyExc_TypeError, "lists are currently unspported");
- }
- }
-
- if (val == NULL)
- val = failobj;
- Py_INCREF(val);
- return val;
-}
-%%
-override gst_tag_list_foreach kwargs
-static gboolean
-pygst_tag_list_foreach_marshal(GstTagList *list,
- const gchar *tag,
- gpointer user_data)
+static int
+_wrap_gst_tag_list_ass_subscript(PyGObject *self,
+ PyObject *py_key,
+ PyObject *py_value)
{
- PyGstCustomNotify *cunote = user_data;
- PyObject *py_list;
- PyObject *py_key, *retobj;
- gboolean retval = TRUE;
- PyGILState_STATE state;
-
- g_assert(cunote->func);
-
- state = pyg_gil_state_ensure();
-
- py_list = pyg_boxed_new(GST_TYPE_TAG_LIST, list, TRUE, TRUE);
- py_key = Py_BuildValue("s", tag);
- if (cunote->data)
- retobj = PyEval_CallFunction(cunote->func, "(NNO)",
- py_list,
- py_key,
- cunote->data);
- else
- retobj = PyEval_CallFunction(cunote->func, "(NN)",
- py_list,
- py_key);
-
- if (PyErr_Occurred () || (retobj == NULL) || (retobj == Py_None)) {
- PyErr_Print ();
- retval = FALSE;
- } else if (retobj != Py_None) {
- retval = PyInt_AsLong(retobj);
+ const char *key;
+ GstStructure* structure;
+
+ 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;
+ gst_structure_set_value(structure, key, &v);
+ g_value_unset(&v);
+ } else {
+ gst_structure_remove_field(structure, key);
}
-
- Py_XDECREF(retobj);
-
- pyg_gil_state_release(state);
- return retval;
-}
-
-static PyObject *
-_wrap_gst_tag_list_foreach (PyGObject *self,
- PyObject *args,
- PyObject *kwargs)
-{
- static char *kwlist[] = { "foreach_function", "args", NULL };
- PyObject *pyfunc, *pyarg = NULL;
- PyGstCustomNotify cunote;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "O|O:GstTagList.foreach",
- kwlist, &pyfunc, &pyarg))
- return NULL;
-
- if (!PyCallable_Check(pyfunc)) {
- PyErr_SetString(PyExc_TypeError, "foreach_function not callable");
- return NULL;
- }
-
- cunote.func = pyfunc;
- cunote.data = pyarg;
- gst_tag_list_foreach(pyg_boxed_get(self, GstTagList),
- (GstTagForeachFunc)pygst_tag_list_foreach_marshal,
- &cunote);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-%%
-override gst_tag_list_get_value_index kwargs
-static PyObject *
-_wrap_gst_tag_list_get_value_index (PyGObject *self,
- PyObject *args,
- PyObject *kwargs)
-{
- static char *kwlist[] = { "tag", "index", NULL };
- char *tag;
- int index;
- const GValue *gvalue;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "si:GstTagList.get_value_index",
- kwlist, &tag, &index))
- return NULL;
-
- gvalue = gst_tag_list_get_value_index(pyg_boxed_get(self, GstTagList),
- tag,
- index);
-
- return pygst_value_as_pyobject(gvalue, FALSE);
+ return 0;
}
+static PyMappingMethods _wrap_gst_tag_list_tp_as_mapping = {
+ (inquiry)_wrap_gst_tag_list_length, /* mp_length */
+ (binaryfunc)_wrap_gst_tag_list_subscript, /* mp_subscript */
+ (objobjargproc)_wrap_gst_tag_list_ass_subscript /* mp_ass_subscript */
+};