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
|
|
|
|
* @short_description: Base Class for transitions in a #GESTimelineLayer
|
|
|
|
*/
|
|
|
|
|
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-05-25 11:44:57 +00:00
|
|
|
#include "ges-track-transition.h"
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2010-06-02 16:57:10 +00:00
|
|
|
#define GES_TYPE_TIMELINE_TRANSITION_VTYPE_TYPE \
|
|
|
|
(ges_type_timeline_transition_vtype_get_type())
|
|
|
|
|
|
|
|
static GType ges_type_timeline_transition_vtype_get_type (void);
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
VTYPE_CROSSFADE = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
*, GESTrack *);
|
|
|
|
|
2010-06-02 16:57:10 +00:00
|
|
|
void
|
|
|
|
ges_timeline_transition_update_vtype_internal (GESTimelineObject * self,
|
|
|
|
gint value)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GESTrackTransition *tr;
|
|
|
|
GESTrackObject *to;
|
|
|
|
|
|
|
|
for (tmp = g_list_first (self->trackobjects); tmp; tmp = g_list_next (tmp)) {
|
|
|
|
tr = GES_TRACK_TRANSITION (tmp->data);
|
|
|
|
to = (GESTrackObject *) tr;
|
|
|
|
|
|
|
|
if ((to->track) && (to->track->type == GES_TRACK_TYPE_VIDEO)) {
|
|
|
|
ges_track_transition_set_vtype (tr, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
gint value_int;
|
2009-08-04 15:13:11 +00:00
|
|
|
switch (property_id) {
|
2010-06-02 16:57:10 +00:00
|
|
|
case PROP_VTYPE:
|
|
|
|
self->vtype = g_value_get_enum (value);
|
|
|
|
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);
|
|
|
|
GESTimelineTransition *trself = 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:
|
|
|
|
trself->vtype = g_value_get_enum (value);
|
|
|
|
ges_timeline_transition_update_vtype_internal (self, trself->vtype);
|
|
|
|
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
|
|
|
/**
|
|
|
|
* GESTimelineTransition: vtype
|
|
|
|
*
|
|
|
|
* The SMPTE wipe to use, or 0 for crossfade.
|
|
|
|
*/
|
|
|
|
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",
|
|
|
|
GES_TYPE_TIMELINE_TRANSITION_VTYPE_TYPE, VTYPE_CROSSFADE,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
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-06-02 14:43:10 +00:00
|
|
|
self->vtype = 0;
|
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-02 14:43:10 +00:00
|
|
|
res = GES_TRACK_OBJECT (ges_track_transition_new (transition->vtype));
|
2010-05-25 11:44:57 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-08-04 15:16:31 +00:00
|
|
|
GESTimelineTransition *
|
2010-06-02 14:50:07 +00:00
|
|
|
ges_timeline_transition_new (gint vtype)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2010-05-26 14:33:44 +00:00
|
|
|
GESTimelineTransition *ret = g_object_new
|
|
|
|
(GES_TYPE_TIMELINE_TRANSITION, NULL);
|
|
|
|
|
2010-06-02 16:57:10 +00:00
|
|
|
g_object_set (ret, "vtype", (gint) vtype, NULL);
|
2010-05-26 14:33:44 +00:00
|
|
|
return ret;
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
2010-05-27 10:02:10 +00:00
|
|
|
|
|
|
|
static GEnumClass *smpte_enum_class = NULL;
|
|
|
|
|
2010-06-02 16:57:10 +00:00
|
|
|
static void
|
2010-05-27 10:02:10 +00:00
|
|
|
_ensure_smpte_enum_class ()
|
|
|
|
{
|
2010-06-02 16:57:10 +00:00
|
|
|
/* is there a better way to do this? */
|
|
|
|
|
2010-05-27 10:02:10 +00:00
|
|
|
if (!smpte_enum_class) {
|
|
|
|
GstElement *element = gst_element_factory_make ("smpte", NULL);
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_GET_CLASS (element);
|
|
|
|
|
|
|
|
GParamSpec *pspec =
|
|
|
|
g_object_class_find_property (G_OBJECT_CLASS (element_class), "type");
|
|
|
|
|
|
|
|
smpte_enum_class = G_ENUM_CLASS (g_type_class_ref (pspec->value_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-02 16:57:10 +00:00
|
|
|
/* how many types could GType type if GType could type types? */
|
|
|
|
|
|
|
|
static GType
|
|
|
|
ges_type_timeline_transition_vtype_get_type (void)
|
|
|
|
{
|
|
|
|
_ensure_smpte_enum_class ();
|
|
|
|
|
|
|
|
static GType the_type = 0;
|
|
|
|
|
|
|
|
if (!the_type) {
|
|
|
|
GEnumValue *values, *src, *dst;
|
|
|
|
gint i, n;
|
|
|
|
|
|
|
|
n = smpte_enum_class->n_values;
|
|
|
|
|
|
|
|
/* plus one for sentinel, plus another for the crossfade GEnumValue */
|
|
|
|
values = g_new0 (GEnumValue, 2 + n);
|
|
|
|
|
|
|
|
values->value = 0;
|
|
|
|
values->value_name = "Cross-fade between two sources";
|
|
|
|
values->value_nick = "crossfade";
|
|
|
|
|
|
|
|
for (i = 0, dst = (values + 1), src = smpte_enum_class->values; i < n;
|
|
|
|
i++, dst++, src++) {
|
|
|
|
dst->value = src->value;
|
|
|
|
dst->value_nick = src->value_nick;
|
|
|
|
dst->value_name = src->value_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->value = 0;
|
|
|
|
dst->value_nick = NULL;
|
|
|
|
dst->value_name = NULL;
|
|
|
|
|
|
|
|
the_type = g_enum_register_static ("GESTimelineTransitionVType", values);
|
|
|
|
}
|
|
|
|
|
|
|
|
return the_type;
|
|
|
|
}
|
|
|
|
|
2010-05-27 10:02:10 +00:00
|
|
|
GESTimelineTransition *
|
|
|
|
ges_timeline_transition_new_for_nick (char *nick)
|
|
|
|
{
|
|
|
|
|
|
|
|
_ensure_smpte_enum_class ();
|
|
|
|
|
|
|
|
if (!strcmp ("crossfade", nick)) {
|
2010-06-02 14:50:07 +00:00
|
|
|
return ges_timeline_transition_new (0);
|
2010-05-27 10:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GEnumValue *value = g_enum_get_value_by_nick (smpte_enum_class, nick);
|
|
|
|
|
|
|
|
if (!value) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-02 14:50:07 +00:00
|
|
|
return ges_timeline_transition_new (value->value);
|
2010-05-27 10:02:10 +00:00
|
|
|
}
|