mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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:
parent
30eeebe7d7
commit
bc47432fc8
6 changed files with 106 additions and 127 deletions
15
ChangeLog
15
ChangeLog
|
@ -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>
|
2005-07-01 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
63
gst/gst.defs
63
gst/gst.defs
|
@ -2443,6 +2443,7 @@
|
||||||
(c-name "gst_message_new_application")
|
(c-name "gst_message_new_application")
|
||||||
(return-type "GstMessage*")
|
(return-type "GstMessage*")
|
||||||
(parameters
|
(parameters
|
||||||
|
'("GstObject*" "src")
|
||||||
'("GstStructure*" "structure")
|
'("GstStructure*" "structure")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -3048,7 +3049,7 @@
|
||||||
(define-method fixate_caps
|
(define-method fixate_caps
|
||||||
(of-object "GstPad")
|
(of-object "GstPad")
|
||||||
(c-name "gst_pad_fixate_caps")
|
(c-name "gst_pad_fixate_caps")
|
||||||
(return-type "GstCaps*")
|
(return-type "none")
|
||||||
(parameters
|
(parameters
|
||||||
'("GstCaps*" "caps")
|
'("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
|
(define-function pad_load_and_link
|
||||||
(c-name "gst_pad_load_and_link")
|
(c-name "gst_pad_load_and_link")
|
||||||
(return-type "none")
|
(return-type "none")
|
||||||
|
|
|
@ -118,86 +118,6 @@ _wrap_gst_buffer_set_data(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
return Py_None;
|
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
|
override-slot GstBuffer.tp_str
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_wrap_gst_buffer_tp_str(PyGstMiniObject *self)
|
_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);
|
self = pyg_boxed_new (GST_TYPE_BUFFER, buf, FALSE, TRUE);
|
||||||
return self;
|
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
|
define GstBuffer.flag_is_set
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -19,31 +19,3 @@
|
||||||
*
|
*
|
||||||
* Author: Johan Dahlin <johan@gnome.org>
|
* 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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "pygstminiobject.h"
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||||
|
@ -144,9 +146,15 @@ init_gst (void)
|
||||||
PyDict_SetItemString(d, "LinkError", PyGstExc_LinkError);
|
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_register_classes (d);
|
||||||
pygst_add_constants (m, "GST_");
|
pygst_add_constants (m, "GST_");
|
||||||
|
|
||||||
|
|
||||||
g_timeout_add_full (0, 100, python_do_pending_calls, NULL, NULL);
|
g_timeout_add_full (0, 100, python_do_pending_calls, NULL, NULL);
|
||||||
|
|
||||||
if (PyErr_Occurred ()) {
|
if (PyErr_Occurred ()) {
|
||||||
|
|
|
@ -91,6 +91,8 @@ pygstminiobject_register_class(PyObject *dict, const gchar *type_name,
|
||||||
class_name = s + 1;
|
class_name = s + 1;
|
||||||
|
|
||||||
type->ob_type = &PyType_Type;
|
type->ob_type = &PyType_Type;
|
||||||
|
type->tp_alloc = PyType_GenericAlloc;
|
||||||
|
type->tp_new = PyType_GenericNew;
|
||||||
if (bases) {
|
if (bases) {
|
||||||
type->tp_bases = bases;
|
type->tp_bases = bases;
|
||||||
type->tp_base = (PyTypeObject *)PyTuple_GetItem(bases, 0);
|
type->tp_base = (PyTypeObject *)PyTuple_GetItem(bases, 0);
|
||||||
|
@ -140,6 +142,7 @@ pygstminiobject_register_wrapper(PyObject *self)
|
||||||
Py_INCREF(self);
|
Py_INCREF(self);
|
||||||
state = pyg_gil_state_ensure();
|
state = pyg_gil_state_ensure();
|
||||||
g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self);
|
g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self);
|
||||||
|
gst_mini_object_ref(obj);
|
||||||
pyg_gil_state_release(state);
|
pyg_gil_state_release(state);
|
||||||
/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */
|
/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */
|
||||||
/* pyg_destroy_notify); */
|
/* pyg_destroy_notify); */
|
||||||
|
@ -188,15 +191,14 @@ pygstminiobject_new(GstMiniObject *obj)
|
||||||
self = PyObject_GC_New(PyGstMiniObject, tp);
|
self = PyObject_GC_New(PyGstMiniObject, tp);
|
||||||
if (self == NULL)
|
if (self == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
pyg_begin_allow_threads;
|
|
||||||
self->obj = gst_mini_object_ref(obj);
|
self->obj = gst_mini_object_ref(obj);
|
||||||
pyg_end_allow_threads;
|
|
||||||
|
|
||||||
self->inst_dict = NULL;
|
self->inst_dict = NULL;
|
||||||
self->weakreflist = NULL;
|
self->weakreflist = NULL;
|
||||||
/* save wrapper pointer so we can access it later */
|
/* save wrapper pointer so we can access it later */
|
||||||
Py_INCREF(self);
|
Py_INCREF(self);
|
||||||
state = pyg_gil_state_ensure();
|
state = pyg_gil_state_ensure();
|
||||||
|
gst_mini_object_ref(obj);
|
||||||
g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self);
|
g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self);
|
||||||
pyg_gil_state_release(state);
|
pyg_gil_state_release(state);
|
||||||
/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */
|
/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */
|
||||||
|
@ -210,6 +212,8 @@ pygstminiobject_new(GstMiniObject *obj)
|
||||||
static void
|
static void
|
||||||
pygstminiobject_dealloc(PyGstMiniObject *self)
|
pygstminiobject_dealloc(PyGstMiniObject *self)
|
||||||
{
|
{
|
||||||
|
GstMiniObject *obj = NULL;
|
||||||
|
|
||||||
PyGILState_STATE state;
|
PyGILState_STATE state;
|
||||||
|
|
||||||
state = pyg_gil_state_ensure();
|
state = pyg_gil_state_ensure();
|
||||||
|
@ -219,9 +223,8 @@ pygstminiobject_dealloc(PyGstMiniObject *self)
|
||||||
PyObject_GC_UnTrack((PyObject *)self);
|
PyObject_GC_UnTrack((PyObject *)self);
|
||||||
|
|
||||||
if (self->obj) {
|
if (self->obj) {
|
||||||
pyg_begin_allow_threads;
|
|
||||||
gst_mini_object_unref(self->obj);
|
gst_mini_object_unref(self->obj);
|
||||||
pyg_end_allow_threads;
|
obj = self->obj;
|
||||||
}
|
}
|
||||||
self->obj = NULL;
|
self->obj = NULL;
|
||||||
|
|
||||||
|
@ -232,7 +235,9 @@ pygstminiobject_dealloc(PyGstMiniObject *self)
|
||||||
|
|
||||||
/* the following causes problems with subclassed types */
|
/* the following causes problems with subclassed types */
|
||||||
/* self->ob_type->tp_free((PyObject *)self); */
|
/* 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);
|
PyObject_GC_Del(self);
|
||||||
pyg_gil_state_release(state);
|
pyg_gil_state_release(state);
|
||||||
}
|
}
|
||||||
|
@ -289,9 +294,7 @@ pygstminiobject_clear(PyGstMiniObject *self)
|
||||||
self->inst_dict = NULL;
|
self->inst_dict = NULL;
|
||||||
|
|
||||||
if (self->obj) {
|
if (self->obj) {
|
||||||
pyg_begin_allow_threads;
|
|
||||||
gst_mini_object_unref(self->obj);
|
gst_mini_object_unref(self->obj);
|
||||||
pyg_end_allow_threads;
|
|
||||||
}
|
}
|
||||||
self->obj = NULL;
|
self->obj = NULL;
|
||||||
|
|
||||||
|
@ -302,9 +305,12 @@ static void
|
||||||
pygstminiobject_free(PyObject *op)
|
pygstminiobject_free(PyObject *op)
|
||||||
{
|
{
|
||||||
PyGILState_STATE state;
|
PyGILState_STATE state;
|
||||||
|
GstMiniObject *obj = ((PyGstMiniObject*) op)->obj;
|
||||||
|
|
||||||
state = pyg_gil_state_ensure();
|
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);
|
pyg_gil_state_release(state);
|
||||||
PyObject_GC_Del(op);
|
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));
|
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[] = {
|
static PyGetSetDef pygstminiobject_getsets[] = {
|
||||||
{ "__dict__", (getter)pygstminiobject_get_dict, (setter)0 },
|
{ "__dict__", (getter)pygstminiobject_get_dict, (setter)0 },
|
||||||
{ "__grefcount__", (getter)pygstminiobject_get_refcount, (setter)0, },
|
{ "__grefcount__", (getter)pygstminiobject_get_refcount, (setter)0, },
|
||||||
|
{ "flags", (getter)pygstminiobject_get_flags, (setter)0, },
|
||||||
{ NULL, 0, 0 }
|
{ NULL, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue