pyges: link against pygst and use GstMiniObject
[platform/upstream/gst-editing-services.git] / bindings / python / ges.override
1 /* -*- Mode: C; c-basic-offset: 4 -*- */
2 %%
3 headers
4 #define NO_IMPORT_PYGOBJECT
5 #include <pygobject.h>
6 #include <pygst/pygst.h>
7
8 #include <gst/gst.h>
9 #include <ges/ges.h>
10 #include <pygst/pygst.h>
11
12 #include <glib.h>
13 #include <pyglib.h>
14
15
16 #ifdef HAVE_CONFIG_H
17 # include <config.h>
18 #endif
19
20 /* Boonky define that allows for backwards compatibility with Python 2.4 */
21 #if PY_VERSION_HEX < 0x02050000
22 #define Py_ssize_t int
23 #endif
24
25 void pyges_register_classes(PyObject *d);
26 void pyges_add_constants(PyObject *module, const gchar *strip_prefix);
27
28 %%
29 import gobject.GObject as PyGObject_Type
30 import gobject.MainContext as PyGMainContext_Type
31 import gobject.GObject as PyGInitiallyUnowned_Type
32 import gst.Bin as PyGstBin_Type
33 import gst.Pipeline as PyGstPipeline_Type
34 import gst.Element as PyGstElement_Type
35 import gst.Buffer as PyGstBuffer_Type
36 import gst.Pad as PyGstPad_Type
37 import gst.pbutils.EncodingProfile as PyGstEncodingProfile_Type
38
39 %%
40 override ges_track_get_timeline kwargs
41 static PyObject *
42 _wrap_ges_track_get_timeline(PyGObject *self)
43 {
44     const GESTimeline *ret;
45
46     pyg_begin_allow_threads;
47     ret = ges_track_get_timeline(GES_TRACK(self->obj));
48     pyg_end_allow_threads;
49     /* pygobject_new handles NULL checking */
50     return pygobject_new((GObject *)ret);
51 }
52
53 %%
54 override ges_track_get_caps noargs
55 static PyObject *
56 _wrap_ges_track_get_caps(PyGObject *self, void* closure)
57 {
58     const GstCaps *ret;
59
60     ret = ges_track_get_caps(GES_TRACK(self->obj));
61
62     return pyg_boxed_new (GST_TYPE_CAPS, (GstCaps*) ret, TRUE, TRUE);
63 }
64
65 %%
66 override ges_track_set_caps kwargs
67 static PyObject *
68 _wrap_ges_track_set_caps(PyGObject *self, PyObject *args, PyObject *kwargs)
69 {
70   static char *kwlist[] = { "caps", NULL };
71   PyObject *py_caps;
72   GstCaps *caps;
73
74   if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstBuffer.set_caps", kwlist, &py_caps))
75       return NULL;
76
77   caps = pyg_boxed_get (py_caps, GstCaps);
78   if (PyErr_Occurred())
79     return NULL;
80
81   pyg_begin_allow_threads;
82   ges_track_set_caps (GES_TRACK(self->obj), caps);
83   pyg_end_allow_threads;
84   Py_INCREF(Py_None);
85   return Py_None;
86 }
87
88 %%
89 new-constructor GES_TYPE_TRACK
90 %%
91 override ges_track_new kwargs
92 static int
93 _wrap_ges_track_new(PyGObject *self, PyObject *args, PyObject *kwargs)
94 {
95     static char *kwlist[] = { "type", "caps", NULL };
96     PyObject *py_type = NULL;
97     GESTrackType type;
98     GstCaps *caps;
99     PyObject *py_caps;
100
101     if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:GES.Track.__init__", kwlist, &py_type, &py_caps))
102         return -1;
103     if (pyg_flags_get_value(GES_TYPE_TRACK_TYPE, py_type, (gpointer)&type))
104         return -1;
105     caps = pyg_boxed_get (py_caps, GstCaps);
106     self->obj = (GObject *)ges_track_new(type, caps);
107
108     if (!self->obj) {
109         PyErr_SetString(PyExc_RuntimeError, "could not create GESTrack object");
110         return -1;
111     }
112     pygobject_register_wrapper((PyObject *)self);
113     return 0;
114 }
115
116 %%
117 override ges_track_object_lookup_child kwargs
118 static PyObject *
119 _wrap_ges_track_object_lookup_child(PyGObject *self, PyObject *args, PyObject *kwargs)
120 {
121   static char *kwlist[] = {"name", NULL};
122   char *name = NULL;
123   GParamSpec *pspec;
124   GstElement *element;
125   gboolean ret;
126
127   if (!PyArg_ParseTupleAndKeywords(args, kwargs,
128       "z:GES.TrackObject.lookup_child", kwlist, &name))
129         return FALSE;
130
131   pyg_begin_allow_threads;
132   ret = ges_track_object_lookup_child (GES_TRACK_OBJECT (self->obj), name, &element, &pspec);
133   pyg_end_allow_threads;
134
135   if (!ret)
136     return PyBool_FromLong(ret);
137   return pygobject_new((GObject *)element);
138 }
139
140 %%
141 override ges_timeline_parse_launch_effect_new kwargs
142 static int
143 _wrap_ges_timeline_parse_launch_effect_new(PyGObject *self, PyObject *args, PyObject *kwargs)
144 {
145     static char *kwlist[] = { "video_bin_description", "audio_bin_description", NULL };
146     char *video_bin_description, *audio_bin_description = NULL;
147
148     if (!PyArg_ParseTupleAndKeywords(args, kwargs,"zz:GES.TimelineParseLaunchEffect.__init__", kwlist, &video_bin_description, &audio_bin_description))
149         return -1;
150     self->obj = (GObject *)ges_timeline_parse_launch_effect_new(video_bin_description, audio_bin_description);
151
152     if (!self->obj) {
153         PyErr_SetString(PyExc_RuntimeError, "could not create GESTimelineParseLaunchEffect object");
154         return -1;
155     }
156     pygobject_register_wrapper((PyObject *)self);
157     return 0;
158 }
159
160 /* I did not override ges_formatter_get_data and set_data for these functions are deprecated */
161
162 %%
163 override ges_timeline_object_get_top_effects noargs
164 static PyObject *
165 _wrap_ges_timeline_object_get_top_effects(PyGObject *self)
166 {
167     const GList *l, *list;
168     PyObject *py_list;
169
170     g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (self->obj),PyList_New(0));
171
172     pyg_begin_allow_threads;
173     list = ges_timeline_object_get_top_effects(GES_TIMELINE_OBJECT(self->obj));
174     pyg_end_allow_threads;
175
176     py_list = PyList_New(0);
177     for (l = list; l; l = l->next) {
178     GESTrackEffect *track_effect = (GESTrackEffect*)l->data;
179     PyObject *py_track_effect = pygobject_new(G_OBJECT(track_effect));
180     PyList_Append(py_list, py_track_effect);
181     Py_DECREF(py_track_effect);
182     }
183
184     return py_list;
185 }
186
187 %%
188 override ges_timeline_get_tracks noargs
189 static PyObject *
190 _wrap_ges_timeline_get_tracks(PyGObject *self)
191 {
192     const GList *l, *list;
193     PyObject *py_list;
194
195     g_return_val_if_fail (GES_IS_TIMELINE (self->obj),PyList_New(0));
196
197     pyg_begin_allow_threads;
198     list = ges_timeline_get_tracks(GES_TIMELINE(self->obj));
199     pyg_end_allow_threads;
200
201     py_list = PyList_New(0);
202     for (l = list; l; l = l->next) {
203     GESTrack *track = (GESTrack*)l->data;
204     PyObject *py_track = pygobject_new(G_OBJECT(track));
205     PyList_Append(py_list, py_track);
206     Py_DECREF(py_track);
207     }
208
209     return py_list;
210 }
211
212 %%
213 override ges_timeline_get_layers noargs
214 static PyObject *
215 _wrap_ges_timeline_get_layers(PyGObject *self)
216 {
217     const GList *l, *list;
218     PyObject *py_list;
219
220     g_return_val_if_fail (GES_IS_TIMELINE (self->obj), PyList_New(0));
221
222     pyg_begin_allow_threads;
223     list = ges_timeline_get_layers(GES_TIMELINE(self->obj));
224     pyg_end_allow_threads;
225
226     py_list = PyList_New(0);
227     for (l = list; l; l = l->next) {
228     GESTimelineLayer *layer = (GESTimelineLayer*)l->data;
229     PyObject *py_layer = pygobject_new(G_OBJECT(layer));
230     PyList_Append(py_list, py_layer);
231     Py_DECREF(py_layer);
232     }
233
234     return py_list;
235 }
236
237 %%
238 override ges_timeline_layer_get_objects noargs
239 static PyObject *
240 _wrap_ges_timeline_layer_get_objects(PyGObject *self)
241 {
242     const GList *l, *list;
243     PyObject *py_list;
244
245     g_return_val_if_fail (GES_IS_TIMELINE_LAYER (self->obj), PyList_New(0));
246
247     pyg_begin_allow_threads;
248     list = ges_timeline_layer_get_objects(GES_TIMELINE_LAYER(self->obj));
249     pyg_end_allow_threads;
250
251     py_list = PyList_New(0);
252     for (l = list; l; l = l->next) {
253     GESTimelineObject *object = (GESTimelineObject*)l->data;
254     PyObject *py_object = pygobject_new(G_OBJECT(object));
255     PyList_Append(py_list, py_object);
256     Py_DECREF(py_object);
257     }
258
259     return py_list;
260 }
261
262 %%
263 override ges_timeline_object_get_track_objects noargs
264 static PyObject *
265 _wrap_ges_timeline_object_get_track_objects(PyGObject *self)
266 {
267     const GList *l, *list;
268     PyObject *py_list;
269
270     g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (self->obj), PyList_New(0));
271
272     pyg_begin_allow_threads;
273     list = ges_timeline_object_get_track_objects(GES_TIMELINE_OBJECT(self->obj));
274     pyg_end_allow_threads;
275
276     py_list = PyList_New(0);
277     for (l = list; l; l = l->next) {
278     GESTrackObject *object = (GESTrackObject*)l->data;
279     PyObject *py_object = pygobject_new(G_OBJECT(object));
280     PyList_Append(py_list, py_object);
281     Py_DECREF(py_object);
282     }
283
284     return py_list;
285 }
286
287 %%
288 override ges_track_object_get_child_property kwargs
289 static PyObject *
290 _wrap_ges_track_object_get_child_property (PyGObject *self, PyObject *args, PyObject *kwargs)
291 {
292     gchar *property_name;
293     GESTrackObject *obj = GES_TRACK_OBJECT (self->obj);
294
295     GParamSpec *pspec = NULL;
296     GValue value = { 0, } ;
297     PyObject *ret;
298
299     if (!PyArg_ParseTuple(args, "s:GESTrackObject.get_child_property",
300                           &property_name)) {
301         return NULL;
302     }
303
304     ges_track_object_lookup_child(obj, property_name, NULL, &pspec);
305     if (!pspec) {
306         gchar buf[512];
307         g_snprintf(buf, sizeof(buf),
308                    "container does not support property `%s'",
309                    property_name);
310
311         PyErr_SetString(PyExc_TypeError, buf);
312         return NULL;
313     }
314
315     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
316
317     ges_track_object_get_child_property_by_pspec(obj,
318                                      pspec,
319                                      &value);
320
321     ret = pyg_value_as_pyobject(&value, TRUE);
322     g_value_unset(&value);
323
324     return ret;
325 }
326
327 %%
328 override ges_track_object_set_child_property kwargs
329 static PyObject *
330 _wrap_ges_track_object_set_child_property (PyGObject *self, PyObject *args, PyObject *kwargs)
331 {
332     gchar *property_name;
333     GESTrackObject *obj = GES_TRACK_OBJECT (self->obj);
334
335     GParamSpec *pspec = NULL;
336     PyGObject *pyvalue;
337     GValue value = { 0, } ;
338
339     if (!PyArg_ParseTuple(args, "sO:GESTrackObject.set_child_property",
340                           &property_name, &pyvalue)) {
341         return NULL;
342     }
343
344     ges_track_object_lookup_child(obj, property_name, NULL, &pspec);
345     if (!pspec) {
346         gchar buf[512];
347         g_snprintf(buf, sizeof(buf),
348                    "container does not support property `%s'",
349                    property_name);
350
351         PyErr_SetString(PyExc_TypeError, buf);
352         return NULL;
353     }
354
355     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
356     pyg_value_from_pyobject(&value, (PyObject*)pyvalue);
357
358     ges_track_object_set_child_property_by_pspec(obj,
359                                      pspec,
360                                      &value);
361
362     g_value_unset(&value);
363
364     Py_INCREF(Py_None);
365     return Py_None;
366 }
367
368 %%
369 override ges_track_object_list_children_properties noargs
370 static PyObject *
371 _wrap_ges_track_object_list_children_properties (PyGObject *self)
372 {
373     GParamSpec **specs;
374     PyObject *list;
375     guint nprops;
376     guint i;
377
378     specs = ges_track_object_list_children_properties(GES_TRACK_OBJECT (self->obj), &nprops);
379     list = PyTuple_New(nprops);
380     if (list == NULL) {
381       g_free(specs);
382       return NULL;
383     }
384
385     for (i = 0; i < nprops; i++) {
386       PyTuple_SetItem(list, i, pyg_param_spec_new(specs[i]));
387     }
388
389     g_free(specs);
390
391     return list;
392 }
393
394 %%
395 ignore-glob
396
397   *_get_type
398   ges_formatter_set_data
399   ges_formatter_set_data
400   *_valist
401   *_by_pspec