video-transition: Make smpte props children properties
[platform/upstream/gst-editing-services.git] / ges / ges-video-transition.c
1 /* GStreamer Editing Services
2  * Copyright (C) 2010 Brandon Lewis <brandon.lewis@collabora.co.uk>
3  *               2010 Nokia Corporation
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 /**
22  * SECTION:gesvideotransition
23  * @title: GESVideoTransition
24  * @short_description: implements video crossfade transition
25  */
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <ges/ges.h>
31 #include "ges-internal.h"
32 #include "ges-smart-video-mixer.h"
33
34 #include <gst/controller/gstdirectcontrolbinding.h>
35
36 #define parent_class ges_video_transition_parent_class
37
38 static inline void
39 ges_video_transition_set_border_internal (GESVideoTransition * self,
40     guint border);
41 static inline void
42 ges_video_transition_set_inverted_internal (GESVideoTransition *
43     self, gboolean inverted);
44 static inline gboolean
45 ges_video_transition_set_transition_type_internal (GESVideoTransition
46     * self, GESVideoStandardTransitionType type);
47 struct _GESVideoTransitionPrivate
48 {
49   GESVideoStandardTransitionType type;
50
51   /* prevents cases where the transitions have not been created yet */
52   GESVideoStandardTransitionType pending_type;
53
54   /* these enable video interpolation */
55   GstTimedValueControlSource *fade_in_control_source;
56   GstTimedValueControlSource *fade_out_control_source;
57   GstTimedValueControlSource *smpte_control_source;
58
59   /* so we can support changing between wipes */
60   GstElement *smpte;
61
62   GstPad *mixer_sink;
63
64   GstElement *mixer;
65   GstPad *mixer_sinka;
66   GstPad *mixer_sinkb;
67
68   GstPad *mixer_ghosta;
69   GstPad *mixer_ghostb;
70
71   /* This is in case the smpte doesn't exist yet */
72   gint pending_border_value;
73   gboolean pending_inverted;
74
75   GstElement *positioner;
76 };
77
78 enum
79 {
80   PROP_0,
81   PROP_BORDER,
82   PROP_TRANSITION_TYPE,
83   PROP_INVERT,
84   PROP_LAST
85 };
86
87 static GParamSpec *properties[PROP_LAST];
88
89 G_DEFINE_TYPE_WITH_PRIVATE (GESVideoTransition, ges_video_transition,
90     GES_TYPE_TRANSITION);
91
92 #define fast_element_link(a,b) gst_element_link_pads_full((a),"src",(b),"sink",GST_PAD_LINK_CHECK_NOTHING)
93
94 static GObject *link_element_to_mixer_with_smpte (GstBin * bin,
95     GstElement * element, GstElement * mixer, gint type,
96     GstElement ** smpteref, GESVideoTransitionPrivate * priv, GstPad ** ghost);
97
98 static void
99 ges_video_transition_duration_changed (GESTrackElement * self,
100     guint64 duration);
101
102 static GstElement *ges_video_transition_create_element (GESTrackElement * self);
103
104 static void ges_video_transition_dispose (GObject * object);
105
106 static void ges_video_transition_finalize (GObject * object);
107
108 static void ges_video_transition_get_property (GObject * object, guint
109     property_id, GValue * value, GParamSpec * pspec);
110
111 static void ges_video_transition_set_property (GObject * object, guint
112     property_id, const GValue * value, GParamSpec * pspec);
113
114 static void
115 duration_changed_cb (GESTrackElement * self, GParamSpec * arg G_GNUC_UNUSED)
116 {
117   ges_video_transition_duration_changed (self,
118       ges_timeline_element_get_duration (GES_TIMELINE_ELEMENT (self)));
119 }
120
121 static gboolean
122 _set_priority (GESTimelineElement * element, guint32 priority)
123 {
124   gboolean res;
125   GESVideoTransition *self = GES_VIDEO_TRANSITION (element);
126
127   res = GES_TIMELINE_ELEMENT_CLASS (parent_class)->set_priority (element,
128       priority);
129
130   if (res && self->priv->positioner)
131     g_object_set (self->priv->positioner, "zorder", G_MAXUINT - priority, NULL);
132
133   return res;
134 }
135
136 static void
137 ges_video_transition_class_init (GESVideoTransitionClass * klass)
138 {
139   GObjectClass *object_class;
140   GESTrackElementClass *toclass;
141   GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
142   GESTrackElementClass *track_element_class = GES_TRACK_ELEMENT_CLASS (klass);
143
144   object_class = G_OBJECT_CLASS (klass);
145
146   object_class->get_property = ges_video_transition_get_property;
147   object_class->set_property = ges_video_transition_set_property;
148   object_class->dispose = ges_video_transition_dispose;
149   object_class->finalize = ges_video_transition_finalize;
150
151   track_element_class->ABI.abi.default_track_type = GES_TRACK_TYPE_VIDEO;
152
153   /**
154    * GESVideoTransition:border:
155    *
156    * This value represents the border width of the transition.
157    *
158    */
159   properties[PROP_BORDER] =
160       g_param_spec_uint ("border", "Border", "The border width", 0,
161       G_MAXUINT, 0, G_PARAM_READWRITE);
162   g_object_class_install_property (object_class, PROP_BORDER,
163       properties[PROP_BORDER]);
164
165   /**
166    * GESVideoTransition:type:
167    *
168    * The #GESVideoStandardTransitionType currently applied on the object
169    *
170    * Deprecated:1.20: Use ges_timeline_element_[sg]et_child_property instead.
171    */
172   properties[PROP_TRANSITION_TYPE] =
173       g_param_spec_enum ("transition-type", "Transition type",
174       "The type of the transition", GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE,
175       GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE, G_PARAM_READWRITE);
176   g_object_class_install_property (object_class, PROP_TRANSITION_TYPE,
177       properties[PROP_TRANSITION_TYPE]);
178
179   /**
180    * GESVideoTransition:invert:
181    *
182    * This value represents the direction of the transition.
183    *
184     * Deprecated:1.20: Use ges_timeline_element_[sg]et_child_property instead.
185    */
186   properties[PROP_INVERT] =
187       g_param_spec_boolean ("invert", "Invert",
188       "Whether the transition is inverted", FALSE, G_PARAM_READWRITE);
189   g_object_class_install_property (object_class, PROP_INVERT,
190       properties[PROP_INVERT]);
191
192   toclass = GES_TRACK_ELEMENT_CLASS (klass);
193   toclass->create_element = ges_video_transition_create_element;
194
195   element_class->set_priority = _set_priority;
196 }
197
198 static void
199 ges_video_transition_init (GESVideoTransition * self)
200 {
201   self->priv = ges_video_transition_get_instance_private (self);
202
203   self->priv->fade_in_control_source = NULL;
204   self->priv->fade_out_control_source = NULL;
205   self->priv->smpte_control_source = NULL;
206   self->priv->smpte = NULL;
207   self->priv->mixer_sink = NULL;
208   self->priv->mixer = NULL;
209   self->priv->mixer_sinka = NULL;
210   self->priv->mixer_sinkb = NULL;
211   self->priv->pending_type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
212   self->priv->pending_border_value = 0;
213   self->priv->pending_inverted = TRUE;
214 }
215
216 static void
217 ges_video_transition_release_mixer (GESVideoTransition * self)
218 {
219   GESVideoTransitionPrivate *priv = self->priv;
220
221   if (priv->mixer_ghosta && priv->mixer_ghostb) {
222     gst_element_release_request_pad (priv->mixer, priv->mixer_ghosta);
223     gst_element_release_request_pad (priv->mixer, priv->mixer_ghostb);
224     gst_clear_object (&priv->mixer_ghosta);
225     gst_clear_object (&priv->mixer_ghostb);
226   }
227
228   gst_clear_object (&priv->mixer_sinka);
229   gst_clear_object (&priv->mixer_sinkb);
230   gst_clear_object (&priv->mixer);
231 }
232
233 static void
234 ges_video_transition_dispose (GObject * object)
235 {
236   GESVideoTransition *self = GES_VIDEO_TRANSITION (object);
237   GESVideoTransitionPrivate *priv = self->priv;
238
239   GST_DEBUG ("disposing");
240
241   if (priv->fade_in_control_source) {
242     gst_object_unref (priv->fade_in_control_source);
243     priv->fade_in_control_source = NULL;
244   }
245
246   if (priv->fade_out_control_source) {
247     gst_object_unref (priv->fade_out_control_source);
248     priv->fade_out_control_source = NULL;
249   }
250
251   if (priv->smpte_control_source) {
252     gst_object_unref (priv->smpte_control_source);
253     priv->smpte_control_source = NULL;
254   }
255
256   ges_video_transition_release_mixer (self);
257
258   g_signal_handlers_disconnect_by_func (GES_TRACK_ELEMENT (self),
259       duration_changed_cb, NULL);
260
261   G_OBJECT_CLASS (ges_video_transition_parent_class)->dispose (object);
262 }
263
264 static void
265 ges_video_transition_finalize (GObject * object)
266 {
267   G_OBJECT_CLASS (ges_video_transition_parent_class)->finalize (object);
268 }
269
270 static void
271 ges_video_transition_get_property (GObject * object,
272     guint property_id, GValue * value, GParamSpec * pspec)
273 {
274   GESVideoTransition *tr = GES_VIDEO_TRANSITION (object);
275
276   switch (property_id) {
277     case PROP_BORDER:
278       g_value_set_uint (value, ges_video_transition_get_border (tr));
279       break;
280     case PROP_TRANSITION_TYPE:
281       g_value_set_enum (value, ges_video_transition_get_transition_type (tr));
282       break;
283     case PROP_INVERT:
284       g_value_set_boolean (value, ges_video_transition_is_inverted (tr));
285       break;
286     default:
287       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
288   }
289 }
290
291 static void
292 ges_video_transition_set_property (GObject * object,
293     guint property_id, const GValue * value, GParamSpec * pspec)
294 {
295   GESVideoTransition *tr = GES_VIDEO_TRANSITION (object);
296
297   switch (property_id) {
298     case PROP_BORDER:
299       ges_video_transition_set_border_internal (tr, g_value_get_uint (value));
300       break;
301     case PROP_TRANSITION_TYPE:
302       ges_video_transition_set_transition_type_internal (tr,
303           g_value_get_enum (value));
304       break;
305     case PROP_INVERT:
306       ges_video_transition_set_inverted_internal (tr,
307           g_value_get_boolean (value));
308       break;
309     default:
310       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
311   }
312 }
313
314 static GstTimedValueControlSource *
315 set_interpolation (GstObject * element, GESVideoTransitionPrivate * priv,
316     const gchar * propname)
317 {
318   GstControlSource *control_source;
319
320   g_object_set (element, propname, (gfloat) 0.0, NULL);
321
322   control_source = gst_interpolation_control_source_new ();
323   gst_object_add_control_binding (GST_OBJECT (element),
324       gst_direct_control_binding_new (GST_OBJECT (element), propname,
325           control_source));
326   g_object_set (control_source, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
327
328   return GST_TIMED_VALUE_CONTROL_SOURCE (control_source);
329 }
330
331 static GstElement *
332 ges_video_transition_create_element (GESTrackElement * object)
333 {
334   GstElement *topbin, *iconva, *iconvb;
335   GstElement *mixer = NULL;
336   GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src;
337   GESVideoTransition *self;
338   GESVideoTransitionPrivate *priv;
339   const gchar *smpte_properties[] = { "invert", "border", NULL };
340
341   self = GES_VIDEO_TRANSITION (object);
342   priv = self->priv;
343
344   GST_LOG ("creating a video bin");
345
346   topbin = gst_bin_new ("transition-bin");
347
348   iconva = gst_element_factory_make ("videoconvert", "tr-csp-a");
349   iconvb = gst_element_factory_make ("videoconvert", "tr-csp-b");
350   priv->positioner =
351       gst_element_factory_make ("framepositioner", "frame_tagger");
352   g_object_set (priv->positioner, "zorder",
353       G_MAXUINT - GES_TIMELINE_ELEMENT_PRIORITY (self), NULL);
354
355   gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, priv->positioner, NULL);
356
357   mixer =
358       g_object_new (GES_TYPE_SMART_MIXER, "name",
359       GES_TIMELINE_ELEMENT_NAME (object), NULL);
360   GES_SMART_MIXER (mixer)->is_transition = TRUE;
361   gst_util_set_object_arg (G_OBJECT (GES_SMART_MIXER (mixer)->mixer),
362       "background", "transparent");
363   gst_bin_add (GST_BIN (topbin), mixer);
364
365   priv->mixer_sinka =
366       (GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva,
367       mixer, GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_LR, NULL, priv,
368       &priv->mixer_ghosta);
369   priv->mixer_sinkb =
370       (GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb,
371       mixer, GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_LR, &priv->smpte,
372       priv, &priv->mixer_ghostb);
373   g_object_set (priv->mixer_sinka, "zorder", 0, NULL);
374   g_object_set (priv->mixer_sinkb, "zorder", 1, NULL);
375   gst_util_set_object_arg (G_OBJECT (priv->mixer_sinka), "operator",
376       priv->type ==
377       GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE ? "source" : "over");
378   gst_util_set_object_arg (G_OBJECT (priv->mixer_sinkb), "operator",
379       priv->type ==
380       GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE ? "add" : "over");
381
382   fast_element_link (mixer, priv->positioner);
383
384   sinka_target = gst_element_get_static_pad (iconva, "sink");
385   sinkb_target = gst_element_get_static_pad (iconvb, "sink");
386   src_target = gst_element_get_static_pad (priv->positioner, "src");
387
388   sinka = gst_ghost_pad_new ("sinka", sinka_target);
389   sinkb = gst_ghost_pad_new ("sinkb", sinkb_target);
390   src = gst_ghost_pad_new ("src", src_target);
391
392   gst_element_add_pad (topbin, src);
393   gst_element_add_pad (topbin, sinka);
394   gst_element_add_pad (topbin, sinkb);
395
396   gst_object_unref (sinka_target);
397   gst_object_unref (sinkb_target);
398   gst_object_unref (src_target);
399
400   /* set up interpolation */
401
402   priv->fade_out_control_source =
403       set_interpolation (GST_OBJECT (priv->mixer_ghosta), priv, "alpha");
404   priv->fade_in_control_source =
405       set_interpolation (GST_OBJECT (priv->mixer_ghostb), priv, "alpha");
406   priv->smpte_control_source =
407       set_interpolation (GST_OBJECT (priv->smpte), priv, "position");
408   priv->mixer = gst_object_ref (mixer);
409
410   if (priv->pending_type)
411     ges_video_transition_set_transition_type_internal (self,
412         priv->pending_type);
413   else
414     ges_video_transition_set_transition_type_internal (self, priv->type);
415
416   ges_video_transition_duration_changed (object,
417       ges_timeline_element_get_duration (GES_TIMELINE_ELEMENT (object)));
418
419   g_signal_connect (object, "notify::duration",
420       G_CALLBACK (duration_changed_cb), NULL);
421
422   priv->pending_type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
423
424   ges_track_element_add_children_props (GES_TRACK_ELEMENT (self),
425       priv->smpte, NULL, NULL, smpte_properties);
426
427   return topbin;
428 }
429
430 static GObject *
431 link_element_to_mixer_with_smpte (GstBin * bin, GstElement * element,
432     GstElement * mixer, gint type, GstElement ** smpteref,
433     GESVideoTransitionPrivate * priv, GstPad ** ghost)
434 {
435   GstPad *srcpad, *mixerpad;
436   GstElement *smptealpha = gst_element_factory_make ("smptealpha", NULL);
437
438   g_object_set (G_OBJECT (smptealpha),
439       "type", (gint) type, "invert", (gboolean) priv->pending_inverted,
440       "border", priv->pending_border_value, NULL);
441   gst_bin_add (bin, smptealpha);
442
443   fast_element_link (element, smptealpha);
444
445   /* crack */
446   if (smpteref) {
447     *smpteref = smptealpha;
448   }
449
450   srcpad = gst_element_get_static_pad (smptealpha, "src");
451   *ghost = ges_smart_mixer_get_mixer_pad (GES_SMART_MIXER (mixer), &mixerpad);
452   gst_pad_link_full (srcpad, *ghost, GST_PAD_LINK_CHECK_NOTHING);
453   gst_object_unref (srcpad);
454
455   return G_OBJECT (mixerpad);
456 }
457
458 static void
459 ges_video_transition_update_control_source (GstTimedValueControlSource * ts,
460     guint64 duration, gdouble start_value, gdouble end_value)
461 {
462   gst_timed_value_control_source_unset_all (ts);
463   gst_timed_value_control_source_set (ts, 0, start_value);
464   gst_timed_value_control_source_set (ts, duration, end_value);
465 }
466
467 static void
468 ges_video_transition_update_control_sources (GESVideoTransition * self,
469     GESVideoStandardTransitionType type)
470 {
471   GESVideoTransitionPrivate *priv = self->priv;
472   guint64 duration =
473       ges_timeline_element_get_duration (GES_TIMELINE_ELEMENT (self));
474
475   GST_LOG ("updating controller");
476   if (type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
477     ges_video_transition_update_control_source
478         (priv->fade_in_control_source, duration, 0.0, 1.0);
479     ges_video_transition_update_control_source
480         (priv->fade_out_control_source, duration, 1.0, 0.0);
481     ges_video_transition_update_control_source (priv->smpte_control_source,
482         duration, 0.0, 0.0);
483   } else {
484     ges_video_transition_update_control_source
485         (priv->fade_in_control_source, duration, 1.0, 1.0);
486     ges_video_transition_update_control_source
487         (priv->fade_out_control_source, duration, 1.0, 1.0);
488     ges_video_transition_update_control_source (priv->smpte_control_source,
489         duration, 1.0, 0.0);
490   }
491   GST_LOG ("done updating controller");
492 }
493
494 static void
495 ges_video_transition_duration_changed (GESTrackElement * object,
496     guint64 duration)
497 {
498   GESVideoTransition *self = GES_VIDEO_TRANSITION (object);
499
500   ges_video_transition_update_control_sources (self, self->priv->type);
501 }
502
503 static inline void
504 ges_video_transition_set_border_internal (GESVideoTransition * self,
505     guint value)
506 {
507   GESVideoTransitionPrivate *priv = self->priv;
508
509   if (!priv->smpte) {
510     priv->pending_border_value = value;
511     return;
512   }
513   g_object_set (priv->smpte, "border", value, NULL);
514 }
515
516 static inline void
517 ges_video_transition_set_inverted_internal (GESVideoTransition *
518     self, gboolean inverted)
519 {
520   GESVideoTransitionPrivate *priv = self->priv;
521
522   if (!priv->smpte) {
523     priv->pending_inverted = !inverted;
524     return;
525   }
526   g_object_set (priv->smpte, "invert", !inverted, NULL);
527 }
528
529 static inline gboolean
530 ges_video_transition_set_transition_type_internal (GESVideoTransition
531     * self, GESVideoStandardTransitionType type)
532 {
533   GESVideoTransitionPrivate *priv = self->priv;
534
535   GST_DEBUG ("%p %d => %d", self, priv->type, type);
536
537   if (!priv->mixer) {
538     priv->pending_type = type;
539     return TRUE;
540   }
541
542   if (type == priv->type) {
543     GST_DEBUG ("%d type is already set on this transition\n", type);
544     return TRUE;
545   }
546
547   ges_video_transition_update_control_sources (self, type);
548
549   priv->type = type;
550
551   if (type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
552     g_object_set (priv->smpte, "type", (gint) type, NULL);
553   }
554
555   gst_util_set_object_arg (G_OBJECT (priv->mixer_sinka), "operator",
556       priv->type ==
557       GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE ? "source" : "over");
558   gst_util_set_object_arg (G_OBJECT (priv->mixer_sinkb), "operator",
559       priv->type ==
560       GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE ? "add" : "over");
561
562   return TRUE;
563 }
564
565 /**
566  * ges_video_transition_set_border:
567  * @self: The #GESVideoTransition to set the border to
568  * @value: The value of the border to set on @object
569  *
570  * Set the border property of @self, this value represents
571  * the border width of the transition. In case this value does
572  * not make sense for the current transition type, it is cached
573  * for later use.
574  *
575  * Deprecated:1.20: Use ges_timeline_element_set_child_property instead.
576  */
577 void
578 ges_video_transition_set_border (GESVideoTransition * self, guint value)
579 {
580   ges_video_transition_set_border_internal (self, value);
581
582   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BORDER]);
583 }
584
585 /**
586  * ges_video_transition_get_border:
587  * @self: The #GESVideoTransition to get the border from
588  *
589  * Get the border property of @self, this value represents
590  * the border width of the transition.
591  *
592  * Returns: The border values of @self or -1 if not meaningful
593  * (this will happen when not using a smpte transition).
594  *
595  * Deprecated:1.20: Use ges_timeline_element_get_child_property instead.
596  */
597 gint
598 ges_video_transition_get_border (GESVideoTransition * self)
599 {
600   gint value;
601
602   if (!self->priv->smpte) {
603     return -1;
604   }
605
606   g_object_get (self->priv->smpte, "border", &value, NULL);
607
608   return value;
609 }
610
611 /**
612  * ges_video_transition_set_inverted:
613  * @self: The #GESVideoTransition to set invert on
614  * @inverted: %TRUE if the transition should be inverted %FALSE otherwise
615  *
616  * Set the invert property of @self, this value represents
617  * the direction of the transition. In case this value does
618  * not make sense for the current transition type, it is cached
619  * for later use.
620  *
621  * Deprecated:1.20: Use ges_timeline_element_set_child_property instead.
622  */
623 void
624 ges_video_transition_set_inverted (GESVideoTransition * self, gboolean inverted)
625 {
626   ges_video_transition_set_inverted_internal (self, inverted);
627
628   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INVERT]);
629 }
630
631 /**
632  * ges_video_transition_is_inverted:
633  * @self: The #GESVideoTransition to get the inversion from
634  *
635  * Get the invert property of @self, this value represents
636  * the direction of the transition.
637  *
638  * Returns: The invert value of @self
639  *
640  * Deprecated:1.20: Use ges_timeline_element_get_child_property instead.
641  */
642 gboolean
643 ges_video_transition_is_inverted (GESVideoTransition * self)
644 {
645   gboolean inverted;
646
647   if (!self->priv->smpte) {
648     return FALSE;
649   }
650
651   g_object_get (self->priv->smpte, "invert", &inverted, NULL);
652
653   return !inverted;
654 }
655
656 /**
657  * ges_video_transition_set_transition_type:
658  * @self: a #GESVideoTransition
659  * @type: a #GESVideoStandardTransitionType
660  *
661  * Sets the transition being used to @type.
662  *
663  * Returns: %TRUE if the transition type was properly changed, else %FALSE.
664  */
665 gboolean
666 ges_video_transition_set_transition_type (GESVideoTransition * self,
667     GESVideoStandardTransitionType type)
668 {
669   gboolean ret = ges_video_transition_set_transition_type_internal (self, type);
670
671   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TRANSITION_TYPE]);
672
673   return ret;
674 }
675
676 /**
677  * ges_video_transition_get_transition_type:
678  * @trans: a #GESVideoTransition
679  *
680  * Get the transition type used by @trans.
681  *
682  * Returns: The transition type used by @trans.
683  */
684 GESVideoStandardTransitionType
685 ges_video_transition_get_transition_type (GESVideoTransition * trans)
686 {
687   if (trans->priv->pending_type)
688     return trans->priv->pending_type;
689   return trans->priv->type;
690 }
691
692 /* ges_video_transition_new:
693  *
694  * Creates a new #GESVideoTransition.
695  *
696  * Returns: (transfer floating) (nullable): The newly created
697  * #GESVideoTransition, or %NULL if there was an error.
698  */
699 GESVideoTransition *
700 ges_video_transition_new (void)
701 {
702   GESVideoTransition *res;
703   GESAsset *asset = ges_asset_request (GES_TYPE_VIDEO_TRANSITION, NULL, NULL);
704
705   res = GES_VIDEO_TRANSITION (ges_asset_extract (asset, NULL));
706   gst_object_unref (asset);
707
708   return res;
709 }