timeline-object: Add TrackObject to the Track after the TimelineObject
[platform/upstream/gstreamer.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 <gst/pygst.h>
7
8 #include <gst/gst.h>
9 #include <ges/ges.h>
10 #include <gst/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_pitivi_formatter_set_sources kwargs
164 static PyObject *
165 _wrap_ges_pitivi_formatter_set_sources(PyGObject *self, PyObject *args, PyObject *kwargs)
166 {
167   GList *sources = NULL;
168   guint i;
169
170   PyObject *pylist = NULL;
171   PyGObject *tmpobj = NULL;
172   Py_ssize_t list_size;
173
174   GESPitiviFormatter *formatter = GES_PITIVI_FORMATTER (self->obj);
175
176   if (!PyArg_ParseTuple(args, "O:GESPitiviFormatter.set_sources",
177         &pylist))
178     return PyBool_FromLong(FALSE);
179
180   list_size = PyList_GET_SIZE(pylist);
181
182   for (i = 0; i < list_size; i++) {
183     tmpobj = (PyGObject*)PyList_GetItem(pylist, i);
184     sources = g_list_prepend (sources, tmpobj->obj);
185   }
186
187   return PyBool_FromLong (ges_pitivi_formatter_set_sources (formatter, sources));
188 }
189
190 %%
191 override ges_pitivi_formatter_get_sources kwargs
192 static PyObject *
193 _wrap_ges_pitivi_formatter_get_sources(PyGObject *self, PyObject *args, PyObject *kwargs)
194 {
195     const GList *l, *list;
196     PyObject *py_list;
197
198     g_return_val_if_fail (GES_IS_PITIVI_FORMATTER (self->obj),PyList_New(0));
199
200     pyg_begin_allow_threads;
201     list = ges_pitivi_formatter_get_sources (GES_PITIVI_FORMATTER (self->obj));
202     pyg_end_allow_threads;
203
204     py_list = PyList_New(0);
205     for (l = list; l; l = l->next) {
206         gchar * source = (gchar *)l->data;
207         GST_ERROR ("Adding %s", source);
208         PyList_Append(py_list, PyString_FromString(source));
209         Py_DECREF(source);
210     }
211
212     return py_list;
213 }
214
215 %%
216 override ges_timeline_object_get_top_effects noargs
217 static PyObject *
218 _wrap_ges_timeline_object_get_top_effects(PyGObject *self)
219 {
220     const GList *l, *list;
221     PyObject *py_list;
222
223     g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (self->obj),PyList_New(0));
224
225     pyg_begin_allow_threads;
226     list = ges_timeline_object_get_top_effects(GES_TIMELINE_OBJECT(self->obj));
227     pyg_end_allow_threads;
228
229     py_list = PyList_New(0);
230     for (l = list; l; l = l->next) {
231     GESTrackEffect *track_effect = (GESTrackEffect*)l->data;
232     PyObject *py_track_effect = pygobject_new(G_OBJECT(track_effect));
233     PyList_Append(py_list, py_track_effect);
234     Py_DECREF(py_track_effect);
235     }
236
237     return py_list;
238 }
239
240 %%
241 override ges_timeline_get_tracks noargs
242 static PyObject *
243 _wrap_ges_timeline_get_tracks(PyGObject *self)
244 {
245     const GList *l, *list;
246     PyObject *py_list;
247
248     g_return_val_if_fail (GES_IS_TIMELINE (self->obj),PyList_New(0));
249
250     pyg_begin_allow_threads;
251     list = ges_timeline_get_tracks(GES_TIMELINE(self->obj));
252     pyg_end_allow_threads;
253
254     py_list = PyList_New(0);
255     for (l = list; l; l = l->next) {
256     GESTrack *track = (GESTrack*)l->data;
257     PyObject *py_track = pygobject_new(G_OBJECT(track));
258     PyList_Append(py_list, py_track);
259     Py_DECREF(py_track);
260     }
261
262     return py_list;
263 }
264
265 %%
266 override ges_timeline_get_layers noargs
267 static PyObject *
268 _wrap_ges_timeline_get_layers(PyGObject *self)
269 {
270     const GList *l, *list;
271     PyObject *py_list;
272
273     g_return_val_if_fail (GES_IS_TIMELINE (self->obj), PyList_New(0));
274
275     pyg_begin_allow_threads;
276     list = ges_timeline_get_layers(GES_TIMELINE(self->obj));
277     pyg_end_allow_threads;
278
279     py_list = PyList_New(0);
280     for (l = list; l; l = l->next) {
281     GESTimelineLayer *layer = (GESTimelineLayer*)l->data;
282     PyObject *py_layer = pygobject_new(G_OBJECT(layer));
283     PyList_Append(py_list, py_layer);
284     Py_DECREF(py_layer);
285     }
286
287     return py_list;
288 }
289
290 %%
291 override ges_timeline_layer_get_objects noargs
292 static PyObject *
293 _wrap_ges_timeline_layer_get_objects(PyGObject *self)
294 {
295     const GList *l, *list;
296     PyObject *py_list;
297
298     g_return_val_if_fail (GES_IS_TIMELINE_LAYER (self->obj), PyList_New(0));
299
300     pyg_begin_allow_threads;
301     list = ges_timeline_layer_get_objects(GES_TIMELINE_LAYER(self->obj));
302     pyg_end_allow_threads;
303
304     py_list = PyList_New(0);
305     for (l = list; l; l = l->next) {
306     GESTimelineObject *object = (GESTimelineObject*)l->data;
307     PyObject *py_object = pygobject_new(G_OBJECT(object));
308     PyList_Append(py_list, py_object);
309     Py_DECREF(py_object);
310     }
311
312     return py_list;
313 }
314
315 %%
316 override ges_timeline_object_get_track_objects noargs
317 static PyObject *
318 _wrap_ges_timeline_object_get_track_objects(PyGObject *self)
319 {
320     const GList *l, *list;
321     PyObject *py_list;
322
323     g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (self->obj), PyList_New(0));
324
325     pyg_begin_allow_threads;
326     list = ges_timeline_object_get_track_objects(GES_TIMELINE_OBJECT(self->obj));
327     pyg_end_allow_threads;
328
329     py_list = PyList_New(0);
330     for (l = list; l; l = l->next) {
331     GESTrackObject *object = (GESTrackObject*)l->data;
332     PyObject *py_object = pygobject_new(G_OBJECT(object));
333     PyList_Append(py_list, py_object);
334     Py_DECREF(py_object);
335     }
336
337     return py_list;
338 }
339
340 %%
341 override ges_track_get_objects noargs
342 static PyObject *
343 _wrap_ges_track_get_objects(PyGObject *self)
344 {
345     const GList *l, *list;
346     PyObject *py_list;
347
348     g_return_val_if_fail (GES_IS_TRACK (self->obj), PyList_New(0));
349
350     pyg_begin_allow_threads;
351     list = ges_track_get_objects(GES_TRACK(self->obj));
352     pyg_end_allow_threads;
353
354     py_list = PyList_New(0);
355     for (l = list; l; l = l->next) {
356     GESTrackObject *object = (GESTrackObject*)l->data;
357     PyObject *py_object = pygobject_new(G_OBJECT(object));
358     PyList_Append(py_list, py_object);
359     Py_DECREF(py_object);
360     }
361
362     return py_list;
363 }
364
365 %%
366 override ges_track_object_get_child_property kwargs
367 static PyObject *
368 _wrap_ges_track_object_get_child_property (PyGObject *self, PyObject *args, PyObject *kwargs)
369 {
370     gchar *property_name;
371     GESTrackObject *obj = GES_TRACK_OBJECT (self->obj);
372
373     GParamSpec *pspec = NULL;
374     GValue value = { 0, } ;
375     PyObject *ret;
376
377     if (!PyArg_ParseTuple(args, "s:GESTrackObject.get_child_property",
378                           &property_name)) {
379         return NULL;
380     }
381
382     ges_track_object_lookup_child(obj, property_name, NULL, &pspec);
383     if (!pspec) {
384         gchar buf[512];
385         g_snprintf(buf, sizeof(buf),
386                    "container does not support property `%s'",
387                    property_name);
388
389         PyErr_SetString(PyExc_TypeError, buf);
390         return NULL;
391     }
392
393     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
394
395     ges_track_object_get_child_property_by_pspec(obj,
396                                      pspec,
397                                      &value);
398
399     ret = pyg_value_as_pyobject(&value, TRUE);
400     g_value_unset(&value);
401
402     return ret;
403 }
404
405 %%
406 override ges_track_object_set_child_property kwargs
407 static PyObject *
408 _wrap_ges_track_object_set_child_property (PyGObject *self, PyObject *args, PyObject *kwargs)
409 {
410     gchar *property_name;
411     GESTrackObject *obj = GES_TRACK_OBJECT (self->obj);
412
413     GParamSpec *pspec = NULL;
414     PyGObject *pyvalue;
415     GValue value = { 0, } ;
416
417     if (!PyArg_ParseTuple(args, "sO:GESTrackObject.set_child_property",
418                           &property_name, &pyvalue)) {
419         return NULL;
420     }
421
422     ges_track_object_lookup_child(obj, property_name, NULL, &pspec);
423     if (!pspec) {
424         gchar buf[512];
425         g_snprintf(buf, sizeof(buf),
426                    "container does not support property `%s'",
427                    property_name);
428
429         PyErr_SetString(PyExc_TypeError, buf);
430         return NULL;
431     }
432
433     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
434     pyg_value_from_pyobject(&value, (PyObject*)pyvalue);
435
436     ges_track_object_set_child_property_by_pspec(obj,
437                                      pspec,
438                                      &value);
439
440     g_value_unset(&value);
441
442     Py_INCREF(Py_None);
443     return Py_None;
444 }
445
446 %%
447 override ges_track_object_list_children_properties noargs
448 static PyObject *
449 _wrap_ges_track_object_list_children_properties (PyGObject *self)
450 {
451     GParamSpec **specs;
452     PyObject *list;
453     guint nprops;
454     guint i;
455
456     specs = ges_track_object_list_children_properties(GES_TRACK_OBJECT (self->obj), &nprops);
457     list = PyTuple_New(nprops);
458     if (list == NULL) {
459       g_free(specs);
460       return NULL;
461     }
462
463     for (i = 0; i < nprops; i++) {
464       PyTuple_SetItem(list, i, pyg_param_spec_new(specs[i]));
465     }
466
467     g_free(specs);
468
469     return list;
470 }
471
472 %%
473 override ges_version noargs
474 static PyObject *
475 _wrap_ges_version (PyObject *self)
476 {
477     guint       major, minor, micro, nano;
478     PyObject    *py_tuple;
479
480     ges_version (&major, &minor, &micro, &nano);
481     py_tuple = PyTuple_New(4);
482     PyTuple_SetItem(py_tuple, 0, PyInt_FromLong(major));
483     PyTuple_SetItem(py_tuple, 1, PyInt_FromLong(minor));
484     PyTuple_SetItem(py_tuple, 2, PyInt_FromLong(micro));
485     PyTuple_SetItem(py_tuple, 3, PyInt_FromLong(nano));
486
487     return py_tuple;
488 }
489
490
491 %%
492 ignore-glob
493
494   *_get_type
495   ges_formatter_set_data
496   ges_formatter_set_data
497   *_valist
498   *_by_pspec