gst/gst.override: removed deprecated wrappers (gst_event_new_any*)

Original commit message from CVS:
* gst/gst.override:
removed deprecated wrappers (gst_event_new_any*)
* gst/gstbuffer.override:
* gst/gstquery.override:
* gst/gstmessage.override:
* gst/gstevent.override:
* gst/pygstminiobject.c:
* gst/pygstminiobject.h:
Correct wrapping of functions 'creating' mini-objects
* gst/gstelement.override: (_wrap_gst_element_get_state):
More meaningful exception message
* gst/gstpad.override:
wrapped gst_pad_alloc_buffer(), gst_pad_pull_range(),
gst_pad_get_range(), gst_pad_get_internal_links(),
gst_pad_get_internal_links_default(), gst_pad_get_query_types(),
gst_pad_get_query_types_default()
This commit is contained in:
Edward Hervey 2005-07-12 16:37:31 +00:00
parent 786460e832
commit 9b74a9033a
10 changed files with 565 additions and 118 deletions

View file

@ -1,3 +1,26 @@
2005-07-12 Edward Hervey <edward@fluendo.com>
* gst/gst.override:
removed deprecated wrappers (gst_event_new_any*)
* gst/gstbuffer.override:
* gst/gstquery.override:
* gst/gstmessage.override:
* gst/gstevent.override:
* gst/pygstminiobject.c:
* gst/pygstminiobject.h:
Correct wrapping of functions 'creating' mini-objects
* gst/gstelement.override: (_wrap_gst_element_get_state):
More meaningful exception message
* gst/gstpad.override:
wrapped gst_pad_alloc_buffer(), gst_pad_pull_range(),
gst_pad_get_range(), gst_pad_get_internal_links(),
gst_pad_get_internal_links_default(), gst_pad_get_query_types(),
gst_pad_get_query_types_default()
2005-07-12 Andy Wingo <wingo@pobox.com>
* examples/pipeline-tester: New file, tests out gstreamer

View file

@ -658,83 +658,6 @@ _wrap_gst_main_quit(PyObject *self)
return Py_None;
}
%%
override gst_event_new_any kwargs
static PyObject *
_wrap_gst_event_new_any(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "structure", NULL };
PyObject *py_structure;
GstStructure *structure = NULL;
GstEvent *event;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O:event_new_any", kwlist, &py_structure))
return NULL;
if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE))
structure = pyg_boxed_get(py_structure, GstStructure);
else {
PyErr_SetString(PyExc_TypeError,
"structure should be a GstStructure");
return NULL;
}
event = gst_event_new (GST_EVENT_ANY);
if (!event) {
PyErr_SetString(PyExc_RuntimeError,
"could not create GstEvent object");
return NULL;
}
event->event_data.structure.structure = gst_structure_copy(structure);
/* pyg_boxed_new handles NULL checking */
return pyg_boxed_new(GST_TYPE_EVENT, event, TRUE, TRUE);
}
%%
override gst_event_any_get_structure noargs
static PyObject *
_wrap_gst_event_any_get_structure(PyObject *self)
{
GstStructure *ret;
GstEvent *event;
event = pyg_pointer_get(self, GstEvent);
if (GST_EVENT_TYPE(event) == GST_EVENT_ANY) {
ret = event->event_data.structure.structure;
/* pyg_boxed_new handles NULL checking */
return pyg_boxed_new(GST_TYPE_STRUCTURE, ret, TRUE, TRUE);
} else {
Py_INCREF(Py_None);
return Py_None;
}
}
%%
override gst_event_new_discontinuous kwargs
static PyObject *
_wrap_gst_event_new_discontinuous(PyObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "new_media", "format", "value", NULL };
int new_media = FALSE;
PyObject *py_format = NULL;
gint64 value = 0;
GstFormat format;
GstEvent *event;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"iOL:event_new_discontinuous", kwlist, &new_media, &py_format,
&value)) {
return NULL;
}
if (pyg_enum_get_value(GST_TYPE_FORMAT, py_format, (gint *) &format)) {
return NULL;
}
event = gst_event_new_discontinuous (new_media, format, value,
GST_FORMAT_UNDEFINED);
return pyg_boxed_new(GST_TYPE_EVENT, event, TRUE, TRUE);
}
%%
override gst_registry_pool_plugin_list noargs
static PyObject *
_wrap_gst_registry_pool_plugin_list(PyGObject *self)

View file

@ -76,6 +76,21 @@ _wrap_gst_buffer_new(PyGstMiniObject *self, PyObject *args, PyObject *kwargs)
return 0;
}
%%
override gst_buffer_new_and_alloc kwargs
static PyObject *
_wrap_gst_buffer_new_and_alloc(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "size", NULL };
GstBuffer *ret;
guint size;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "I:buffer_new_and_alloc", kwlist, &size))
return NULL;
ret = gst_buffer_new_and_alloc(size);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_buffer_get_data
static PyObject*
_wrap_gst_buffer_get_data(PyObject *self)

View file

@ -95,7 +95,7 @@ _wrap_gst_element_get_state(PyGObject *self, PyObject *args, PyObject *kwargs)
/* Only returns the state for the time being */
ret = gst_element_get_state(GST_ELEMENT (self->obj), &state, NULL, NULL);
if (!ret) {
PyErr_SetString(PyExc_RuntimeError, "conversion could not be performed");
PyErr_SetString(PyExc_RuntimeError, "Element is in an error state");
return NULL;
}
return pyg_flags_from_gtype(GST_TYPE_ELEMENT_STATE, state);

View file

@ -54,3 +54,97 @@ _wrap_gst_event_discont_get_value(PyGstMiniObject *self, PyObject *args, PyObjec
return ret;
}
%%
override gst_event_new_seek kwargs
static PyObject *
_wrap_gst_event_new_seek(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "type", "offset", NULL };
PyObject *py_type = NULL;
gint64 offset;
GstEvent *ret;
GstSeekType type;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OL:event_new_seek", kwlist, &py_type, &offset))
return NULL;
if (pyg_flags_get_value(GST_TYPE_SEEK_TYPE, py_type, (gint *)&type))
return NULL;
ret = gst_event_new_seek(type, offset);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_event_new_segment_seek kwargs
static PyObject *
_wrap_gst_event_new_segment_seek(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "type", "start", "stop", NULL };
PyObject *py_type = NULL;
gint64 start, stop;
GstEvent *ret;
GstSeekType type;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OLL:event_new_segment_seek", kwlist, &py_type, &start, &stop))
return NULL;
if (pyg_flags_get_value(GST_TYPE_SEEK_TYPE, py_type, (gint *)&type))
return NULL;
ret = gst_event_new_segment_seek(type, start, stop);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_event_new_size kwargs
static PyObject *
_wrap_gst_event_new_size(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "format", "value", NULL };
PyObject *py_format = NULL;
GstFormat format;
GstEvent *ret;
gint64 value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OL:event_new_size", kwlist, &py_format, &value))
return NULL;
if (pyg_enum_get_value(GST_TYPE_FORMAT, py_format, (gint *)&format))
return NULL;
ret = gst_event_new_size(format, value);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_event_new_flush kwargs
static PyObject *
_wrap_gst_event_new_flush(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "done", NULL };
int done;
GstEvent *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:event_new_flush", kwlist, &done))
return NULL;
ret = gst_event_new_flush(done);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_event_new_tag kwargs
static PyObject *
_wrap_gst_event_new_tag(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "list", NULL };
GstTagList *list = NULL;
PyObject *py_list;
GstEvent *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:event_new_tag", kwlist, &py_list))
return NULL;
if (pyg_boxed_check(py_list, GST_TYPE_TAG_LIST))
list = pyg_boxed_get(py_list, GstTagList);
else {
PyErr_SetString(PyExc_TypeError, "list should be a GstTagList");
return NULL;
}
ret = gst_event_new_tag(list);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}

View file

@ -106,3 +106,133 @@ _wrap_gst_message_parse_tag (PyGstMiniObject *self)
return ret;
}
%%
override gst_message_new_eos kwargs
static PyObject *
_wrap_gst_message_new_eos(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "src", NULL };
PyGObject *src;
GstMessage *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:message_new_eos", kwlist, &PyGstObject_Type, &src))
return NULL;
ret = gst_message_new_eos(GST_OBJECT(src->obj));
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_message_new_error kwargs
static PyObject *
_wrap_gst_message_new_error(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "src", "error", "debug", NULL };
PyGObject *src;
PyObject *py_error;
char *debug;
GError *error = NULL;
GstMessage *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!Os:message_new_error", kwlist, &PyGstObject_Type, &src, &py_error, &debug))
return NULL;
if (pyg_boxed_check(py_error, GST_TYPE_G_ERROR))
error = pyg_boxed_get(py_error, GError);
else {
PyErr_SetString(PyExc_TypeError, "error should be a GError");
return NULL;
}
ret = gst_message_new_error(GST_OBJECT(src->obj), error, debug);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_message_new_warning kwargs
static PyObject *
_wrap_gst_message_new_warning(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "src", "error", "debug", NULL };
PyGObject *src;
PyObject *py_error;
char *debug;
GError *error = NULL;
GstMessage *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!Os:message_new_warning", kwlist, &PyGstObject_Type, &src, &py_error, &debug))
return NULL;
if (pyg_boxed_check(py_error, GST_TYPE_G_ERROR))
error = pyg_boxed_get(py_error, GError);
else {
PyErr_SetString(PyExc_TypeError, "error should be a GError");
return NULL;
}
ret = gst_message_new_warning(GST_OBJECT(src->obj), error, debug);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_message_new_tag kwargs
static PyObject *
_wrap_gst_message_new_tag(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "src", "tag_list", NULL };
PyGObject *src;
GstTagList *tag_list = NULL;
PyObject *py_tag_list;
GstMessage *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:message_new_tag", kwlist, &PyGstObject_Type, &src, &py_tag_list))
return NULL;
if (pyg_boxed_check(py_tag_list, GST_TYPE_TAG_LIST))
tag_list = pyg_boxed_get(py_tag_list, GstTagList);
else {
PyErr_SetString(PyExc_TypeError, "tag_list should be a GstTagList");
return NULL;
}
ret = gst_message_new_tag(GST_OBJECT(src->obj), tag_list);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_message_new_state_changed kwargs
static PyObject *
_wrap_gst_message_new_state_changed(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "src", "old_state", "new_state", NULL };
PyGObject *src;
PyObject *py_old_state = NULL, *py_new_state = NULL;
GstElementState old_state, new_state;
GstMessage *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!OO:message_new_state_changed", kwlist, &PyGstObject_Type, &src, &py_old_state, &py_new_state))
return NULL;
if (pyg_flags_get_value(GST_TYPE_ELEMENT_STATE, py_old_state, (gint *)&old_state))
return NULL;
if (pyg_flags_get_value(GST_TYPE_ELEMENT_STATE, py_new_state, (gint *)&new_state))
return NULL;
ret = gst_message_new_state_changed(GST_OBJECT(src->obj), old_state, new_state);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_message_new_application kwargs
static PyObject *
_wrap_gst_message_new_application(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "src", "structure", NULL };
PyGObject *src;
PyObject *py_structure;
GstStructure *structure = NULL;
GstMessage *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:message_new_application", kwlist, &PyGstObject_Type, &src, &py_structure))
return NULL;
if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE))
structure = pyg_boxed_get(py_structure, GstStructure);
else {
PyErr_SetString(PyExc_TypeError, "structure should be a GstStructure");
return NULL;
}
ret = gst_message_new_application(GST_OBJECT(src->obj), structure);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}

View file

@ -407,14 +407,12 @@ _wrap_gst_pad_query(PyGObject *self, PyObject *args, PyObject *kwargs)
static char *kwlist[] = { "query", NULL };
int ret;
PyGstMiniObject *query;
GstMiniObject *copy;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GstPad.query", kwlist, &PyGstQuery_Type, &query))
return NULL;
copy = gst_mini_object_make_writable(query->obj);
ret = gst_pad_query(GST_PAD(self->obj), GST_QUERY (copy));
gst_mini_object_unref ((query->obj));
gst_mini_object_replace (&(query->obj), copy);
ret = gst_pad_query(GST_PAD(self->obj), GST_QUERY (query->obj));
return PyBool_FromLong(ret);
}
%%
@ -831,3 +829,172 @@ _wrap_gst_pad_query_convert (PyGObject *self, PyObject *args, PyObject *kwargs)
return ret;
}
%%
override gst_pad_alloc_buffer kwargs
static PyObject *
_wrap_gst_pad_alloc_buffer (PyGObject *self, PyObject * args, PyObject *kwargs)
{
static char *kwlist[] = {"offset", "size", "caps", NULL};
guint64 offset;
gint size;
PyObject *pcaps;
GstCaps *caps;
PyObject *ret;
GstBuffer *buf;
GstFlowReturn res;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"KiO:GstPad.alloc_buffer",
kwlist, &offset, &size, &pcaps))
return NULL;
caps = pyg_boxed_get(pcaps, GstCaps);
res = gst_pad_alloc_buffer (GST_PAD(pygobject_get(self)),
offset, size, caps, &buf);
ret = PyList_New(0);
PyList_Append(ret, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, res));
if (res != GST_FLOW_OK) {
Py_INCREF(Py_None);
PyList_Append(ret, Py_None);
} else {
PyList_Append(ret, pygstminiobject_new(GST_MINI_OBJECT(buf)));
}
return ret;
}
%%
override gst_pad_pull_range kwargs
static PyObject *
_wrap_gst_pad_pull_range (PyGObject *self, PyObject * args, PyObject *kwargs)
{
static char *kwlist[] = {"offset", "size", NULL};
guint64 offset;
gint size;
PyObject *ret;
GstBuffer *buf;
GstFlowReturn res;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"Ki:GstPad.pull_range",
kwlist, &offset, &size))
return NULL;
res = gst_pad_pull_range (GST_PAD(pygobject_get(self)),
offset, size, &buf);
ret = PyList_New(0);
PyList_Append(ret, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, res));
if (res != GST_FLOW_OK) {
Py_INCREF(Py_None);
PyList_Append(ret, Py_None);
} else {
PyList_Append(ret, pygstminiobject_new(GST_MINI_OBJECT(buf)));
}
return ret;
}
%%
override gst_pad_get_range kwargs
static PyObject *
_wrap_gst_pad_get_range (PyGObject *self, PyObject * args, PyObject *kwargs)
{
static char *kwlist[] = {"offset", "size", NULL};
guint64 offset;
gint size;
PyObject *ret;
GstBuffer *buf;
GstFlowReturn res;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"Ki:GstPad.get_range",
kwlist, &offset, &size))
return NULL;
res = gst_pad_get_range (GST_PAD(pygobject_get(self)),
offset, size, &buf);
ret = PyList_New(0);
PyList_Append(ret, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, res));
if (res != GST_FLOW_OK) {
Py_INCREF(Py_None);
PyList_Append(ret, Py_None);
} else {
PyList_Append(ret, pygstminiobject_new(GST_MINI_OBJECT(buf)));
}
return ret;
}
%%
override gst_pad_get_internal_links noargs
static PyObject *
_wrap_gst_pad_get_internal_links (PyGObject * self)
{
PyObject *ret;
GList *lst, *tmp;
lst = gst_pad_get_internal_links (GST_PAD (pygobject_get(self)));
ret = PyList_New(0);
for (tmp = lst ; tmp; tmp = g_list_next(tmp)) {
PyList_Append(ret, pygobject_new(G_OBJECT(tmp->data)));
}
g_list_free(lst);
return ret;
}
%%
override gst_pad_get_internal_links_default noargs
static PyObject *
_wrap_gst_pad_get_internal_links_default (PyGObject * self)
{
PyObject *ret;
GList *lst, *tmp;
lst = gst_pad_get_internal_links_default (GST_PAD (pygobject_get(self)));
ret = PyList_New(0);
for (tmp = lst ; tmp; tmp = g_list_next(tmp)) {
PyList_Append(ret, pygobject_new(G_OBJECT(tmp->data)));
}
g_list_free(lst);
return ret;
}
%%
override gst_pad_get_query_types noargs
static PyObject *
_wrap_gst_pad_get_query_types (PyGObject *self)
{
PyObject *ret;
PyObject *item;
int i;
GstQueryType *tab;
tab = (GstQueryType*) gst_pad_get_query_types(GST_PAD(self->obj));
if (tab == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
ret = PyList_New(0);
for (i = 0; tab[i] != 0; i++) {
item = pyg_enum_from_gtype (GST_TYPE_QUERY_TYPE, tab[i]);
PyList_Append(ret, item);
}
return ret;
}
%%
override gst_pad_get_query_types_default noargs
static PyObject *
_wrap_gst_pad_get_query_types_default (PyGObject *self)
{
PyObject *ret;
PyObject *item;
int i;
GstQueryType *tab;
tab = (GstQueryType*) gst_pad_get_query_types_default(GST_PAD(self->obj));
if (tab == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
ret = PyList_New(0);
for (i = 0; tab[i] != 0; i++) {
item = pyg_enum_from_gtype (GST_TYPE_QUERY_TYPE, tab[i]);
PyList_Append(ret, item);
}
return ret;
}

View file

@ -112,3 +112,67 @@ _wrap_gst_query_parse_seeking_response (PyGstMiniObject *self)
return ret;
}
%%
override gst_query_new_position kwargs
static PyObject *
_wrap_gst_query_new_position(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "format", NULL };
PyObject *py_format = NULL;
GstFormat format;
GstQuery *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:query_new_position", kwlist, &py_format))
return NULL;
if (pyg_enum_get_value(GST_TYPE_FORMAT, py_format, (gint *)&format))
return NULL;
ret = gst_query_new_position(format);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_query_new_convert kwargs
static PyObject *
_wrap_gst_query_new_convert(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "src_fmt", "value", "dest_fmt", NULL };
PyObject *py_src_fmt = NULL, *py_dest_fmt = NULL;
GstQuery *ret;
GstFormat src_fmt, dest_fmt;
gint64 value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OLO:query_new_convert", kwlist, &py_src_fmt, &value, &py_dest_fmt))
return NULL;
if (pyg_enum_get_value(GST_TYPE_FORMAT, py_src_fmt, (gint *)&src_fmt))
return NULL;
if (pyg_enum_get_value(GST_TYPE_FORMAT, py_dest_fmt, (gint *)&dest_fmt))
return NULL;
ret = gst_query_new_convert(src_fmt, value, dest_fmt);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}
%%
override gst_query_new_application kwargs
static PyObject *
_wrap_gst_query_new_application(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "type", "structure", NULL };
PyObject *py_type = NULL, *py_structure;
GstQuery *ret;
GstStructure *structure = NULL;
GstQueryType type;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:query_new_application", kwlist, &py_type, &py_structure))
return NULL;
if (pyg_enum_get_value(GST_TYPE_QUERY_TYPE, py_type, (gint *)&type))
return NULL;
if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE))
structure = pyg_boxed_get(py_structure, GstStructure);
else {
PyErr_SetString(PyExc_TypeError, "structure should be a GstStructure");
return NULL;
}
ret = gst_query_new_application(type, structure);
/* pygobject_new handles NULL checking */
return pygstminiobject_new_noref((GstMiniObject *)ret);
}

View file

@ -24,8 +24,8 @@
static const gchar *pygstminiobject_class_id = "PyGstMiniObject::class";
static GQuark pygstminiobject_class_key = 0;
static const gchar *pygstminiobject_wrapper_id = "PyGstMiniObject::wrapper";
static GQuark pygstminiobject_wrapper_key = 0;
/* static const gchar *pygstminiobject_wrapper_id = "PyGstMiniObject::wrapper"; */
/* static GQuark pygstminiobject_wrapper_key = 0; */
static void pygstminiobject_dealloc(PyGstMiniObject *self);
static int pygstminiobject_traverse(PyGstMiniObject *self, visitproc visit, void *arg);
@ -119,10 +119,6 @@ pygstminiobject_register_class(PyObject *dict, const gchar *type_name,
g_type_set_qdata(gtype, pygstminiobject_class_key, type);
}
/* set up __doc__ descriptor on type */
/* PyDict_SetItemString(type->tp_dict, "__doc__", */
/* pyg_object_descr_doc_get()); */
PyDict_SetItemString(dict, (char *)class_name, (PyObject *)type);
}
@ -142,16 +138,11 @@ pygstminiobject_register_wrapper(PyObject *self)
GstMiniObject *obj = ((PyGstMiniObject *)self)->obj;
PyGILState_STATE state;
if (!pygstminiobject_wrapper_key)
pygstminiobject_wrapper_key=g_quark_from_static_string(pygstminiobject_wrapper_id);
Py_INCREF(self);
state = pyg_gil_state_ensure();
g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self);
gst_mini_object_ref(obj);
pyg_gil_state_release(state);
/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */
/* pyg_destroy_notify); */
}
@ -172,9 +163,6 @@ pygstminiobject_new(GstMiniObject *obj)
PyGILState_STATE state;
PyGstMiniObject *self;
if (!pygstminiobject_wrapper_key)
pygstminiobject_wrapper_key = g_quark_from_static_string(pygstminiobject_wrapper_id);
if (obj == NULL) {
Py_INCREF(Py_None);
return Py_None;
@ -184,7 +172,7 @@ pygstminiobject_new(GstMiniObject *obj)
state = pyg_gil_state_ensure();
self = (PyGstMiniObject *)g_hash_table_lookup (miniobjs, (gpointer) obj);
pyg_gil_state_release(state);
/* self = (PyGstMiniObject *)gst_mini_object_get_qdata(obj, pygstminiobject_wrapper_key); */
if (self != NULL) {
Py_INCREF(self);
} else {
@ -203,20 +191,69 @@ pygstminiobject_new(GstMiniObject *obj)
self->inst_dict = NULL;
self->weakreflist = NULL;
/* save wrapper pointer so we can access it later */
Py_INCREF(self);
state = pyg_gil_state_ensure();
gst_mini_object_ref(obj);
/* save wrapper pointer so we can access it later */
g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self);
pyg_gil_state_release(state);
/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */
/* pyg_destroy_notify); */
PyObject_GC_Track((PyObject *)self);
}
return (PyObject *)self;
}
/**
* pygstminiobject_new_noref
* @obj: a GstMiniObject instance.
*
* This function will return the wrapper for the given MiniObject
* Only use this function to wrap miniobjects created in the bindings
*
* Returns: a reference to the wrapper for the GstMiniObject.
*/
PyObject *
pygstminiobject_new_noref(GstMiniObject *obj)
{
PyGILState_STATE state;
PyGstMiniObject *self;
if (obj == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
/* create wrapper */
PyTypeObject *tp = pygstminiobject_lookup_class(G_OBJECT_TYPE(obj));
if (!tp)
g_warning ("Couldn't get class for type object : %p", obj);
/* need to bump type refcount if created with
pygstminiobject_new_with_interfaces(). fixes bug #141042 */
if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE)
Py_INCREF(tp);
self = PyObject_GC_New(PyGstMiniObject, tp);
if (self == NULL)
return NULL;
/* DO NOT REF !! */
self->obj = obj;
/*self->obj = gst_mini_object_ref(obj);*/
self->inst_dict = NULL;
self->weakreflist = NULL;
/* save wrapper pointer so we can access it later */
Py_INCREF(self);
state = pyg_gil_state_ensure();
g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self);
pyg_gil_state_release(state);
PyObject_GC_Track((PyObject *)self);
return (PyObject *)self;
}
static void
pygstminiobject_dealloc(PyGstMiniObject *self)
{
@ -233,7 +270,7 @@ pygstminiobject_dealloc(PyGstMiniObject *self)
PyObject_GC_UnTrack((PyObject *)self);
if (self->obj) {
gst_mini_object_unref(self->obj);
gst_mini_object_unref(self->obj);
obj = self->obj;
}
self->obj = NULL;
@ -246,8 +283,7 @@ pygstminiobject_dealloc(PyGstMiniObject *self)
/* the following causes problems with subclassed types */
/* self->ob_type->tp_free((PyObject *)self); */
g_hash_table_remove (miniobjs, (gpointer) obj);
if (obj)
gst_mini_object_unref(obj);
PyObject_GC_Del(self);
pyg_gil_state_release(state);
}
@ -314,14 +350,6 @@ pygstminiobject_clear(PyGstMiniObject *self)
static void
pygstminiobject_free(PyObject *op)
{
PyGILState_STATE state;
GstMiniObject *obj = ((PyGstMiniObject*) op)->obj;
state = pyg_gil_state_ensure();
g_hash_table_remove (miniobjs, obj);
if (obj)
gst_mini_object_unref (obj);
pyg_gil_state_release(state);
PyObject_GC_Del(op);
}
@ -380,7 +408,8 @@ pygstminiobject_copy(PyGstMiniObject *self, PyObject *args)
static PyObject *
pygstminiobject_ref(PyGstMiniObject *self, PyObject *args)
{
return pygstminiobject_new(gst_mini_object_ref(self->obj));
gst_mini_object_ref(self->obj);
return (PyObject*) self;
}
static PyObject *
@ -394,9 +423,9 @@ pygstminiobject_unref(PyGstMiniObject *self, PyObject *args)
static PyMethodDef pygstminiobject_methods[] = {
{ "__gstminiobject_init__", (PyCFunction)pygstminiobject__gstminiobject_init__,
METH_VARARGS|METH_KEYWORDS },
{ "copy", (PyCFunction)pygstminiobject_copy, METH_VARARGS},
{ "ref", (PyCFunction)pygstminiobject_ref, METH_VARARGS},
{ "unref", (PyCFunction)pygstminiobject_unref, METH_VARARGS},
{ "copy", (PyCFunction)pygstminiobject_copy, METH_VARARGS, "Copies the miniobject"},
{ "ref", (PyCFunction)pygstminiobject_ref, METH_VARARGS, "Adds a reference to the miniobject" },
{ "unref", (PyCFunction)pygstminiobject_unref, METH_VARARGS, "Removes a reference from the miniobject"},
{ NULL, NULL, 0 }
};

View file

@ -28,6 +28,8 @@ typedef struct {
PyObject *
pygstminiobject_new(GstMiniObject *obj);
PyObject *
pygstminiobject_new_noref(GstMiniObject *obj);
#define pygstminiobject_get(v) (((PyGstMiniObject *)(v))->obj)
#define pygstminiobject_check(v,base) (PyObject_TypeCheck(v,base))