2013-01-10 21:50:54 +00:00
|
|
|
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
|
|
|
|
/*
|
|
|
|
* gst-editing-services
|
|
|
|
* Copyright (C) 2013 Thibault Saunier <thibault.saunier@collabora.com>
|
|
|
|
*
|
|
|
|
* gst-editing-services is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* gst-editing-services 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 Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
|
|
|
|
*/
|
|
|
|
|
2013-01-25 14:26:14 +00:00
|
|
|
/* This class warps a GESBaseTransitionClip, letting any implementation
|
|
|
|
* of a GESBaseTransitionClip to be used.
|
2013-01-10 21:50:54 +00:00
|
|
|
*
|
|
|
|
* NOTE: This is for internal use exclusively
|
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2013-01-10 21:50:54 +00:00
|
|
|
|
|
|
|
#include "ges-auto-transition.h"
|
|
|
|
#include "ges-internal.h"
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
DESTROY_ME,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint auto_transition_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GESAutoTransition, ges_auto_transition, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
neighbour_changed_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED,
|
2013-01-10 21:50:54 +00:00
|
|
|
GESAutoTransition * self)
|
|
|
|
{
|
|
|
|
gint64 new_duration;
|
2016-06-20 00:02:06 +00:00
|
|
|
GESTimelineElement *parent =
|
|
|
|
ges_timeline_element_get_toplevel_parent (GES_TIMELINE_ELEMENT (clip));
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (ELEMENT_FLAG_IS_SET (parent, GES_TIMELINE_ELEMENT_SET_SIMPLE)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-11 17:19:44 +00:00
|
|
|
if (parent) {
|
2016-06-20 00:02:06 +00:00
|
|
|
GESTimelineElement *prev_topparent =
|
|
|
|
ges_timeline_element_get_toplevel_parent (GES_TIMELINE_ELEMENT
|
|
|
|
(self->next_source));
|
|
|
|
GESTimelineElement *next_topparent =
|
|
|
|
ges_timeline_element_get_toplevel_parent (GES_TIMELINE_ELEMENT
|
|
|
|
(self->previous_source));
|
|
|
|
|
2019-03-01 22:32:19 +00:00
|
|
|
if (ELEMENT_FLAG_IS_SET (prev_topparent, GES_TIMELINE_ELEMENT_SET_SIMPLE) ||
|
|
|
|
ELEMENT_FLAG_IS_SET (next_topparent, GES_TIMELINE_ELEMENT_SET_SIMPLE)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-20 00:02:06 +00:00
|
|
|
if (parent == prev_topparent && parent == next_topparent) {
|
|
|
|
GST_DEBUG_OBJECT (self,
|
|
|
|
"Moving all inside the same group, nothing to do");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2019-02-08 19:44:39 +00:00
|
|
|
if (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (self->next_source) !=
|
|
|
|
GES_TIMELINE_ELEMENT_LAYER_PRIORITY (self->previous_source)) {
|
2013-01-10 21:50:54 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "Destroy changed layer");
|
|
|
|
g_signal_emit (self, auto_transition_signals[DESTROY_ME], 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_duration =
|
2013-01-15 13:52:17 +00:00
|
|
|
(_START (self->previous_source) +
|
|
|
|
_DURATION (self->previous_source)) - _START (self->next_source);
|
2013-01-10 21:50:54 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
if (new_duration <= 0 || new_duration >= _DURATION (self->previous_source)
|
|
|
|
|| new_duration >= _DURATION (self->next_source)) {
|
2013-01-10 21:50:54 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "Destroy %" G_GINT64_FORMAT " not a valid duration",
|
|
|
|
new_duration);
|
|
|
|
g_signal_emit (self, auto_transition_signals[DESTROY_ME], 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-31 12:16:05 +00:00
|
|
|
self->positioning = TRUE;
|
2020-03-05 18:56:28 +00:00
|
|
|
ELEMENT_SET_FLAG (self->transition_clip, GES_TIMELINE_ELEMENT_SET_SIMPLE);
|
2013-01-17 02:16:02 +00:00
|
|
|
_set_start0 (GES_TIMELINE_ELEMENT (self->transition_clip),
|
2013-01-15 13:52:17 +00:00
|
|
|
_START (self->next_source));
|
2013-01-17 02:16:02 +00:00
|
|
|
_set_duration0 (GES_TIMELINE_ELEMENT (self->transition_clip), new_duration);
|
2020-03-10 21:54:56 +00:00
|
|
|
ELEMENT_UNSET_FLAG (self->transition_clip, GES_TIMELINE_ELEMENT_SET_SIMPLE);
|
2015-05-31 12:16:05 +00:00
|
|
|
self->positioning = FALSE;
|
2013-01-10 21:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
_track_changed_cb (GESTrackElement * track_element,
|
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESAutoTransition * self)
|
2013-01-10 21:50:54 +00:00
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
if (ges_track_element_get_track (track_element) == NULL) {
|
2013-01-10 21:50:54 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "Neighboor %" GST_PTR_FORMAT
|
2013-02-15 02:34:48 +00:00
|
|
|
" removed from track ... auto destructing", track_element);
|
2013-01-10 21:50:54 +00:00
|
|
|
|
|
|
|
g_signal_emit (self, auto_transition_signals[DESTROY_ME], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_auto_transition_init (GESAutoTransition * ges_auto_transition)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_auto_transition_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GESAutoTransition *self = GES_AUTO_TRANSITION (object);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (self->previous_source,
|
|
|
|
neighbour_changed_cb, self);
|
|
|
|
g_signal_handlers_disconnect_by_func (self->next_source, neighbour_changed_cb,
|
|
|
|
self);
|
|
|
|
g_signal_handlers_disconnect_by_func (self->next_source, _track_changed_cb,
|
|
|
|
self);
|
|
|
|
g_signal_handlers_disconnect_by_func (self->previous_source,
|
|
|
|
_track_changed_cb, self);
|
|
|
|
|
|
|
|
g_free (self->key);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (ges_auto_transition_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_auto_transition_class_init (GESAutoTransitionClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
auto_transition_signals[DESTROY_ME] =
|
|
|
|
g_signal_new ("destroy-me", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, 0, NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
object_class->finalize = ges_auto_transition_finalize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GESAutoTransition *
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_auto_transition_new (GESTrackElement * transition,
|
|
|
|
GESTrackElement * previous_source, GESTrackElement * next_source)
|
2013-01-10 21:50:54 +00:00
|
|
|
{
|
|
|
|
GESAutoTransition *self = g_object_new (GES_TYPE_AUTO_TRANSITION, NULL);
|
|
|
|
|
|
|
|
self->previous_source = previous_source;
|
|
|
|
self->next_source = next_source;
|
|
|
|
self->transition = transition;
|
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
self->previous_clip =
|
|
|
|
GES_CLIP (GES_TIMELINE_ELEMENT_PARENT (previous_source));
|
|
|
|
self->next_clip = GES_CLIP (GES_TIMELINE_ELEMENT_PARENT (next_source));
|
|
|
|
self->transition_clip = GES_CLIP (GES_TIMELINE_ELEMENT_PARENT (transition));
|
2013-01-10 21:50:54 +00:00
|
|
|
|
|
|
|
g_signal_connect (previous_source, "notify::start",
|
|
|
|
G_CALLBACK (neighbour_changed_cb), self);
|
2016-06-20 00:02:06 +00:00
|
|
|
g_signal_connect_after (previous_source, "notify::priority",
|
2013-01-10 21:50:54 +00:00
|
|
|
G_CALLBACK (neighbour_changed_cb), self);
|
|
|
|
g_signal_connect (next_source, "notify::start",
|
|
|
|
G_CALLBACK (neighbour_changed_cb), self);
|
|
|
|
g_signal_connect (next_source, "notify::priority",
|
|
|
|
G_CALLBACK (neighbour_changed_cb), self);
|
|
|
|
g_signal_connect (previous_source, "notify::duration",
|
|
|
|
G_CALLBACK (neighbour_changed_cb), self);
|
|
|
|
g_signal_connect (next_source, "notify::duration",
|
|
|
|
G_CALLBACK (neighbour_changed_cb), self);
|
|
|
|
|
|
|
|
g_signal_connect (next_source, "notify::track",
|
|
|
|
G_CALLBACK (_track_changed_cb), self);
|
|
|
|
g_signal_connect (previous_source, "notify::track",
|
|
|
|
G_CALLBACK (_track_changed_cb), self);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "Created transition %" GST_PTR_FORMAT
|
2017-11-07 14:26:58 +00:00
|
|
|
" between %" GST_PTR_FORMAT "[%" GST_TIME_FORMAT
|
2017-11-07 13:15:58 +00:00
|
|
|
" - %" GST_TIME_FORMAT "] and: %" GST_PTR_FORMAT
|
2017-11-07 14:26:58 +00:00
|
|
|
"[%" GST_TIME_FORMAT " - %" GST_TIME_FORMAT "]"
|
2013-01-10 21:50:54 +00:00
|
|
|
" in layer nb %i, start: %" GST_TIME_FORMAT " duration: %"
|
2017-11-07 13:15:58 +00:00
|
|
|
GST_TIME_FORMAT, transition, previous_source,
|
|
|
|
GST_TIME_ARGS (_START (previous_source)),
|
|
|
|
GST_TIME_ARGS (_END (previous_source)),
|
|
|
|
next_source,
|
|
|
|
GST_TIME_ARGS (_START (next_source)),
|
|
|
|
GST_TIME_ARGS (_END (next_source)),
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_get_priority (ges_clip_get_layer
|
2013-01-20 15:42:29 +00:00
|
|
|
(self->previous_clip)),
|
2013-01-15 13:52:17 +00:00
|
|
|
GST_TIME_ARGS (_START (transition)),
|
|
|
|
GST_TIME_ARGS (_DURATION (transition)));
|
2013-01-10 21:50:54 +00:00
|
|
|
|
|
|
|
self->key = g_strdup_printf ("%p%p", self->previous_source,
|
|
|
|
self->next_source);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
2019-03-01 22:32:19 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
ges_auto_transition_update (GESAutoTransition * self)
|
|
|
|
{
|
|
|
|
GST_INFO ("Updating info %s",
|
|
|
|
GES_TIMELINE_ELEMENT_NAME (self->transition_clip));
|
|
|
|
neighbour_changed_cb (self->previous_clip, NULL, self);
|
|
|
|
}
|