gst/gstevent.override: Copy the GstStructure given as argument to gst_event_new_custo...
authorZaheer Abbas Merali <zaheermerali@gmail.com>
Mon, 9 Jul 2007 19:30:26 +0000 (19:30 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Mon, 9 Jul 2007 19:30:26 +0000 (19:30 +0000)
Original commit message from CVS:
Patch by: Zaheer Abbas Merali <zaheermerali@gmail.com>
* gst/gstevent.override:
Copy the GstStructure given as argument to gst_event_new_custom
and gst_event_new_navigation, else it would be freed when the python
object wrapping that structure goes out of scope.
Fixes #450117

ChangeLog
gst/gstevent.override

index 713f843..94500c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-09  Edward Hervey  <bilboed@bilboed.com>
+
+       Patch by: Zaheer Abbas Merali <zaheermerali@gmail.com>
+       * gst/gstevent.override:
+       Copy the GstStructure given as argument to gst_event_new_custom
+       and gst_event_new_navigation, else it would be freed when the python
+       object wrapping that structure goes out of scope.
+       Fixes #450117
+
 2007-07-05  Edward Hervey  <bilboed@bilboed.com>
 
        Patch by: Rene Stadler <mail@renestadler.de>
index ba498fc..516963f 100644 (file)
@@ -180,3 +180,58 @@ _wrap_gst_event_parse_latency (PyGstMiniObject * self)
      
      return PyLong_FromUnsignedLongLong(ctime);
 }
+%%
+override gst_event_new_navigation kwargs
+static PyObject *
+_wrap_gst_event_new_navigation(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "structure", NULL };
+    PyObject *py_structure, *py_ret;
+    GstEvent *ret;
+    GstStructure *structure = NULL;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:event_new_navigation", 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;
+    }
+    pyg_begin_allow_threads;
+    ret = gst_event_new_navigation(gst_structure_copy(structure));
+    pyg_end_allow_threads;
+    py_ret = pygstminiobject_new((GstMiniObject *)ret);
+    if (ret != NULL)
+       gst_mini_object_unref((GstMiniObject *)ret);
+    return py_ret;
+}
+%%
+override gst_event_new_custom kwargs
+static PyObject *
+_wrap_gst_event_new_custom(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "type", "structure", NULL };
+    PyObject *py_type = NULL, *py_structure, *py_ret;
+    GstEvent *ret;
+    GstStructure *structure = NULL;
+    GstEventType type;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:event_new_custom", kwlist, &py_type, &py_structure))
+        return NULL;
+    if (pyg_enum_get_value(GST_TYPE_EVENT_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;
+    }
+    pyg_begin_allow_threads;
+    ret = gst_event_new_custom(type, gst_structure_copy(structure));
+    pyg_end_allow_threads;
+    py_ret = pygstminiobject_new((GstMiniObject *)ret);
+    if (ret != NULL)
+       gst_mini_object_unref((GstMiniObject *)ret);
+    return py_ret;
+}