gst/: Proper registration of PyGstMiniObject classes in order to be able to create Event, Messages, Buffers from python.

Original commit message from CVS:
* gst/gstmodule.c:
* gst/pygstminiobject.c:
Proper registration of PyGstMiniObject classes in order to be able to
create Event, Messages, Buffers from python.
More corrections on miniobject's refcounting
* gst/gstevent.override:
* gst/gstbuffer.override:
Removed overloaded overrides
* gst/gst.defs:
updated
This commit is contained in:
Edward Hervey 2005-07-05 15:07:20 +00:00
parent 30eeebe7d7
commit bc47432fc8
6 changed files with 106 additions and 127 deletions

View file

@ -1,3 +1,18 @@
2005-07-05 Edward Hervey <edward@fluendo.com>
* gst/gstmodule.c:
* gst/pygstminiobject.c:
Proper registration of PyGstMiniObject classes in order to be able to
create Event, Messages, Buffers from python.
More corrections on miniobject's refcounting
* gst/gstevent.override:
* gst/gstbuffer.override:
Removed overloaded overrides
* gst/gst.defs:
updated
2005-07-01 Edward Hervey <edward@fluendo.com>
* configure.ac:

View file

@ -2443,6 +2443,7 @@
(c-name "gst_message_new_application")
(return-type "GstMessage*")
(parameters
'("GstObject*" "src")
'("GstStructure*" "structure")
)
)
@ -3048,7 +3049,7 @@
(define-method fixate_caps
(of-object "GstPad")
(c-name "gst_pad_fixate_caps")
(return-type "GstCaps*")
(return-type "none")
(parameters
'("GstCaps*" "caps")
)
@ -3273,6 +3274,66 @@
)
)
(define-method add_data_probe
(of-object "GstPad")
(c-name "gst_pad_add_data_probe")
(return-type "gulong")
(parameters
'("GCallback" "handler")
'("gpointer" "data")
)
)
(define-method remove_data_probe
(of-object "GstPad")
(c-name "gst_pad_remove_data_probe")
(return-type "none")
(parameters
'("GCallback" "handler")
'("gpointer" "data")
)
)
(define-method add_event_probe
(of-object "GstPad")
(c-name "gst_pad_add_event_probe")
(return-type "gulong")
(parameters
'("GCallback" "handler")
'("gpointer" "data")
)
)
(define-method remove_event_probe
(of-object "GstPad")
(c-name "gst_pad_remove_event_probe")
(return-type "none")
(parameters
'("GCallback" "handler")
'("gpointer" "data")
)
)
(define-method add_buffer_probe
(of-object "GstPad")
(c-name "gst_pad_add_buffer_probe")
(return-type "gulong")
(parameters
'("GCallback" "handler")
'("gpointer" "data")
)
)
(define-method remove_buffer_probe
(of-object "GstPad")
(c-name "gst_pad_remove_buffer_probe")
(return-type "none")
(parameters
'("GCallback" "handler")
'("gpointer" "data")
)
)
(define-function pad_load_and_link
(c-name "gst_pad_load_and_link")
(return-type "none")

View file

@ -118,86 +118,6 @@ _wrap_gst_buffer_set_data(PyObject *self, PyObject *args, PyObject *kwargs)
return Py_None;
}
%%
override-attr GstBuffer.data_type
static PyObject*
_wrap_gst_buffer__get_data_type(PyGstMiniObject *self, void *closure)
{
return pyg_type_wrapper_new(GST_DATA_TYPE(self->obj));
}
%%
override-attr GstBuffer.flags
static PyObject*
_wrap_gst_buffer__get_flags(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_DATA_FLAGS(self->obj));
}
%%
override-attr GstBuffer.size
static PyObject *
_wrap_gst_buffer__get_size(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_BUFFER_SIZE(self->obj));
}
%%
override-attr GstBuffer.maxsize
static PyObject *
_wrap_gst_buffer__get_maxsize(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_BUFFER_MAXSIZE(self->obj));
}
%%
override-attr GstBuffer.offset
static PyObject *
_wrap_gst_buffer__get_offset(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_BUFFER_OFFSET(self->obj));
}
%%
override-attr GstBuffer.offset_end
static PyObject *
_wrap_gst_buffer__get_offset_end(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_BUFFER_OFFSET_END(self->obj));
}
%%
override-attr GstBuffer.timestamp
static PyObject *
_wrap_gst_buffer__get_timestamp(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_BUFFER(self->obj)->timestamp);
}
static int
_wrap_gst_buffer__set_timestamp(PyGBoxed *self, PyObject *value, void *closure)
{
gint val;
val = PyInt_AsLong(value);
if (PyErr_Occurred())
return -1;
pyg_boxed_get(self, GstBuffer)->timestamp = val;
return 0;
}
%%
override-attr GstBuffer.duration
static PyObject *
_wrap_gst_buffer__get_duration(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_BUFFER(self->obj)->duration);
}
static int
_wrap_gst_buffer__set_duration(PyGBoxed *self, PyObject *value, void *closure)
{
gint val;
val = PyInt_AsLong(value);
if (PyErr_Occurred())
return -1;
pyg_boxed_get(self, GstBuffer)->duration = val;
return 0;
}
%%
override-slot GstBuffer.tp_str
static PyObject *
_wrap_gst_buffer_tp_str(PyGstMiniObject *self)
@ -378,16 +298,6 @@ _wrap_gst_buffer_copy_on_write (PyObject *self)
self = pyg_boxed_new (GST_TYPE_BUFFER, buf, FALSE, TRUE);
return self;
}
/* %%
define GstBuffer.flags noargs
static PyObject *
_wrap_gst_buffer_flags(PyGBoxed *self)
{
GstBuffer *buf = pyg_boxed_get(self, GstBuffer);
g_assert(GST_IS_BUFFER(buf));
return PyInt_FromLong(GST_BUFFER_FLAGS(buf));
} */
%%
define GstBuffer.flag_is_set
static PyObject *

View file

@ -19,31 +19,3 @@
*
* Author: Johan Dahlin <johan@gnome.org>
*/
%%
override-attr GstEvent.data_type
static PyObject*
_wrap_gst_event__get_data_type(PyGObject *self, void *closure)
{
return pyg_type_wrapper_new(GST_DATA_TYPE(GST_DATA(self->obj)));
}
%%
override-attr GstEvent.flags
static PyObject*
_wrap_gst_event__get_flags(PyGObject *self, void *closure)
{
return PyInt_FromLong(GST_DATA_FLAGS(self->obj));
}
%%
override-attr GstEvent.type
static PyObject*
_wrap_gst_event__get_type(PyGObject *self, void *closure)
{
return pyg_enum_from_gtype(GST_TYPE_EVENT_TYPE, GST_EVENT_TYPE(GST_EVENT(self->obj)));
}
%%
override-attr GstEvent.timestamp
static PyObject *
_wrap_gst_event__get_timestamp(PyGObject *self, void *closure)
{
return PyInt_FromLong(GST_EVENT(self->obj)->timestamp);
}

View file

@ -24,6 +24,8 @@
#include "config.h"
#endif
#include "pygstminiobject.h"
#include <locale.h>
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
@ -144,9 +146,15 @@ init_gst (void)
PyDict_SetItemString(d, "LinkError", PyGstExc_LinkError);
PyGstMiniObject_Type.tp_alloc = PyType_GenericAlloc;
PyGstMiniObject_Type.tp_new = PyType_GenericNew;
pygstminiobject_register_class(d, "GstMiniObject", GST_TYPE_MINI_OBJECT,
&PyGstMiniObject_Type, NULL);
pygst_register_classes (d);
pygst_add_constants (m, "GST_");
g_timeout_add_full (0, 100, python_do_pending_calls, NULL, NULL);
if (PyErr_Occurred ()) {

View file

@ -91,6 +91,8 @@ pygstminiobject_register_class(PyObject *dict, const gchar *type_name,
class_name = s + 1;
type->ob_type = &PyType_Type;
type->tp_alloc = PyType_GenericAlloc;
type->tp_new = PyType_GenericNew;
if (bases) {
type->tp_bases = bases;
type->tp_base = (PyTypeObject *)PyTuple_GetItem(bases, 0);
@ -140,6 +142,7 @@ pygstminiobject_register_wrapper(PyObject *self)
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); */
@ -188,15 +191,14 @@ pygstminiobject_new(GstMiniObject *obj)
self = PyObject_GC_New(PyGstMiniObject, tp);
if (self == NULL)
return NULL;
pyg_begin_allow_threads;
self->obj = gst_mini_object_ref(obj);
pyg_end_allow_threads;
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);
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, */
@ -210,6 +212,8 @@ pygstminiobject_new(GstMiniObject *obj)
static void
pygstminiobject_dealloc(PyGstMiniObject *self)
{
GstMiniObject *obj = NULL;
PyGILState_STATE state;
state = pyg_gil_state_ensure();
@ -219,9 +223,8 @@ pygstminiobject_dealloc(PyGstMiniObject *self)
PyObject_GC_UnTrack((PyObject *)self);
if (self->obj) {
pyg_begin_allow_threads;
gst_mini_object_unref(self->obj);
pyg_end_allow_threads;
obj = self->obj;
}
self->obj = NULL;
@ -232,7 +235,9 @@ pygstminiobject_dealloc(PyGstMiniObject *self)
/* the following causes problems with subclassed types */
/* self->ob_type->tp_free((PyObject *)self); */
g_hash_table_remove (miniobjs, (gpointer) self);
g_hash_table_remove (miniobjs, (gpointer) obj);
if (obj)
gst_mini_object_unref(obj);
PyObject_GC_Del(self);
pyg_gil_state_release(state);
}
@ -289,9 +294,7 @@ pygstminiobject_clear(PyGstMiniObject *self)
self->inst_dict = NULL;
if (self->obj) {
pyg_begin_allow_threads;
gst_mini_object_unref(self->obj);
pyg_end_allow_threads;
}
self->obj = NULL;
@ -302,9 +305,12 @@ static void
pygstminiobject_free(PyObject *op)
{
PyGILState_STATE state;
GstMiniObject *obj = ((PyGstMiniObject*) op)->obj;
state = pyg_gil_state_ensure();
g_hash_table_remove (miniobjs, (gpointer) op);
g_hash_table_remove (miniobjs, obj);
if (obj)
gst_mini_object_unref (obj);
pyg_gil_state_release(state);
PyObject_GC_Del(op);
}
@ -402,9 +408,16 @@ pygstminiobject_get_refcount(PyGstMiniObject *self, void *closure)
return PyInt_FromLong(GST_MINI_OBJECT_REFCOUNT_VALUE(self->obj));
}
static PyObject *
pygstminiobject_get_flags(PyGstMiniObject *self, void *closure)
{
return PyInt_FromLong(GST_MINI_OBJECT_FLAGS(self->obj));
}
static PyGetSetDef pygstminiobject_getsets[] = {
{ "__dict__", (getter)pygstminiobject_get_dict, (setter)0 },
{ "__grefcount__", (getter)pygstminiobject_get_refcount, (setter)0, },
{ "flags", (getter)pygstminiobject_get_flags, (setter)0, },
{ NULL, 0, 0 }
};