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
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-01-27 15:41:51 +00:00
|
|
|
* SECTION:ges-video-transition
|
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;
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
/* prevents cases where the transition has not been changed yet */
|
|
|
|
GESVideoStandardTransitionType pending_type;
|
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
/* these enable video interpolation */
|
2012-02-10 19:01:03 +00:00
|
|
|
GstControlSource *control_source;
|
2011-01-06 09:55:37 +00:00
|
|
|
|
|
|
|
/* so we can support changing between wipes */
|
2012-05-01 23:08:08 +00:00
|
|
|
GstElement *topbin;
|
2011-01-06 09:55:37 +00:00
|
|
|
GstElement *smpte;
|
|
|
|
GstElement *mixer;
|
|
|
|
GstPad *sinka;
|
|
|
|
GstPad *sinkb;
|
|
|
|
|
|
|
|
/* these will be different depending on whether smptealpha or alpha element
|
|
|
|
* is used */
|
|
|
|
gdouble start_value;
|
|
|
|
gdouble end_value;
|
2012-05-01 23:08:08 +00:00
|
|
|
guint64 dur;
|
|
|
|
|
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 (GstElement * element,
|
|
|
|
GstElement * mixer);
|
|
|
|
|
|
|
|
static GObject *link_element_to_mixer_with_smpte (GstBin * bin,
|
|
|
|
GstElement * element, GstElement * mixer, gint type,
|
|
|
|
GstElement ** smpteref);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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,
|
|
|
|
GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE, G_PARAM_READWRITE);
|
|
|
|
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->duration_changed = ges_video_transition_duration_changed;
|
|
|
|
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
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
self->priv->control_source = NULL;
|
|
|
|
self->priv->smpte = NULL;
|
|
|
|
self->priv->mixer = NULL;
|
|
|
|
self->priv->sinka = NULL;
|
|
|
|
self->priv->sinkb = NULL;
|
2012-05-01 23:08:08 +00:00
|
|
|
self->priv->topbin = NULL;
|
2011-01-06 09:55:37 +00:00
|
|
|
self->priv->type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
2012-05-01 23:08:08 +00:00
|
|
|
self->priv->pending_type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
2011-01-06 09:55:37 +00:00
|
|
|
self->priv->start_value = 0.0;
|
|
|
|
self->priv->end_value = 0.0;
|
2012-05-01 23:08:08 +00:00
|
|
|
self->priv->dur = 42;
|
2012-05-01 23:09:07 +00:00
|
|
|
self->priv->pending_border_value = -1;
|
2012-05-03 00:28:41 +00:00
|
|
|
self->priv->pending_inverted = FALSE;
|
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");
|
|
|
|
GST_LOG ("mixer: %p smpte: %p sinka: %p sinkb: %p",
|
2011-01-06 09:55:37 +00:00
|
|
|
priv->mixer, priv->smpte, priv->sinka, priv->sinkb);
|
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
if (priv->control_source) {
|
2011-01-06 09:55:37 +00:00
|
|
|
if (priv->control_source)
|
|
|
|
gst_object_unref (priv->control_source);
|
|
|
|
priv->control_source = NULL;
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
if (priv->sinka && priv->sinkb) {
|
2010-06-18 14:22:21 +00:00
|
|
|
GST_DEBUG ("releasing request pads for mixer");
|
2011-01-06 09:55:37 +00:00
|
|
|
gst_element_release_request_pad (priv->mixer, priv->sinka);
|
|
|
|
gst_element_release_request_pad (priv->mixer, priv->sinkb);
|
|
|
|
gst_object_unref (priv->sinka);
|
|
|
|
gst_object_unref (priv->sinkb);
|
|
|
|
priv->sinka = NULL;
|
|
|
|
priv->sinkb = NULL;
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
if (priv->mixer) {
|
2010-06-28 16:20:15 +00:00
|
|
|
GST_LOG ("unrefing mixer");
|
2011-01-06 09:55:37 +00:00
|
|
|
gst_object_unref (priv->mixer);
|
|
|
|
priv->mixer = NULL;
|
2010-06-28 16:20:15 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-14 18:27:08 +00:00
|
|
|
static void
|
|
|
|
on_caps_set (GstPad * srca_pad, GParamSpec * pspec, GstElement * capsfilt)
|
|
|
|
{
|
2011-10-11 08:02:11 +00:00
|
|
|
GstCaps *orig_caps;
|
|
|
|
|
2013-04-24 01:50:40 +00:00
|
|
|
orig_caps = gst_pad_get_current_caps (srca_pad);
|
2011-10-11 08:02:11 +00:00
|
|
|
|
|
|
|
if (orig_caps) {
|
|
|
|
gint width, height;
|
|
|
|
const GstStructure *str;
|
|
|
|
GstCaps *size_caps;
|
2011-08-14 18:27:08 +00:00
|
|
|
|
|
|
|
/* Get width and height of first video */
|
2011-10-11 08:02:11 +00:00
|
|
|
str = gst_caps_get_structure (orig_caps, 0);
|
2011-08-14 18:27:08 +00:00
|
|
|
gst_structure_get_int (str, "width", &width);
|
|
|
|
gst_structure_get_int (str, "height", &height);
|
|
|
|
|
|
|
|
/* Set capsfilter to the size of the first video */
|
|
|
|
size_caps =
|
2012-02-10 19:35:28 +00:00
|
|
|
gst_caps_new_simple ("video/x-raw", "width", G_TYPE_INT, width,
|
2011-08-14 18:27:08 +00:00
|
|
|
"height", G_TYPE_INT, height, NULL);
|
|
|
|
g_object_set (capsfilt, "caps", size_caps, NULL);
|
2013-04-24 01:50:40 +00:00
|
|
|
/* Shouldn't we need a reconfigure event here ? */
|
2011-08-14 18:27:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
static GstElement *
|
|
|
|
create_mixer (GstElement * topbin)
|
|
|
|
{
|
|
|
|
GstElement *mixer = NULL;
|
|
|
|
|
2012-05-05 17:00:49 +00:00
|
|
|
mixer = gst_element_factory_make ("videomixer", NULL);
|
2012-05-01 23:08:08 +00:00
|
|
|
g_object_set (G_OBJECT (mixer), "background", 1, NULL);
|
|
|
|
gst_bin_add (GST_BIN (topbin), mixer);
|
|
|
|
|
|
|
|
return (mixer);
|
|
|
|
}
|
|
|
|
|
2012-05-02 22:38:42 +00:00
|
|
|
static void
|
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)
|
|
|
|
{
|
2012-05-03 02:03:51 +00:00
|
|
|
GstTimedValueControlSource *ts;
|
2012-05-02 22:38:42 +00:00
|
|
|
|
|
|
|
if (priv->control_source) {
|
2012-05-03 02:03:51 +00:00
|
|
|
ts = GST_TIMED_VALUE_CONTROL_SOURCE (priv->control_source);
|
|
|
|
|
|
|
|
gst_timed_value_control_source_unset_all (ts);
|
2012-05-02 22:38:42 +00:00
|
|
|
gst_object_unref (priv->control_source);
|
|
|
|
}
|
|
|
|
|
2012-05-03 02:03:51 +00:00
|
|
|
g_object_set (element, propname, (gfloat) 0.0, NULL);
|
|
|
|
|
2012-05-02 22:38:42 +00:00
|
|
|
priv->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,
|
|
|
|
priv->control_source));
|
|
|
|
g_object_set (priv->control_source, "mode", GST_INTERPOLATION_MODE_LINEAR,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2011-08-14 18:27:08 +00:00
|
|
|
GstElement *topbin, *iconva, *iconvb, *scalea, *scaleb, *capsfilt, *oconv;
|
2012-05-03 02:03:51 +00:00
|
|
|
GstObject *target = NULL;
|
2010-06-18 13:54:37 +00:00
|
|
|
const gchar *propname = NULL;
|
|
|
|
GstElement *mixer = NULL;
|
2011-08-14 18:27:08 +00:00
|
|
|
GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src,
|
|
|
|
*srca_pad;
|
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");
|
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");
|
2011-08-14 18:27:08 +00:00
|
|
|
scalea = gst_element_factory_make ("videoscale", "vs-a");
|
|
|
|
scaleb = gst_element_factory_make ("videoscale", "vs-b");
|
|
|
|
capsfilt = gst_element_factory_make ("capsfilter", "capsfilt");
|
2011-10-11 07:51:43 +00:00
|
|
|
oconv = gst_element_factory_make ("videoconvert", "tr-csp-output");
|
2010-06-18 13:54:37 +00:00
|
|
|
|
2011-08-14 18:27:08 +00:00
|
|
|
gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, scalea, scaleb, capsfilt,
|
|
|
|
oconv, NULL);
|
|
|
|
|
2012-05-01 18:06:20 +00:00
|
|
|
mixer = gst_element_factory_make ("videomixer", 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);
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
if (priv->pending_type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
|
2011-01-06 09:55:37 +00:00
|
|
|
priv->sinka =
|
2010-06-28 16:23:37 +00:00
|
|
|
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva,
|
2012-05-01 23:08:08 +00:00
|
|
|
mixer, priv->pending_type, NULL);
|
2011-01-06 09:55:37 +00:00
|
|
|
priv->sinkb =
|
2010-06-28 16:23:37 +00:00
|
|
|
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb,
|
2012-05-01 23:08:08 +00:00
|
|
|
mixer, priv->pending_type, &priv->smpte);
|
2012-05-03 02:03:51 +00:00
|
|
|
target = GST_OBJECT (priv->smpte);
|
2010-06-18 13:54:37 +00:00
|
|
|
propname = "position";
|
2011-01-06 09:55:37 +00:00
|
|
|
priv->start_value = 1.0;
|
|
|
|
priv->end_value = 0.0;
|
2010-06-18 13:54:37 +00:00
|
|
|
} else {
|
2011-08-14 18:27:08 +00:00
|
|
|
gst_element_link_pads_full (iconva, "src", scalea, "sink",
|
|
|
|
GST_PAD_LINK_CHECK_NOTHING);
|
|
|
|
gst_element_link_pads_full (iconvb, "src", scaleb, "sink",
|
|
|
|
GST_PAD_LINK_CHECK_NOTHING);
|
|
|
|
gst_element_link_pads_full (scaleb, "src", capsfilt, "sink",
|
|
|
|
GST_PAD_LINK_CHECK_NOTHING);
|
|
|
|
|
|
|
|
priv->sinka = (GstPad *) link_element_to_mixer (scalea, mixer);
|
|
|
|
priv->sinkb = (GstPad *) link_element_to_mixer (capsfilt, mixer);
|
2012-05-03 02:03:51 +00:00
|
|
|
target = GST_OBJECT (priv->sinkb);
|
2010-06-18 13:54:37 +00:00
|
|
|
propname = "alpha";
|
2011-01-06 09:55:37 +00:00
|
|
|
priv->start_value = 0.0;
|
|
|
|
priv->end_value = 1.0;
|
2010-06-18 13:54:37 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 09:55:37 +00:00
|
|
|
priv->mixer = gst_object_ref (mixer);
|
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);
|
|
|
|
|
2011-08-14 18:27:08 +00:00
|
|
|
srca_pad = gst_element_get_static_pad (scalea, "src");
|
|
|
|
g_signal_connect (srca_pad, "notify::caps", G_CALLBACK (on_caps_set),
|
|
|
|
(GstElement *) capsfilt);
|
|
|
|
|
2010-06-18 13:54:37 +00:00
|
|
|
gst_object_unref (sinka_target);
|
|
|
|
gst_object_unref (sinkb_target);
|
|
|
|
gst_object_unref (src_target);
|
2011-08-14 18:27:08 +00:00
|
|
|
gst_object_unref (srca_pad);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
/* set up interpolation */
|
|
|
|
|
2012-05-02 22:38:42 +00:00
|
|
|
set_interpolation (target, priv, propname);
|
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
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
priv->topbin = topbin;
|
|
|
|
priv->type = priv->pending_type;
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
return topbin;
|
|
|
|
}
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
static void
|
|
|
|
add_smpte_to_bin (GstPad * sink, GstElement * smptealpha,
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransitionPrivate * priv)
|
2012-05-01 23:08:08 +00:00
|
|
|
{
|
|
|
|
GstPad *peer, *sinkpad;
|
|
|
|
|
|
|
|
g_object_set (smptealpha,
|
|
|
|
"type", (gint) priv->pending_type, "invert", (gboolean) TRUE, NULL);
|
|
|
|
gst_bin_add (GST_BIN (priv->topbin), smptealpha);
|
|
|
|
gst_element_sync_state_with_parent (smptealpha);
|
|
|
|
|
|
|
|
sinkpad = gst_element_get_static_pad (smptealpha, "sink");
|
|
|
|
peer = gst_pad_get_peer (sink);
|
|
|
|
gst_pad_unlink (peer, sink);
|
|
|
|
|
|
|
|
gst_pad_link_full (peer, sinkpad, GST_PAD_LINK_CHECK_NOTHING);
|
|
|
|
|
|
|
|
gst_object_unref (sinkpad);
|
|
|
|
gst_object_unref (peer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 15:41:51 +00:00
|
|
|
replace_mixer (GESVideoTransitionPrivate * priv)
|
2012-05-01 23:08:08 +00:00
|
|
|
{
|
|
|
|
GstPad *mixer_src_pad, *color_sink_pad;
|
|
|
|
|
|
|
|
mixer_src_pad = gst_element_get_static_pad (priv->mixer, "src");
|
|
|
|
color_sink_pad = gst_pad_get_peer (mixer_src_pad);
|
|
|
|
|
|
|
|
gst_element_set_state (priv->mixer, GST_STATE_NULL);
|
|
|
|
gst_bin_remove (GST_BIN (priv->topbin), priv->mixer);
|
|
|
|
|
|
|
|
gst_object_unref (priv->mixer);
|
|
|
|
|
|
|
|
priv->mixer = gst_object_ref (create_mixer (priv->topbin));
|
|
|
|
|
|
|
|
gst_element_sync_state_with_parent (priv->mixer);
|
|
|
|
|
|
|
|
gst_object_unref (mixer_src_pad);
|
|
|
|
|
|
|
|
mixer_src_pad = gst_element_get_static_pad (priv->mixer, "src");
|
|
|
|
gst_pad_link (mixer_src_pad, color_sink_pad);
|
|
|
|
|
|
|
|
gst_object_unref (mixer_src_pad);
|
|
|
|
gst_object_unref (color_sink_pad);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-05-03 02:03:51 +00:00
|
|
|
static GstPadProbeReturn
|
2012-05-01 23:08:08 +00:00
|
|
|
switch_to_smpte_cb (GstPad * sink, gboolean blocked,
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition * transition)
|
2012-05-01 23:08:08 +00:00
|
|
|
{
|
|
|
|
GstElement *smptealpha = gst_element_factory_make ("smptealpha", NULL);
|
|
|
|
GstElement *smptealphab = gst_element_factory_make ("smptealpha", NULL);
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransitionPrivate *priv = transition->priv;
|
2012-05-01 23:08:08 +00:00
|
|
|
|
|
|
|
if (priv->pending_type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE)
|
|
|
|
goto beach;
|
|
|
|
|
|
|
|
GST_INFO ("Bin %p switching from crossfade to smpte", priv->topbin);
|
|
|
|
|
|
|
|
add_smpte_to_bin (priv->sinka, smptealpha, priv);
|
|
|
|
add_smpte_to_bin (priv->sinkb, smptealphab, priv);
|
|
|
|
|
2012-05-01 23:09:07 +00:00
|
|
|
if (priv->pending_border_value != -1) {
|
|
|
|
g_object_set (smptealphab, "border", priv->pending_border_value, NULL);
|
|
|
|
priv->pending_border_value = -1;
|
|
|
|
}
|
|
|
|
|
2012-05-03 00:28:41 +00:00
|
|
|
if (priv->pending_inverted) {
|
|
|
|
g_object_set (smptealphab, "invert", priv->pending_inverted, NULL);
|
|
|
|
priv->pending_inverted = FALSE;
|
|
|
|
}
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
replace_mixer (priv);
|
|
|
|
|
|
|
|
priv->start_value = 1.0;
|
|
|
|
priv->end_value = 0.0;
|
|
|
|
|
2012-05-03 02:03:51 +00:00
|
|
|
set_interpolation (GST_OBJECT (smptealphab), priv, (gchar *) "position");
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_duration_changed (GES_TRACK_ELEMENT (transition),
|
2012-05-02 22:38:42 +00:00
|
|
|
priv->dur);
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
|
|
|
|
priv->sinka = (GstPad *) link_element_to_mixer (smptealpha, priv->mixer);
|
|
|
|
priv->sinkb = (GstPad *) link_element_to_mixer (smptealphab, priv->mixer);
|
|
|
|
|
|
|
|
priv->smpte = smptealphab;
|
|
|
|
|
|
|
|
priv->type = priv->pending_type;
|
|
|
|
|
|
|
|
GST_INFO ("Bin %p switched from crossfade to smpte", priv->topbin);
|
|
|
|
|
|
|
|
beach:
|
|
|
|
priv->pending_type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2012-05-05 17:00:49 +00:00
|
|
|
return GST_PAD_PROBE_REMOVE;
|
2012-05-01 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstElement *
|
2013-01-27 15:41:51 +00:00
|
|
|
remove_smpte_from_bin (GESVideoTransitionPrivate * priv, GstPad * sink)
|
2012-05-01 23:08:08 +00:00
|
|
|
{
|
|
|
|
GstPad *smpte_src, *peer_src, *smpte_sink;
|
|
|
|
GstElement *smpte, *peer;
|
|
|
|
|
|
|
|
smpte_src = gst_pad_get_peer (sink);
|
|
|
|
smpte = gst_pad_get_parent_element (smpte_src);
|
|
|
|
|
|
|
|
if (smpte == NULL) {
|
|
|
|
gst_object_unref (smpte_src);
|
2012-05-07 15:11:26 +00:00
|
|
|
GST_ERROR ("The pad %" GST_PTR_FORMAT " has no parent element. "
|
|
|
|
"This should not happen", smpte_src);
|
2012-05-01 23:08:08 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
smpte_sink = gst_element_get_static_pad (smpte, "sink");
|
|
|
|
peer_src = gst_pad_get_peer (smpte_sink);
|
|
|
|
peer = gst_pad_get_parent_element (peer_src);
|
|
|
|
|
|
|
|
gst_pad_unlink (peer_src, smpte_sink);
|
|
|
|
gst_pad_unlink (smpte_src, sink);
|
|
|
|
|
|
|
|
gst_element_set_state (smpte, GST_STATE_NULL);
|
|
|
|
gst_bin_remove (GST_BIN (priv->topbin), smpte);
|
|
|
|
|
|
|
|
gst_object_unref (smpte);
|
|
|
|
gst_object_unref (smpte_sink);
|
|
|
|
gst_object_unref (smpte_src);
|
|
|
|
gst_object_unref (peer_src);
|
|
|
|
return (peer);
|
|
|
|
}
|
|
|
|
|
2012-05-03 02:03:51 +00:00
|
|
|
static GstPadProbeReturn
|
2012-05-01 23:08:08 +00:00
|
|
|
switch_to_crossfade_cb (GstPad * sink, gboolean blocked,
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransition * transition)
|
2012-05-01 23:08:08 +00:00
|
|
|
{
|
|
|
|
GstElement *peera;
|
|
|
|
GstElement *peerb;
|
2013-01-27 15:41:51 +00:00
|
|
|
GESVideoTransitionPrivate *priv = transition->priv;
|
2012-05-01 23:08:08 +00:00
|
|
|
|
|
|
|
GST_INFO ("Bin %p switching from smpte to crossfade", priv->topbin);
|
|
|
|
|
|
|
|
if (priv->pending_type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE)
|
|
|
|
goto beach;
|
|
|
|
|
|
|
|
peera = remove_smpte_from_bin (priv, priv->sinka);
|
|
|
|
peerb = remove_smpte_from_bin (priv, priv->sinkb);
|
|
|
|
if (!peera || !peerb)
|
|
|
|
goto beach;
|
|
|
|
|
|
|
|
replace_mixer (priv);
|
|
|
|
|
|
|
|
priv->sinka = (GstPad *) link_element_to_mixer (peera, priv->mixer);
|
|
|
|
priv->sinkb = (GstPad *) link_element_to_mixer (peerb, priv->mixer);
|
|
|
|
|
|
|
|
priv->start_value = 0.0;
|
|
|
|
priv->end_value = 1.0;
|
2012-05-03 02:03:51 +00:00
|
|
|
set_interpolation (GST_OBJECT (priv->sinkb), priv, (gchar *) "alpha");
|
2013-01-27 15:41:51 +00:00
|
|
|
ges_video_transition_duration_changed (GES_TRACK_ELEMENT (transition),
|
2012-05-02 22:38:42 +00:00
|
|
|
priv->dur);
|
2012-05-01 23:08:08 +00:00
|
|
|
|
|
|
|
priv->smpte = NULL;
|
|
|
|
|
|
|
|
gst_object_unref (peera);
|
|
|
|
gst_object_unref (peerb);
|
|
|
|
|
|
|
|
priv->type = priv->pending_type;
|
|
|
|
|
|
|
|
GST_INFO ("Bin %p switched from smpte to crossfade", priv->topbin);
|
|
|
|
|
|
|
|
beach:
|
|
|
|
priv->pending_type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2012-05-05 17:00:49 +00:00
|
|
|
return GST_PAD_PROBE_REMOVE;
|
2012-05-01 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:54:37 +00:00
|
|
|
static GObject *
|
|
|
|
link_element_to_mixer (GstElement * element, GstElement * mixer)
|
|
|
|
{
|
2012-05-05 17:00:49 +00:00
|
|
|
GstPad *sinkpad = gst_element_get_request_pad (mixer, "sink_%u");
|
2010-06-18 13:54:37 +00:00
|
|
|
GstPad *srcpad = gst_element_get_static_pad (element, "src");
|
|
|
|
|
2010-07-14 11:29:23 +00:00
|
|
|
gst_pad_link_full (srcpad, sinkpad, GST_PAD_LINK_CHECK_NOTHING);
|
2010-06-18 13:54:37 +00:00
|
|
|
gst_object_unref (srcpad);
|
|
|
|
|
|
|
|
return G_OBJECT (sinkpad);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
link_element_to_mixer_with_smpte (GstBin * bin, GstElement * element,
|
|
|
|
GstElement * mixer, gint type, GstElement ** smpteref)
|
|
|
|
{
|
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),
|
|
|
|
"type", (gint) type, "invert", (gboolean) TRUE, NULL);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2011-12-30 16:15:07 +00:00
|
|
|
GstTimedValueControlSource *ts;
|
2010-06-18 13:54:37 +00:00
|
|
|
|
|
|
|
GST_LOG ("updating controller");
|
|
|
|
|
2013-04-24 01:50:40 +00:00
|
|
|
if (G_UNLIKELY (!priv->control_source))
|
2010-06-18 13:54:37 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
ts = GST_TIMED_VALUE_CONTROL_SOURCE (priv->control_source);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
GST_INFO ("duration: %" G_GUINT64_FORMAT, duration);
|
2010-06-18 13:54:37 +00:00
|
|
|
GST_LOG ("setting values on controller");
|
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
gst_timed_value_control_source_unset_all (ts);
|
|
|
|
gst_timed_value_control_source_set (ts, 0, priv->start_value);
|
|
|
|
gst_timed_value_control_source_set (ts, duration, priv->end_value);
|
2010-06-18 13:54:37 +00:00
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
priv->dur = duration;
|
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:44:31 +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;
|
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
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
if (type == priv->type && !priv->pending_type) {
|
|
|
|
GST_INFO ("This type is already set on this transition\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
if (type == priv->pending_type) {
|
|
|
|
GST_INFO ("This type is already pending for this transition\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
2012-05-03 02:03:51 +00:00
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
if (priv->type &&
|
|
|
|
((priv->type != type) || (priv->type != priv->pending_type)) &&
|
2010-12-09 16:09:11 +00:00
|
|
|
((type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) ||
|
2011-01-06 09:55:37 +00:00
|
|
|
(priv->type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE))) {
|
2012-05-03 02:03:51 +00:00
|
|
|
GstPad *pad = gst_element_get_static_pad (priv->topbin, "sinka");
|
|
|
|
|
2012-05-01 23:08:08 +00:00
|
|
|
priv->pending_type = type;
|
|
|
|
if (type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
|
|
|
|
if (!priv->topbin)
|
|
|
|
return FALSE;
|
|
|
|
priv->smpte = NULL;
|
2012-05-05 17:00:49 +00:00
|
|
|
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_IDLE,
|
2012-05-03 02:03:51 +00:00
|
|
|
(GstPadProbeCallback) switch_to_smpte_cb, self, NULL);
|
2012-05-01 23:08:08 +00:00
|
|
|
} else {
|
|
|
|
if (!priv->topbin)
|
|
|
|
return FALSE;
|
|
|
|
priv->start_value = 1.0;
|
|
|
|
priv->end_value = 0.0;
|
2012-05-05 17:00:49 +00:00
|
|
|
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_IDLE,
|
2012-05-03 02:03:51 +00:00
|
|
|
(GstPadProbeCallback) switch_to_crossfade_cb, self, NULL);
|
2012-05-01 23:08:08 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
2010-06-18 14:22:21 +00:00
|
|
|
}
|
2012-05-01 23:08:08 +00:00
|
|
|
priv->pending_type = type;
|
|
|
|
if (priv->smpte && (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
|
|
|
}
|
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
|
|
|
}
|