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