2004-11-23 10:16:58 +00:00
|
|
|
#include "pygobject.h"
|
|
|
|
#include "test-object.h"
|
|
|
|
|
2005-10-12 11:21:53 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
2004-11-23 10:16:58 +00:00
|
|
|
static PyObject *
|
|
|
|
_wrap_get_object (PyObject * self)
|
|
|
|
{
|
|
|
|
GObject *obj;
|
|
|
|
obj = g_object_new (TEST_TYPE_OBJECT, NULL);
|
|
|
|
if (!obj) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-12-15 13:55:07 +00:00
|
|
|
|
|
|
|
return pygobject_new (obj);
|
2004-11-23 10:16:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2018-12-15 13:55:07 +00:00
|
|
|
_wrap_emit_event (PyObject * self, PyObject * args)
|
2004-11-23 10:16:58 +00:00
|
|
|
{
|
|
|
|
PyGObject *obj;
|
|
|
|
GstEventType event_type = GST_EVENT_UNKNOWN;
|
|
|
|
GstEvent *event;
|
2018-12-15 13:55:07 +00:00
|
|
|
|
|
|
|
if (!PyArg_ParseTuple (args, "O|i", &obj, &event_type))
|
2004-11-23 10:16:58 +00:00
|
|
|
return NULL;
|
|
|
|
|
2018-12-15 13:55:07 +00:00
|
|
|
event = gst_event_new_custom (event_type, NULL);
|
|
|
|
|
|
|
|
g_signal_emit_by_name (G_OBJECT (obj->obj), "event", event);
|
2004-11-23 10:16:58 +00:00
|
|
|
|
2018-12-15 13:55:07 +00:00
|
|
|
gst_mini_object_unref (GST_MINI_OBJECT (event));
|
|
|
|
|
|
|
|
Py_INCREF (Py_None);
|
2004-11-23 10:16:58 +00:00
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef testhelper_methods[] = {
|
2018-12-15 13:55:07 +00:00
|
|
|
{"get_object", (PyCFunction) _wrap_get_object, METH_NOARGS},
|
|
|
|
{"emit_event", (PyCFunction) _wrap_emit_event, METH_VARARGS},
|
|
|
|
{NULL, NULL}
|
2004-11-23 10:16:58 +00:00
|
|
|
};
|
|
|
|
|
2018-12-15 13:55:07 +00:00
|
|
|
void
|
2004-11-23 10:16:58 +00:00
|
|
|
inittesthelper ()
|
|
|
|
{
|
|
|
|
PyObject *m, *d;
|
2018-12-15 13:55:07 +00:00
|
|
|
|
|
|
|
init_pygobject ();
|
|
|
|
gst_init (NULL, NULL);
|
2004-11-23 10:16:58 +00:00
|
|
|
|
|
|
|
m = Py_InitModule ("testhelper", testhelper_methods);
|
|
|
|
|
2018-12-15 13:55:07 +00:00
|
|
|
d = PyModule_GetDict (m);
|
2004-11-23 10:16:58 +00:00
|
|
|
}
|