mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
gstreamer/: GstStructure and GstTagList foreach() support.
Original commit message from CVS: * gstreamer/0.7.override: * gstreamer/common.h: GstStructure and GstTagList foreach() support. * examples/gstplay/player.py: Use TagList.foreach() to print tags.
This commit is contained in:
parent
f44fd3f602
commit
5b2f393d43
6 changed files with 385 additions and 4 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,7 +1,15 @@
|
|||
2004-02-24 David I. Lehn <dlehn@users.sourceforge.net>
|
||||
|
||||
* gstreamer/0.7.override:
|
||||
* gstreamer/common.h:
|
||||
GstStructure and GstTagList foreach() support.
|
||||
* examples/gstplay/player.py:
|
||||
Use TagList.foreach() to print tags.
|
||||
|
||||
2004-02-24 David I. Lehn <dlehn@users.sourceforge.net>
|
||||
|
||||
* gstreamer/common.override:
|
||||
Attempt to handle GstBuffer vs GstData better
|
||||
Attempt to handle GstBuffer vs GstData better.
|
||||
|
||||
2004-02-24 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@ import gobject
|
|||
from gstreamer import *
|
||||
from gstplay import Play
|
||||
|
||||
#threads_init()
|
||||
try:
|
||||
threads_init()
|
||||
except Exception, e:
|
||||
print e
|
||||
|
||||
def nano_time_string(nanos):
|
||||
ts = nanos / 1000000000
|
||||
|
@ -50,10 +53,23 @@ def got_have_video_size(sender, w, h):
|
|||
print 'video size %d %d' % (w, h)
|
||||
|
||||
def got_found_tag(sender, src, tags, *args):
|
||||
def fe(tl, tag):
|
||||
c = tl.get_tag_size(tag)
|
||||
#print tl, tag, c
|
||||
for i in range(c):
|
||||
v = tl.get_value_index(tag, i)
|
||||
#print tag, type(v)
|
||||
if i == 0:
|
||||
s = gst_tag_get_nick(tag)
|
||||
else:
|
||||
s = ' '
|
||||
print "%15s: %s" % (s, v)
|
||||
print 'found tag', src, tags, args
|
||||
tags.foreach(fe)
|
||||
|
||||
def got_eos(sender, *args):
|
||||
def got_eos(sender, loop):
|
||||
print 'eos', args
|
||||
loop.quit()
|
||||
|
||||
def idle_iterate(sender):
|
||||
#threads_enter()
|
||||
|
@ -79,7 +95,7 @@ def main():
|
|||
play.connect('stream_length', got_stream_length)
|
||||
play.connect('have_video_size', got_have_video_size)
|
||||
play.connect('found_tag', got_found_tag)
|
||||
play.connect('eos', got_eos)
|
||||
play.connect('eos', got_eos, loop)
|
||||
|
||||
data_src = Element ('gnomevfssrc', 'data_src')
|
||||
#audio_sink = Element ('osssink', 'audio_sink')
|
||||
|
@ -102,7 +118,12 @@ def main():
|
|||
#while play.iterate(): pass
|
||||
#while play.iterate(): print '.'
|
||||
gobject.idle_add(idle_iterate, play)
|
||||
#iterid = add_iterate_bin(play)
|
||||
|
||||
#import gtk
|
||||
#gtk.threads_enter()
|
||||
loop.run()
|
||||
#gtk.threads_leave()
|
||||
|
||||
#threads_leave()
|
||||
|
||||
|
|
172
gst/0.7.override
172
gst/0.7.override
|
@ -71,3 +71,175 @@ _wrap_gst_structure_set_value(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_structure_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_structure_foreach_marshal(GQuark field_id,
|
||||
GValue *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyObject *py_field, *py_value, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
//py_model = pygobject_new((GObject *)model);
|
||||
//py_path = pygtk_tree_path_to_pyobject(path);
|
||||
//py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE);
|
||||
py_field = Py_BuildValue("s", g_quark_to_string(field_id));
|
||||
py_value = pyg_value_as_pyobject(value, FALSE);
|
||||
if (cunote->data)
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NNO)",
|
||||
py_field, py_value,
|
||||
cunote->data);
|
||||
else
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NN)",
|
||||
py_field, py_value);
|
||||
|
||||
if (PyErr_Occurred () || (retobj == NULL) || (retobj == Py_None)) {
|
||||
PyErr_Print ();
|
||||
retval = FALSE;
|
||||
} else if (retobj != Py_None) {
|
||||
retval = PyInt_AsLong(retobj);
|
||||
}
|
||||
|
||||
Py_XDECREF(retobj);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_structure_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:GstStructure.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_structure_foreach(pyg_boxed_get(self, GstStructure),
|
||||
pygst_structure_foreach_marshal,
|
||||
&cunote);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_tag_list_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_tag_list_foreach_marshal(GstTagList *list,
|
||||
const gchar *tag,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyGObject *py_list;
|
||||
PyObject *py_key, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Py_XDECREF(retobj);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
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),
|
||||
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;
|
||||
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 pyg_value_as_pyobject(gvalue, FALSE);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#include <gst/gstqueue.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
|
||||
typedef struct {
|
||||
PyObject *func, *data;
|
||||
} PyGstCustomNotify;
|
||||
|
||||
void iterate_bin_all(GstBin *bin);
|
||||
guint add_iterate_bin(GstBin *bin);
|
||||
void remove_iterate_bin(guint id);
|
||||
|
|
|
@ -71,3 +71,175 @@ _wrap_gst_structure_set_value(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_structure_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_structure_foreach_marshal(GQuark field_id,
|
||||
GValue *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyObject *py_field, *py_value, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
//py_model = pygobject_new((GObject *)model);
|
||||
//py_path = pygtk_tree_path_to_pyobject(path);
|
||||
//py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE);
|
||||
py_field = Py_BuildValue("s", g_quark_to_string(field_id));
|
||||
py_value = pyg_value_as_pyobject(value, FALSE);
|
||||
if (cunote->data)
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NNO)",
|
||||
py_field, py_value,
|
||||
cunote->data);
|
||||
else
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NN)",
|
||||
py_field, py_value);
|
||||
|
||||
if (PyErr_Occurred () || (retobj == NULL) || (retobj == Py_None)) {
|
||||
PyErr_Print ();
|
||||
retval = FALSE;
|
||||
} else if (retobj != Py_None) {
|
||||
retval = PyInt_AsLong(retobj);
|
||||
}
|
||||
|
||||
Py_XDECREF(retobj);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_structure_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:GstStructure.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_structure_foreach(pyg_boxed_get(self, GstStructure),
|
||||
pygst_structure_foreach_marshal,
|
||||
&cunote);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_tag_list_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_tag_list_foreach_marshal(GstTagList *list,
|
||||
const gchar *tag,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyGObject *py_list;
|
||||
PyObject *py_key, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Py_XDECREF(retobj);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
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),
|
||||
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;
|
||||
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 pyg_value_as_pyobject(gvalue, FALSE);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#include <gst/gstqueue.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
|
||||
typedef struct {
|
||||
PyObject *func, *data;
|
||||
} PyGstCustomNotify;
|
||||
|
||||
void iterate_bin_all(GstBin *bin);
|
||||
guint add_iterate_bin(GstBin *bin);
|
||||
void remove_iterate_bin(guint id);
|
||||
|
|
Loading…
Reference in a new issue