2010-06-18 09:24:07 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2010 Brandon Lewis <brandon.lewis@collabora.co.uk>
|
|
|
|
* 2010 Nokia Corporation
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-06-18 09:24:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:gesvideotransition
|
2010-07-01 14:48:45 +00:00
|
|
|
* @short_description: implements video crossfade transition
|
2010-06-18 09:24:07 +00:00
|
|
|
*/
|
|
|
|
|
2010-12-09 16:09:11 +00:00
|
|
|
#include <ges/ges.h>
|
2010-06-18 09:24:07 +00:00
|
|
|
#include "ges-internal.h"
|
|
|
|
|
2012-02-10 19:01:03 +00:00
|
|
|
#include <gst/controller/gstdirectcontrolbinding.h>
|
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
G_DEFINE_TYPE (GESVideoTransition, ges_video_transition, GES_TYPE_TRANSITION);
|
2010-06-18 09:24:07 +00:00
|
|
|
|
2012-05-03 03:44:31 +00:00
|
|
|
static inline void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_border_internal (GESVideoTransition * self,
|
2012-05-03 03:44:31 +00:00
|
|
|
guint border);
|
|
|
|
static inline void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_inverted_internal (GESVideoTransition *
|
2012-05-03 03:44:31 +00:00
|
|
|
self, gboolean inverted);
|
2012-05-03 03:43:50 +00:00
|
|
|
static inline gboolean
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_transition_type_internal (GESVideoTransition
|
2012-05-03 03:43:50 +00:00
|
|
|
* self, GESVideoStandardTransitionType type);
|
2013-01-27 15:41:51 +00:00
|
|
|
struct _GESVideoTransitionPrivate
|
2010-12-04 18:54:13 +00:00
|
|
|
{
|
2011-01-06 09:55:37 +00:00
|
|
|
GESVideoStandardTransitionType type;
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
/* prevents cases where the transitions have not been created yet */
|
2012-05-01 23:08:08 +00:00
|
|
|
GESVideoStandardTransitionType pending_type;
|
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
/* these enable video interpolation */
|
2013-08-29 21:45:56 +00:00
|
|
|
GstTimedValueControlSource *crossfade_control_source;
|
|
|
|
GstTimedValueControlSource *smpte_control_source;
|
2011-01-06 09:55:37 +00:00
|
|
|
|
|
|
|
/* so we can support changing between wipes */
|
|
|
|
GstElement *smpte;
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
GstPad *mixer_sink;
|
|
|
|
|
|
|
|
GstElement *mixer;
|
|
|
|
GstPad *mixer_sinka;
|
|
|
|
GstPad *mixer_sinkb;
|
2012-05-01 23:08:08 +00:00
|
|
|
|
2012-05-01 23:09:07 +00:00
|
|
|
/* This is in case the smpte doesn't exist yet */
|
|
|
|
gint pending_border_value;
|
2012-05-03 00:28:41 +00:00
|
|
|
gboolean pending_inverted;
|
2010-12-04 18:54:13 +00:00
|
|
|
};
|
|
|
|
|
2010-06-18 09:24:07 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2012-05-03 01:35:16 +00:00
|
|
|
PROP_BORDER,
|
2012-05-03 03:43:50 +00:00
|
|
|
PROP_TRANSITION_TYPE,
|
2012-05-03 01:35:16 +00:00
|
|
|
PROP_INVERT,
|
|
|
|
PROP_LAST
|
2010-06-18 09:24:07 +00:00
|
|
|
};
|
|
|
|
|
2012-05-03 01:35:16 +00:00
|
|
|
static GParamSpec *properties[PROP_LAST];
|
|
|
|
|
2010-07-14 11:29:23 +00:00
|
|
|
#define fast_element_link(a,b) gst_element_link_pads_full((a),"src",(b),"sink",GST_PAD_LINK_CHECK_NOTHING)
|
|
|
|
|
2010-06-18 13:54:37 +00:00
|
|
|
static GObject *link_element_to_mixer_with_smpte (GstBin * bin,
|
|
|
|
GstElement * element, GstElement * mixer, gint type,
|
2013-08-29 21:45:56 +00:00
|
|
|
GstElement ** smpteref, GESVideoTransitionPrivate * priv);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_duration_changed (GESTrackElement * self,
|
2010-07-08 11:20:56 +00:00
|
|
|
guint64 duration);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
static GstElement *ges_video_transition_create_element (GESTrackElement * self);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
static void ges_video_transition_dispose (GObject * object);
|
2010-06-18 09:24:07 +00:00
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
static void ges_video_transition_finalize (GObject * object);
|
2010-06-18 09:24:07 +00:00
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
static void ges_video_transition_get_property (GObject * object, guint
|
2010-06-18 09:24:07 +00:00
|
|
|
property_id, GValue * value, GParamSpec * pspec);
|
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
static void ges_video_transition_set_property (GObject * object, guint
|
2010-06-18 09:24:07 +00:00
|
|
|
property_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
|
2013-07-01 21:33:01 +00:00
|
|
|
static void
|
|
|
|
duration_changed_cb (GESTrackElement * self, GParamSpec * arg G_GNUC_UNUSED)
|
|
|
|
{
|
|
|
|
ges_video_transition_duration_changed (self,
|
|
|
|
ges_timeline_element_get_duration (GES_TIMELINE_ELEMENT (self)));
|
|
|
|
}
|
|
|
|
|
2010-06-18 09:24:07 +00:00
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_class_init (GESVideoTransitionClass * klass)
|
2010-06-18 09:24:07 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementClass *toclass;
|
2010-06-18 09:24:07 +00:00
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GESVideoTransitionPrivate));
|
2010-12-04 18:54:13 +00:00
|
|
|
|
2010-06-18 09:24:07 +00:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
object_class->get_property = ges_video_transition_get_property;
|
|
|
|
object_class->set_property = ges_video_transition_set_property;
|
|
|
|
object_class->dispose = ges_video_transition_dispose;
|
|
|
|
object_class->finalize = ges_video_transition_finalize;
|
2010-06-18 09:24:07 +00:00
|
|
|
|
2012-05-03 01:35:16 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* GESVideoTransition:border:
|
2012-05-03 01:35:16 +00:00
|
|
|
*
|
|
|
|
* This value represents the border width of the transition.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
properties[PROP_BORDER] =
|
|
|
|
g_param_spec_uint ("border", "Border", "The border width", 0,
|
|
|
|
G_MAXUINT, 0, G_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (object_class, PROP_BORDER,
|
|
|
|
properties[PROP_BORDER]);
|
|
|
|
|
2012-05-03 03:43:50 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* GESVideoTransition:type:
|
2012-05-03 03:43:50 +00:00
|
|
|
*
|
|
|
|
* The #GESVideoStandardTransitionType currently applied on the object
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
properties[PROP_TRANSITION_TYPE] =
|
|
|
|
g_param_spec_enum ("transition-type", "Transition type",
|
|
|
|
"The type of the transition", GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE,
|
2013-08-29 21:45:56 +00:00
|
|
|
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE, G_PARAM_READWRITE);
|
2012-05-03 03:43:50 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_TRANSITION_TYPE,
|
|
|
|
properties[PROP_TRANSITION_TYPE]);
|
|
|
|
|
2012-05-03 01:35:16 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* GESVideoTransition:invert:
|
2012-05-03 01:35:16 +00:00
|
|
|
*
|
|
|
|
* This value represents the direction of the transition.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
properties[PROP_INVERT] =
|
|
|
|
g_param_spec_boolean ("invert", "Invert",
|
|
|
|
"Whether the transition is inverted", FALSE, G_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (object_class, PROP_INVERT,
|
|
|
|
properties[PROP_INVERT]);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
toclass = GES_TRACK_ELEMENT_CLASS (klass);
|
2013-01-27 15:41:51 +00:00
|
|
|
toclass->create_element = ges_video_transition_create_element;
|
2010-06-18 09:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_init (GESVideoTransition * self)
|
2010-06-18 09:24:07 +00:00
|
|
|
{
|
2010-12-04 18:54:13 +00:00
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
2013-01-27 15:41:51 +00:00
|
|
|
GES_TYPE_VIDEO_TRANSITION, GESVideoTransitionPrivate);
|
2010-12-04 18:54:13 +00:00
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
self->priv->crossfade_control_source = NULL;
|
|
|
|
self->priv->smpte_control_source = NULL;
|
2011-01-06 09:55:37 +00:00
|
|
|
self->priv->smpte = NULL;
|
2013-08-29 21:45:56 +00:00
|
|
|
self->priv->mixer_sink = NULL;
|
2011-01-06 09:55:37 +00:00
|
|
|
self->priv->mixer = NULL;
|
2013-08-29 21:45:56 +00:00
|
|
|
self->priv->mixer_sinka = NULL;
|
|
|
|
self->priv->mixer_sinkb = NULL;
|
2012-05-01 23:08:08 +00:00
|
|
|
self->priv->pending_type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
2013-08-29 21:45:56 +00:00
|
|
|
self->priv->pending_border_value = 0;
|
|
|
|
self->priv->pending_inverted = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
release_mixer (GstElement ** mixer, GstPad ** sinka, GstPad ** sinkb)
|
|
|
|
{
|
|
|
|
if (*sinka && *sinkb) {
|
|
|
|
gst_element_release_request_pad (*mixer, *sinka);
|
|
|
|
gst_element_release_request_pad (*mixer, *sinkb);
|
|
|
|
gst_object_unref (*sinka);
|
|
|
|
gst_object_unref (*sinkb);
|
|
|
|
*sinka = NULL;
|
|
|
|
*sinkb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*mixer) {
|
|
|
|
gst_object_unref (*mixer);
|
|
|
|
*mixer = NULL;
|
|
|
|
}
|
2010-06-18 09:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_dispose (GObject * object)
|
2010-06-18 09:24:07 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition *self = GES_VIDEO_TRANSITION (object);
|
|
|
|
GESVideoTransitionPrivate *priv = self->priv;
|
2010-06-18 14:22:21 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("disposing");
|
2011-01-06 09:55:37 +00:00
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
if (priv->crossfade_control_source) {
|
|
|
|
gst_object_unref (priv->crossfade_control_source);
|
|
|
|
priv->crossfade_control_source = NULL;
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
if (priv->smpte_control_source) {
|
|
|
|
gst_object_unref (priv->smpte_control_source);
|
|
|
|
priv->smpte_control_source = NULL;
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
release_mixer (&priv->mixer, &priv->mixer_sinka, &priv->mixer_sinkb);
|
2010-06-28 16:20:15 +00:00
|
|
|
|
2013-07-01 21:33:01 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (GES_TRACK_ELEMENT (self),
|
|
|
|
duration_changed_cb, NULL);
|
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
G_OBJECT_CLASS (ges_video_transition_parent_class)->dispose (object);
|
2010-06-18 09:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_finalize (GObject * object)
|
2010-06-18 09:24:07 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
G_OBJECT_CLASS (ges_video_transition_parent_class)->finalize (object);
|
2010-06-18 09:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_get_property (GObject * object,
|
2010-06-18 09:24:07 +00:00
|
|
|
guint property_id, GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition *tr = GES_VIDEO_TRANSITION (object);
|
2012-05-03 01:35:16 +00:00
|
|
|
|
2010-06-18 09:24:07 +00:00
|
|
|
switch (property_id) {
|
2012-05-03 01:35:16 +00:00
|
|
|
case PROP_BORDER:
|
2013-01-27 15:41:51 +00:00
|
|
|
g_value_set_uint (value, ges_video_transition_get_border (tr));
|
2012-05-03 01:35:16 +00:00
|
|
|
break;
|
2012-05-03 03:43:50 +00:00
|
|
|
case PROP_TRANSITION_TYPE:
|
2013-01-27 15:41:51 +00:00
|
|
|
g_value_set_enum (value, ges_video_transition_get_transition_type (tr));
|
2012-05-03 03:43:50 +00:00
|
|
|
break;
|
2012-05-03 01:35:16 +00:00
|
|
|
case PROP_INVERT:
|
2013-01-27 15:41:51 +00:00
|
|
|
g_value_set_boolean (value, ges_video_transition_is_inverted (tr));
|
2012-05-03 01:35:16 +00:00
|
|
|
break;
|
2010-06-18 09:24:07 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_property (GObject * object,
|
2010-06-18 09:24:07 +00:00
|
|
|
guint property_id, const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition *tr = GES_VIDEO_TRANSITION (object);
|
2012-05-03 01:35:16 +00:00
|
|
|
|
2010-06-18 09:24:07 +00:00
|
|
|
switch (property_id) {
|
2012-05-03 01:35:16 +00:00
|
|
|
case PROP_BORDER:
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_border_internal (tr, g_value_get_uint (value));
|
2012-05-03 01:35:16 +00:00
|
|
|
break;
|
2012-05-03 03:43:50 +00:00
|
|
|
case PROP_TRANSITION_TYPE:
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_transition_type_internal (tr,
|
2012-05-03 03:43:50 +00:00
|
|
|
g_value_get_enum (value));
|
|
|
|
break;
|
2012-05-03 01:35:16 +00:00
|
|
|
case PROP_INVERT:
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_inverted_internal (tr,
|
2012-05-03 03:44:31 +00:00
|
|
|
g_value_get_boolean (value));
|
2012-05-03 01:35:16 +00:00
|
|
|
break;
|
2010-06-18 09:24:07 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
static GstTimedValueControlSource *
|
2013-01-27 15:41:51 +00:00
|
|
|
set_interpolation (GstObject * element, GESVideoTransitionPrivate * priv,
|
2012-05-02 22:38:42 +00:00
|
|
|
const gchar * propname)
|
|
|
|
{
|
2013-08-29 21:45:56 +00:00
|
|
|
GstControlSource *control_source;
|
2012-05-02 22:38:42 +00:00
|
|
|
|
2012-05-03 02:03:51 +00:00
|
|
|
g_object_set (element, propname, (gfloat) 0.0, NULL);
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
control_source = gst_interpolation_control_source_new ();
|
2012-05-03 02:03:51 +00:00
|
|
|
gst_object_add_control_binding (GST_OBJECT (element),
|
|
|
|
gst_direct_control_binding_new (GST_OBJECT (element), propname,
|
2013-08-29 21:45:56 +00:00
|
|
|
control_source));
|
|
|
|
g_object_set (control_source, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
return GST_TIMED_VALUE_CONTROL_SOURCE (control_source);
|
2012-05-02 22:38:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:54:37 +00:00
|
|
|
static GstElement *
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_create_element (GESTrackElement * object)
|
2010-06-18 13:54:37 +00:00
|
|
|
{
|
2013-08-15 18:12:30 +00:00
|
|
|
GstElement *topbin, *iconva, *iconvb, *oconv;
|
2010-06-18 13:54:37 +00:00
|
|
|
GstElement *mixer = NULL;
|
2013-08-15 18:12:30 +00:00
|
|
|
GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src;
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition *self;
|
|
|
|
GESVideoTransitionPrivate *priv;
|
2010-06-18 14:22:21 +00:00
|
|
|
|
2013-01-27 15:41:51 +00:00
|
|
|
self = GES_VIDEO_TRANSITION (object);
|
2011-01-06 09:55:37 +00:00
|
|
|
priv = self->priv;
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
GST_LOG ("creating a video bin");
|
|
|
|
|
|
|
|
topbin = gst_bin_new ("transition-bin");
|
2013-08-29 21:45:56 +00:00
|
|
|
|
2011-10-11 07:51:43 +00:00
|
|
|
iconva = gst_element_factory_make ("videoconvert", "tr-csp-a");
|
|
|
|
iconvb = gst_element_factory_make ("videoconvert", "tr-csp-b");
|
|
|
|
oconv = gst_element_factory_make ("videoconvert", "tr-csp-output");
|
2010-06-18 13:54:37 +00:00
|
|
|
|
2013-08-15 18:12:30 +00:00
|
|
|
gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, oconv, NULL);
|
2011-08-14 18:27:08 +00:00
|
|
|
|
2014-06-16 09:38:29 +00:00
|
|
|
mixer = gst_element_factory_create (ges_get_compositor_factory (), NULL);
|
2011-12-30 16:15:07 +00:00
|
|
|
g_assert (mixer);
|
2010-06-18 13:54:37 +00:00
|
|
|
g_object_set (G_OBJECT (mixer), "background", 1, NULL);
|
|
|
|
gst_bin_add (GST_BIN (topbin), mixer);
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
priv->mixer_sinka =
|
2013-08-15 18:12:30 +00:00
|
|
|
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva,
|
2013-08-29 21:45:56 +00:00
|
|
|
mixer, GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_LR, NULL, priv);
|
|
|
|
priv->mixer_sinkb =
|
2013-08-15 18:12:30 +00:00
|
|
|
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb,
|
2013-08-29 21:45:56 +00:00
|
|
|
mixer, GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_LR, &priv->smpte,
|
|
|
|
priv);
|
2010-06-28 16:23:37 +00:00
|
|
|
|
2010-07-14 11:29:23 +00:00
|
|
|
fast_element_link (mixer, oconv);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
sinka_target = gst_element_get_static_pad (iconva, "sink");
|
|
|
|
sinkb_target = gst_element_get_static_pad (iconvb, "sink");
|
|
|
|
src_target = gst_element_get_static_pad (oconv, "src");
|
|
|
|
|
|
|
|
sinka = gst_ghost_pad_new ("sinka", sinka_target);
|
|
|
|
sinkb = gst_ghost_pad_new ("sinkb", sinkb_target);
|
|
|
|
src = gst_ghost_pad_new ("src", src_target);
|
|
|
|
|
|
|
|
gst_element_add_pad (topbin, src);
|
|
|
|
gst_element_add_pad (topbin, sinka);
|
|
|
|
gst_element_add_pad (topbin, sinkb);
|
|
|
|
|
|
|
|
gst_object_unref (sinka_target);
|
|
|
|
gst_object_unref (sinkb_target);
|
|
|
|
gst_object_unref (src_target);
|
|
|
|
|
|
|
|
/* set up interpolation */
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
priv->crossfade_control_source =
|
|
|
|
set_interpolation (GST_OBJECT (priv->mixer_sinkb), priv, "alpha");
|
|
|
|
priv->smpte_control_source =
|
|
|
|
set_interpolation (GST_OBJECT (priv->smpte), priv, "position");
|
|
|
|
priv->mixer = gst_object_ref (mixer);
|
|
|
|
|
|
|
|
if (priv->pending_type)
|
|
|
|
ges_video_transition_set_transition_type_internal (self,
|
|
|
|
priv->pending_type);
|
|
|
|
else
|
|
|
|
ges_video_transition_set_transition_type_internal (self, priv->type);
|
|
|
|
|
2013-04-24 01:50:40 +00:00
|
|
|
ges_video_transition_duration_changed (object,
|
|
|
|
ges_timeline_element_get_duration (GES_TIMELINE_ELEMENT (object)));
|
2010-06-18 13:54:37 +00:00
|
|
|
|
2013-07-01 21:33:01 +00:00
|
|
|
g_signal_connect (object, "notify::duration",
|
|
|
|
G_CALLBACK (duration_changed_cb), NULL);
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
priv->pending_type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
return topbin;
|
2010-06-18 13:54:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
link_element_to_mixer_with_smpte (GstBin * bin, GstElement * element,
|
2013-08-29 21:45:56 +00:00
|
|
|
GstElement * mixer, gint type, GstElement ** smpteref,
|
|
|
|
GESVideoTransitionPrivate * priv)
|
2010-06-18 13:54:37 +00:00
|
|
|
{
|
2010-06-28 16:23:37 +00:00
|
|
|
GstPad *srcpad, *sinkpad;
|
2010-06-18 13:54:37 +00:00
|
|
|
GstElement *smptealpha = gst_element_factory_make ("smptealpha", NULL);
|
2010-06-28 16:23:37 +00:00
|
|
|
|
2010-06-18 13:54:37 +00:00
|
|
|
g_object_set (G_OBJECT (smptealpha),
|
2013-08-29 21:45:56 +00:00
|
|
|
"type", (gint) type, "invert", (gboolean) priv->pending_inverted,
|
|
|
|
"border", priv->pending_border_value, NULL);
|
2010-06-18 13:54:37 +00:00
|
|
|
gst_bin_add (bin, smptealpha);
|
|
|
|
|
2010-07-14 11:29:23 +00:00
|
|
|
fast_element_link (element, smptealpha);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
/* crack */
|
|
|
|
if (smpteref) {
|
|
|
|
*smpteref = smptealpha;
|
|
|
|
}
|
|
|
|
|
2010-06-28 16:23:37 +00:00
|
|
|
srcpad = gst_element_get_static_pad (smptealpha, "src");
|
2012-05-01 18:06:20 +00:00
|
|
|
sinkpad = gst_element_get_request_pad (mixer, "sink_%u");
|
2010-07-14 11:29:23 +00:00
|
|
|
gst_pad_link_full (srcpad, sinkpad, GST_PAD_LINK_CHECK_NOTHING);
|
2010-06-28 16:23:37 +00:00
|
|
|
gst_object_unref (srcpad);
|
|
|
|
|
|
|
|
return G_OBJECT (sinkpad);
|
2010-06-18 13:54:37 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
static void
|
|
|
|
ges_video_transition_update_control_source (GstTimedValueControlSource * ts,
|
|
|
|
guint64 duration, gdouble start_value, gdouble end_value)
|
|
|
|
{
|
|
|
|
gst_timed_value_control_source_unset_all (ts);
|
|
|
|
gst_timed_value_control_source_set (ts, 0, start_value);
|
|
|
|
gst_timed_value_control_source_set (ts, duration, end_value);
|
|
|
|
}
|
|
|
|
|
2010-06-18 13:54:37 +00:00
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_duration_changed (GESTrackElement * object,
|
2010-07-08 11:20:56 +00:00
|
|
|
guint64 duration)
|
2010-06-18 13:54:37 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition *self = GES_VIDEO_TRANSITION (object);
|
|
|
|
GESVideoTransitionPrivate *priv = self->priv;
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
GST_LOG ("updating controller");
|
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
if (priv->type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
|
|
|
|
ges_video_transition_update_control_source (priv->crossfade_control_source,
|
|
|
|
duration, 0.0, 1.0);
|
|
|
|
ges_video_transition_update_control_source (priv->smpte_control_source,
|
|
|
|
duration, 0.0, 0.0);
|
|
|
|
} else {
|
|
|
|
ges_video_transition_update_control_source (priv->crossfade_control_source,
|
|
|
|
duration, 1.0, 1.0);
|
|
|
|
ges_video_transition_update_control_source (priv->smpte_control_source,
|
|
|
|
duration, 1.0, 0.0);
|
|
|
|
}
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
GST_LOG ("done updating controller");
|
|
|
|
}
|
|
|
|
|
2012-05-03 03:44:31 +00:00
|
|
|
static inline void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_border_internal (GESVideoTransition * self,
|
2012-05-02 22:04:54 +00:00
|
|
|
guint value)
|
2012-05-01 23:09:07 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransitionPrivate *priv = self->priv;
|
2012-05-01 23:09:07 +00:00
|
|
|
|
|
|
|
if (!priv->smpte) {
|
|
|
|
priv->pending_border_value = value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_object_set (priv->smpte, "border", value, NULL);
|
|
|
|
}
|
|
|
|
|
2012-05-03 03:44:31 +00:00
|
|
|
static inline void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_inverted_internal (GESVideoTransition *
|
2012-05-03 03:44:31 +00:00
|
|
|
self, gboolean inverted)
|
2012-05-02 22:04:54 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransitionPrivate *priv = self->priv;
|
2012-05-02 22:04:54 +00:00
|
|
|
|
2012-05-03 03:44:31 +00:00
|
|
|
if (!priv->smpte) {
|
2012-05-06 16:52:25 +00:00
|
|
|
priv->pending_inverted = !inverted;
|
2012-05-03 03:44:31 +00:00
|
|
|
return;
|
2012-05-02 22:04:54 +00:00
|
|
|
}
|
2012-05-06 16:52:25 +00:00
|
|
|
g_object_set (priv->smpte, "invert", !inverted, NULL);
|
2012-05-02 22:04:54 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 03:43:50 +00:00
|
|
|
static inline gboolean
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_transition_type_internal (GESVideoTransition
|
2012-05-03 03:43:50 +00:00
|
|
|
* self, GESVideoStandardTransitionType type)
|
2010-06-18 14:22:21 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransitionPrivate *priv = self->priv;
|
2013-08-29 21:45:56 +00:00
|
|
|
guint64 duration =
|
|
|
|
ges_timeline_element_get_duration (GES_TIMELINE_ELEMENT (self));
|
2011-01-06 09:55:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("%p %d => %d", self, priv->type, type);
|
2010-07-06 16:54:33 +00:00
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
if (!priv->mixer) {
|
|
|
|
priv->pending_type = type;
|
2012-05-01 23:08:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
if (type == priv->type) {
|
|
|
|
GST_ERROR ("This type is already set on this transition\n");
|
2012-05-01 23:08:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2013-08-29 21:45:56 +00:00
|
|
|
if (type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
|
|
|
|
ges_video_transition_update_control_source (priv->crossfade_control_source,
|
|
|
|
duration, 0.0, 1.0);
|
|
|
|
ges_video_transition_update_control_source (priv->smpte_control_source,
|
|
|
|
duration, 0.0, 0.0);
|
|
|
|
} else {
|
|
|
|
ges_video_transition_update_control_source (priv->crossfade_control_source,
|
|
|
|
duration, 1.0, 1.0);
|
|
|
|
ges_video_transition_update_control_source (priv->smpte_control_source,
|
|
|
|
duration, 1.0, 0.0);
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
2013-08-29 21:45:56 +00:00
|
|
|
|
|
|
|
priv->type = type;
|
|
|
|
|
|
|
|
if (type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
|
2011-01-06 09:55:37 +00:00
|
|
|
g_object_set (priv->smpte, "type", (gint) type, NULL);
|
2012-05-01 23:08:08 +00:00
|
|
|
}
|
2013-08-29 21:45:56 +00:00
|
|
|
|
2010-07-08 11:20:56 +00:00
|
|
|
return TRUE;
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
|
|
|
|
2012-05-02 22:04:54 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* ges_video_transition_set_border:
|
|
|
|
* @self: The #GESVideoTransition to set the border to
|
2012-05-03 00:28:41 +00:00
|
|
|
* @value: The value of the border to set on @object
|
2012-05-02 22:04:54 +00:00
|
|
|
*
|
|
|
|
* Set the border property of @self, this value represents
|
|
|
|
* the border width of the transition. In case this value does
|
|
|
|
* not make sense for the current transition type, it is cached
|
|
|
|
* for later use.
|
|
|
|
*/
|
2012-05-01 23:09:07 +00:00
|
|
|
void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_border (GESVideoTransition * self, guint value)
|
2012-05-01 23:09:07 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_border_internal (self, value);
|
2012-05-01 23:09:07 +00:00
|
|
|
|
2012-05-03 03:44:31 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BORDER]);
|
2012-05-01 23:09:07 +00:00
|
|
|
}
|
|
|
|
|
2012-05-02 22:04:54 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* ges_video_transition_get_border:
|
|
|
|
* @self: The #GESVideoTransition to get the border from
|
2012-05-02 22:04:54 +00:00
|
|
|
*
|
|
|
|
* Get the border property of @self, this value represents
|
|
|
|
* the border width of the transition.
|
|
|
|
*
|
2012-05-03 00:28:41 +00:00
|
|
|
* Returns: The border values of @self or -1 if not meaningful
|
2012-05-02 22:04:54 +00:00
|
|
|
* (this will happen when not using a smpte transition).
|
|
|
|
*/
|
|
|
|
gint
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_get_border (GESVideoTransition * self)
|
2012-05-02 22:04:54 +00:00
|
|
|
{
|
|
|
|
gint value;
|
|
|
|
|
|
|
|
if (!self->priv->smpte) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (self->priv->smpte, "border", &value, NULL);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-05-03 00:28:41 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* ges_video_transition_set_inverted:
|
|
|
|
* @self: The #GESVideoTransition to set invert on
|
2012-08-10 16:39:10 +00:00
|
|
|
* @inverted: %TRUE if the transition should be inverted %FALSE otherwise
|
2012-05-03 00:28:41 +00:00
|
|
|
*
|
|
|
|
* Set the invert property of @self, this value represents
|
|
|
|
* the direction of the transition. In case this value does
|
|
|
|
* not make sense for the current transition type, it is cached
|
|
|
|
* for later use.
|
|
|
|
*/
|
|
|
|
void
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_inverted (GESVideoTransition * self, gboolean inverted)
|
2012-05-03 00:28:41 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_inverted_internal (self, inverted);
|
2012-05-03 00:28:41 +00:00
|
|
|
|
2012-05-03 03:44:31 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INVERT]);
|
2012-05-03 00:28:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* ges_video_transition_is_inverted:
|
|
|
|
* @self: The #GESVideoTransition to get the inversion from
|
2012-05-03 00:28:41 +00:00
|
|
|
*
|
|
|
|
* Get the invert property of @self, this value represents
|
|
|
|
* the direction of the transition.
|
|
|
|
*
|
|
|
|
* Returns: The invert value of @self
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_is_inverted (GESVideoTransition * self)
|
2012-05-03 00:28:41 +00:00
|
|
|
{
|
|
|
|
gboolean inverted;
|
|
|
|
|
|
|
|
if (!self->priv->smpte) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (self->priv->smpte, "invert", &inverted, NULL);
|
|
|
|
|
2012-05-06 16:52:25 +00:00
|
|
|
return !inverted;
|
2012-05-03 00:28:41 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* ges_video_transition_set_transition_type:
|
|
|
|
* @self: a #GESVideoTransition
|
2011-01-06 09:55:37 +00:00
|
|
|
* @type: a #GESVideoStandardTransitionType
|
|
|
|
*
|
|
|
|
* Sets the transition being used to @type.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the transition type was properly changed, else %FALSE.
|
|
|
|
*/
|
2010-07-08 11:20:56 +00:00
|
|
|
gboolean
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_set_transition_type (GESVideoTransition * self,
|
2010-12-09 16:09:11 +00:00
|
|
|
GESVideoStandardTransitionType type)
|
2010-06-18 14:22:21 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
gboolean ret = ges_video_transition_set_transition_type_internal (self, type);
|
2011-01-06 09:55:37 +00:00
|
|
|
|
2012-05-03 03:43:50 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TRANSITION_TYPE]);
|
2010-07-06 16:54:33 +00:00
|
|
|
|
2012-05-03 03:43:50 +00:00
|
|
|
return ret;
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* ges_video_transition_get_transition_type:
|
|
|
|
* @trans: a #GESVideoTransition
|
2011-01-06 09:55:37 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Get the transition type used by @trans.
|
|
|
|
*
|
2011-01-06 09:55:37 +00:00
|
|
|
* Returns: The transition type used by @trans.
|
|
|
|
*/
|
|
|
|
GESVideoStandardTransitionType
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_get_transition_type (GESVideoTransition * trans)
|
2011-01-06 09:55:37 +00:00
|
|
|
{
|
2012-05-01 21:42:47 +00:00
|
|
|
if (trans->priv->pending_type)
|
|
|
|
return trans->priv->pending_type;
|
2011-01-06 09:55:37 +00:00
|
|
|
return trans->priv->type;
|
|
|
|
}
|
|
|
|
|
2011-01-10 13:28:35 +00:00
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* ges_video_transition_new:
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2013-01-27 15:41:51 +00:00
|
|
|
* Creates a new #GESVideoTransition.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2013-01-27 15:41:51 +00:00
|
|
|
* Returns: The newly created #GESVideoTransition, or %NULL if there was an
|
2011-01-10 13:28:35 +00:00
|
|
|
* error.
|
|
|
|
*/
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition *
|
|
|
|
ges_video_transition_new (void)
|
2010-06-18 09:24:07 +00:00
|
|
|
{
|
2013-01-27 15:41:51 +00:00
|
|
|
return g_object_new (GES_TYPE_VIDEO_TRANSITION, "track-type",
|
2012-12-20 23:23:54 +00:00
|
|
|
GES_TRACK_TYPE_VIDEO, NULL);
|
2010-06-18 09:24:07 +00:00
|
|
|
}
|