2009-08-04 15:13:11 +00:00
|
|
|
/* GStreamer Editing Services
|
2009-11-30 14:14:25 +00:00
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* 2009 Nokia Corporation
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
/**
|
|
|
|
* SECTION: ges-timeline-transition
|
2010-07-01 14:48:45 +00:00
|
|
|
* @short_description: Transition from one clip to another in a
|
|
|
|
* #GESTimelineLayer
|
|
|
|
*
|
|
|
|
* Creates an object that mixes together the two underlying objects, A and B.
|
|
|
|
* The A object is assumed to have a higher prioirity (lower number) than the
|
|
|
|
* B object. At the transition in point, only A will be visible, and by the
|
|
|
|
* end only B will be visible.
|
|
|
|
*
|
|
|
|
* The shape of the video transition depends on the value of the "vtype"
|
|
|
|
* property. The default value is "crossfade". For audio, only "crossfade" is
|
|
|
|
* supported.
|
|
|
|
*
|
|
|
|
* #GESSimpleTimelineLayer will automatically manage the priorities of sources
|
|
|
|
* and transitions. If you use #GESTimelineTransitions in another type of
|
|
|
|
* #GESTimelineLayer, you will need to manage priorities yourself.
|
2009-09-10 16:40:51 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-06 17:51:29 +00:00
|
|
|
#include "ges-internal.h"
|
2009-08-04 15:13:11 +00:00
|
|
|
#include "ges-timeline-transition.h"
|
2010-06-18 09:50:08 +00:00
|
|
|
#include "ges-track-video-transition.h"
|
|
|
|
#include "ges-track-audio-transition.h"
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2010-06-02 16:57:10 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_VTYPE = 5,
|
|
|
|
};
|
|
|
|
|
2009-08-04 15:16:31 +00:00
|
|
|
G_DEFINE_TYPE (GESTimelineTransition, ges_timeline_transition,
|
2009-08-06 15:38:43 +00:00
|
|
|
GES_TYPE_TIMELINE_OBJECT);
|
|
|
|
|
2010-05-25 11:44:57 +00:00
|
|
|
static GESTrackObject *ges_tl_transition_create_track_object (GESTimelineObject
|
2010-07-06 17:00:50 +00:00
|
|
|
* self, GESTrack * track);
|
2010-05-25 11:44:57 +00:00
|
|
|
|
2010-07-06 17:00:50 +00:00
|
|
|
static void
|
2010-06-09 14:27:43 +00:00
|
|
|
ges_timeline_transition_update_vtype_internal (GESTimelineObject * self,
|
2010-07-06 17:00:50 +00:00
|
|
|
GESVideoTransitionType value)
|
2010-06-02 16:57:10 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
2010-07-08 11:20:56 +00:00
|
|
|
GESTimelineTransition *trself = (GESTimelineTransition *) self;
|
|
|
|
GESVideoTransitionType old;
|
|
|
|
old = trself->vtype;
|
|
|
|
|
|
|
|
for (tmp = self->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
|
|
|
GESTrackVideoTransition *obj;
|
|
|
|
if (GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
|
|
|
|
obj = (GESTrackVideoTransition *) tmp->data;
|
|
|
|
if (!ges_track_video_transition_set_type (obj, value))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-06-02 16:57:10 +00:00
|
|
|
|
2010-07-08 11:20:56 +00:00
|
|
|
trself->vtype = value;
|
|
|
|
return;
|
2010-06-02 16:57:10 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
static void
|
|
|
|
ges_timeline_transition_get_property (GObject * object,
|
2009-08-04 15:16:31 +00:00
|
|
|
guint property_id, GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-06-02 16:57:10 +00:00
|
|
|
GESTimelineTransition *self = GES_TIMELINE_TRANSITION (object);
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2010-06-02 16:57:10 +00:00
|
|
|
case PROP_VTYPE:
|
2010-07-08 11:20:56 +00:00
|
|
|
g_value_set_enum (value, self->vtype);
|
2010-06-02 16:57:10 +00:00
|
|
|
break;
|
2009-08-04 15:16:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_transition_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-06-02 16:57:10 +00:00
|
|
|
GESTimelineObject *self = GES_TIMELINE_OBJECT (object);
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2010-06-02 16:57:10 +00:00
|
|
|
case PROP_VTYPE:
|
2010-07-08 11:20:56 +00:00
|
|
|
ges_timeline_transition_update_vtype_internal (self,
|
|
|
|
g_value_get_enum (value));
|
2010-06-02 16:57:10 +00:00
|
|
|
break;
|
2009-08-04 15:16:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_transition_dispose (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (ges_timeline_transition_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_transition_finalize (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (ges_timeline_transition_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_transition_class_init (GESTimelineTransitionClass * klass)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2010-05-25 11:44:57 +00:00
|
|
|
GESTimelineObjectClass *timobj_class = GES_TIMELINE_OBJECT_CLASS (klass);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
|
|
|
object_class->get_property = ges_timeline_transition_get_property;
|
|
|
|
object_class->set_property = ges_timeline_transition_set_property;
|
|
|
|
object_class->dispose = ges_timeline_transition_dispose;
|
|
|
|
object_class->finalize = ges_timeline_transition_finalize;
|
2010-05-25 11:44:57 +00:00
|
|
|
|
2010-06-02 16:57:10 +00:00
|
|
|
/**
|
2010-06-14 17:19:23 +00:00
|
|
|
* GESTimelineTransition:vtype
|
2010-06-02 16:57:10 +00:00
|
|
|
*
|
2010-07-01 16:50:30 +00:00
|
|
|
* a #GESVideoTransitionType representing the wipe to use
|
2010-06-02 16:57:10 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_VTYPE,
|
|
|
|
g_param_spec_enum ("vtype", "VType",
|
|
|
|
"The SMPTE video wipe to use, or 0 for crossfade",
|
2010-07-01 16:50:30 +00:00
|
|
|
GES_VIDEO_TRANSITION_TYPE_TYPE, GES_VIDEO_TRANSITION_TYPE_CROSSFADE,
|
2010-06-04 16:31:25 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2010-06-02 16:57:10 +00:00
|
|
|
|
|
|
|
|
2010-05-25 11:44:57 +00:00
|
|
|
timobj_class->create_track_object = ges_tl_transition_create_track_object;
|
|
|
|
timobj_class->need_fill_track = FALSE;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_transition_init (GESTimelineTransition * self)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-07-07 16:00:21 +00:00
|
|
|
self->vtype = GES_VIDEO_TRANSITION_TYPE_NONE;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2010-05-25 11:44:57 +00:00
|
|
|
static GESTrackObject *
|
|
|
|
ges_tl_transition_create_track_object (GESTimelineObject * obj,
|
|
|
|
GESTrack * track)
|
|
|
|
{
|
|
|
|
GESTimelineTransition *transition = (GESTimelineTransition *) obj;
|
|
|
|
GESTrackObject *res;
|
|
|
|
|
|
|
|
GST_DEBUG ("Creating a GESTrackTransition");
|
|
|
|
|
2010-06-18 09:50:08 +00:00
|
|
|
if (track->type == GES_TRACK_TYPE_VIDEO) {
|
|
|
|
res = GES_TRACK_OBJECT (ges_track_video_transition_new ());
|
2010-06-18 14:22:21 +00:00
|
|
|
ges_track_video_transition_set_type ((GESTrackVideoTransition *) res,
|
2010-06-18 09:50:08 +00:00
|
|
|
transition->vtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (track->type == GES_TRACK_TYPE_AUDIO) {
|
|
|
|
res = GES_TRACK_OBJECT (ges_track_audio_transition_new ());
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2010-07-07 15:34:58 +00:00
|
|
|
GST_WARNING ("Transitions don't handle this track type");
|
|
|
|
return NULL;
|
2010-06-18 09:50:08 +00:00
|
|
|
}
|
2010-05-25 11:44:57 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-06-17 09:22:30 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_transition_new:
|
|
|
|
* @vtype: the type of transition to create
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-05-27 10:02:10 +00:00
|
|
|
GESTimelineTransition *
|
2010-07-01 16:50:30 +00:00
|
|
|
ges_timeline_transition_new (GESVideoTransitionType vtype)
|
2010-05-27 10:02:10 +00:00
|
|
|
{
|
2010-07-06 17:02:02 +00:00
|
|
|
return g_object_new (GES_TYPE_TIMELINE_TRANSITION, "vtype", (gint) vtype,
|
2010-06-04 16:07:39 +00:00
|
|
|
NULL);
|
|
|
|
}
|
2010-05-27 10:02:10 +00:00
|
|
|
|
2010-06-17 09:22:30 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_transition_new_for_nick:
|
|
|
|
* @nick: a string representing the type of transition to create
|
|
|
|
*/
|
|
|
|
|
2010-06-04 16:07:39 +00:00
|
|
|
GESTimelineTransition *
|
|
|
|
ges_timeline_transition_new_for_nick (gchar * nick)
|
|
|
|
{
|
2010-06-04 16:31:25 +00:00
|
|
|
GEnumValue *value;
|
2010-07-08 13:54:27 +00:00
|
|
|
GEnumClass *klass;
|
|
|
|
GESTimelineTransition *ret = NULL;
|
2010-06-04 16:31:25 +00:00
|
|
|
|
2010-07-08 13:54:27 +00:00
|
|
|
klass = G_ENUM_CLASS (g_type_class_ref (GES_VIDEO_TRANSITION_TYPE_TYPE));
|
|
|
|
if (!klass)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
value = g_enum_get_value_by_nick (klass, nick);
|
|
|
|
if (value) {
|
|
|
|
ret = g_object_new (GES_TYPE_TIMELINE_TRANSITION, "vtype",
|
|
|
|
(gint) value->value, NULL);
|
|
|
|
}
|
2010-05-27 10:02:10 +00:00
|
|
|
|
2010-07-08 13:54:27 +00:00
|
|
|
g_type_class_unref (klass);
|
|
|
|
return ret;
|
2010-05-27 10:02:10 +00:00
|
|
|
}
|