2013-06-26 21:08:57 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2013 Thibault Saunier <thibault.saunier@collabora.com>
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:gesgroup
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESGroup
|
2020-01-09 12:09:15 +00:00
|
|
|
* @short_description: Class for a collection of #GESContainer-s within
|
|
|
|
* a single timeline.
|
2013-06-26 21:08:57 +00:00
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* A #GESGroup controls one or more #GESContainer-s (usually #GESClip-s,
|
|
|
|
* but it can also control other #GESGroup-s). Its children must share
|
|
|
|
* the same #GESTimeline, but can otherwise lie in separate #GESLayer-s
|
|
|
|
* and have different timings.
|
2013-06-26 21:08:57 +00:00
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* To initialise a group, you may want to use ges_container_group(),
|
|
|
|
* and similarly use ges_container_ungroup() to dispose of it.
|
|
|
|
*
|
|
|
|
* A group will maintain the relative #GESTimelineElement:start times of
|
|
|
|
* its children, as well as their relative layer #GESLayer:priority.
|
|
|
|
* Therefore, if one of its children has its #GESTimelineElement:start
|
|
|
|
* set, all other children will have their #GESTimelineElement:start
|
|
|
|
* shifted by the same amount. Similarly, if one of its children moves to
|
|
|
|
* a new layer, the other children will also change layers to maintain the
|
|
|
|
* difference in their layer priorities. For example, if a child moves
|
|
|
|
* from a layer with #GESLayer:priority 1 to a layer with priority 3, then
|
|
|
|
* another child that was in a layer with priority 0 will move to the
|
|
|
|
* layer with priority 2.
|
|
|
|
*
|
|
|
|
* The #GESGroup:start of a group refers to the earliest start
|
|
|
|
* time of its children. If the group's #GESGroup:start is set, all the
|
|
|
|
* children will be shifted equally such that the earliest start time
|
|
|
|
* will match the set value. The #GESGroup:duration of a group is the
|
|
|
|
* difference between the earliest start time and latest end time of its
|
|
|
|
* children. If the group's #GESGroup:duration is increased, the children
|
|
|
|
* whose end time matches the end of the group will be extended
|
|
|
|
* accordingly. If it is decreased, then any child whose end time exceeds
|
|
|
|
* the new end time will also have their duration decreased accordingly.
|
|
|
|
*
|
|
|
|
* A group may span several layers, but for methods such as
|
|
|
|
* ges_timeline_element_get_layer_priority() and
|
|
|
|
* ges_timeline_element_edit() a group is considered to have a layer
|
|
|
|
* priority that is the highest #GESLayer:priority (numerically, the
|
|
|
|
* smallest) of all the layers it spans.
|
2013-06-26 21:08:57 +00:00
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
#include "ges-group.h"
|
|
|
|
#include "ges.h"
|
|
|
|
#include "ges-internal.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define parent_class ges_group_parent_class
|
|
|
|
|
|
|
|
struct _GESGroupPrivate
|
|
|
|
{
|
|
|
|
gboolean reseting_start;
|
|
|
|
|
|
|
|
guint32 max_layer_prio;
|
|
|
|
|
2020-04-18 15:49:31 +00:00
|
|
|
gboolean updating_priority;
|
2013-06-26 21:08:57 +00:00
|
|
|
/* This is used while were are setting ourselve a proper timing value,
|
|
|
|
* in this case the value should always be kept */
|
|
|
|
gboolean setting_value;
|
2020-04-21 10:36:58 +00:00
|
|
|
GHashTable *child_sigids;
|
2013-06-26 21:08:57 +00:00
|
|
|
};
|
|
|
|
|
2015-06-05 16:49:51 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GESLayer *layer;
|
|
|
|
gulong child_clip_changed_layer_sid;
|
|
|
|
gulong child_priority_changed_sid;
|
|
|
|
gulong child_group_priority_changed_sid;
|
|
|
|
} ChildSignalIds;
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2014-10-27 15:51:42 +00:00
|
|
|
PROP_START,
|
|
|
|
PROP_INPOINT,
|
|
|
|
PROP_DURATION,
|
|
|
|
PROP_MAX_DURATION,
|
|
|
|
PROP_PRIORITY,
|
2013-06-26 21:08:57 +00:00
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
2014-10-27 15:51:42 +00:00
|
|
|
static GParamSpec *properties[PROP_LAST] = { NULL, };
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GESGroup, ges_group, GES_TYPE_CONTAINER);
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
/****************************************************
|
|
|
|
* Our listening of children *
|
|
|
|
****************************************************/
|
|
|
|
static void
|
|
|
|
_update_our_values (GESGroup * group)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GESContainer *container = GES_CONTAINER (group);
|
|
|
|
guint32 min_layer_prio = G_MAXINT32, max_layer_prio = 0;
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
for (tmp = container->children; tmp; tmp = tmp->next) {
|
2013-06-26 21:08:57 +00:00
|
|
|
GESContainer *child = tmp->data;
|
|
|
|
|
|
|
|
if (GES_IS_CLIP (child)) {
|
|
|
|
GESLayer *layer = ges_clip_get_layer (GES_CLIP (child));
|
2020-04-21 10:36:58 +00:00
|
|
|
guint32 prio;
|
2018-03-14 23:59:04 +00:00
|
|
|
|
|
|
|
if (!layer)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
prio = ges_layer_get_priority (layer);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
min_layer_prio = MIN (prio, min_layer_prio);
|
|
|
|
max_layer_prio = MAX (prio, max_layer_prio);
|
2020-04-18 15:49:31 +00:00
|
|
|
gst_object_unref (layer);
|
2013-06-26 21:08:57 +00:00
|
|
|
} else if (GES_IS_GROUP (child)) {
|
2020-04-21 10:36:58 +00:00
|
|
|
guint32 prio = _PRIORITY (child), height = GES_CONTAINER_HEIGHT (child);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
min_layer_prio = MIN (prio, min_layer_prio);
|
2020-02-24 18:58:55 +00:00
|
|
|
max_layer_prio = MAX ((prio + height - 1), max_layer_prio);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min_layer_prio != _PRIORITY (group)) {
|
2020-04-18 15:49:31 +00:00
|
|
|
group->priv->updating_priority = TRUE;
|
2013-06-26 21:08:57 +00:00
|
|
|
_set_priority0 (GES_TIMELINE_ELEMENT (group), min_layer_prio);
|
2020-04-18 15:49:31 +00:00
|
|
|
group->priv->updating_priority = FALSE;
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
2020-01-09 12:09:15 +00:00
|
|
|
/* FIXME: max_layer_prio not used elsewhere
|
|
|
|
* We could use it to inform our parent group when our maximum has
|
|
|
|
* changed (which we don't currently do, to allow it to change its
|
|
|
|
* height) */
|
2013-06-26 21:08:57 +00:00
|
|
|
group->priv->max_layer_prio = max_layer_prio;
|
2020-04-21 10:36:58 +00:00
|
|
|
_ges_container_set_height (container, max_layer_prio - min_layer_prio + 1);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:49:31 +00:00
|
|
|
/* layer changed its priority in the timeline */
|
2014-11-30 23:34:38 +00:00
|
|
|
static void
|
|
|
|
_child_priority_changed_cb (GESLayer * layer,
|
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESTimelineElement * clip)
|
|
|
|
{
|
2020-04-18 15:49:31 +00:00
|
|
|
_update_our_values (GES_GROUP (clip->parent));
|
2014-11-30 23:34:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
static void
|
2020-04-21 10:36:58 +00:00
|
|
|
_child_clip_changed_layer_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED,
|
|
|
|
GESGroup * group)
|
2013-06-26 21:08:57 +00:00
|
|
|
{
|
2015-06-05 16:49:51 +00:00
|
|
|
ChildSignalIds *sigids;
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
sigids = g_hash_table_lookup (group->priv->child_sigids, clip);
|
2014-11-30 23:34:38 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
g_assert (sigids);
|
2015-06-05 16:49:51 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
if (sigids->layer) {
|
|
|
|
g_signal_handler_disconnect (sigids->layer,
|
|
|
|
sigids->child_priority_changed_sid);
|
2015-06-05 16:49:51 +00:00
|
|
|
sigids->child_priority_changed_sid = 0;
|
2020-04-21 10:36:58 +00:00
|
|
|
gst_object_unref (sigids->layer);
|
2015-06-05 16:49:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
sigids->layer = ges_clip_get_layer (GES_CLIP (clip));
|
|
|
|
|
|
|
|
if (sigids->layer) {
|
2015-06-05 16:49:51 +00:00
|
|
|
sigids->child_priority_changed_sid =
|
2020-04-21 10:36:58 +00:00
|
|
|
g_signal_connect (sigids->layer, "notify::priority",
|
2014-11-30 23:34:38 +00:00
|
|
|
(GCallback) _child_priority_changed_cb, clip);
|
2015-06-05 16:49:51 +00:00
|
|
|
}
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
_update_our_values (group);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_child_group_priority_changed (GESTimelineElement * child,
|
|
|
|
GParamSpec * arg G_GNUC_UNUSED, GESGroup * group)
|
|
|
|
{
|
2020-04-21 10:36:58 +00:00
|
|
|
_update_our_values (group);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************
|
|
|
|
* GESTimelineElement vmethods *
|
|
|
|
****************************************************/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_set_priority (GESTimelineElement * element, guint32 priority)
|
|
|
|
{
|
2020-04-21 10:36:58 +00:00
|
|
|
GList *layers;
|
|
|
|
GESTimeline *timeline = element->timeline;
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
if (GES_GROUP (element)->priv->updating_priority == TRUE
|
|
|
|
|| GES_TIMELINE_ELEMENT_BEING_EDITED (element))
|
2013-06-26 21:08:57 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
layers = timeline ? timeline->layers : NULL;
|
2013-06-26 21:08:57 +00:00
|
|
|
if (layers == NULL) {
|
|
|
|
GST_WARNING_OBJECT (element, "Not any layer in the timeline, not doing"
|
2020-04-21 10:36:58 +00:00
|
|
|
"anything, timeline: %" GST_PTR_FORMAT, timeline);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-01-09 12:09:15 +00:00
|
|
|
/* FIXME: why are we not shifting ->max_layer_prio? */
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
return timeline_tree_move (timeline_get_tree (timeline),
|
|
|
|
element, (gint64) (element->priority) - (gint64) priority, 0,
|
2020-05-15 13:25:01 +00:00
|
|
|
GES_EDGE_NONE, 0, NULL);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_set_start (GESTimelineElement * element, GstClockTime start)
|
|
|
|
{
|
2020-03-02 12:23:07 +00:00
|
|
|
GList *tmp, *children;
|
2013-06-26 21:08:57 +00:00
|
|
|
gint64 diff = start - _START (element);
|
|
|
|
GESContainer *container = GES_CONTAINER (element);
|
|
|
|
|
|
|
|
if (GES_GROUP (element)->priv->setting_value == TRUE)
|
|
|
|
/* Let GESContainer update itself */
|
|
|
|
return GES_TIMELINE_ELEMENT_CLASS (parent_class)->set_start (element,
|
|
|
|
start);
|
|
|
|
|
2020-04-20 12:13:48 +00:00
|
|
|
/* get copy of children, since GESContainer may resort the group */
|
|
|
|
children = ges_container_get_children (container, FALSE);
|
|
|
|
container->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES;
|
|
|
|
for (tmp = children; tmp; tmp = tmp->next)
|
|
|
|
_set_start0 (tmp->data, _START (tmp->data) + diff);
|
|
|
|
container->children_control_mode = GES_CHILDREN_UPDATE;
|
|
|
|
g_list_free_full (children, gst_object_unref);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_set_inpoint (GESTimelineElement * element, GstClockTime inpoint)
|
|
|
|
{
|
2020-03-10 11:35:23 +00:00
|
|
|
if (inpoint != 0) {
|
|
|
|
GST_WARNING_OBJECT (element, "The in-point of a group has no meaning,"
|
|
|
|
" it can not be set to a non-zero value");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_set_max_duration (GESTimelineElement * element, GstClockTime max_duration)
|
|
|
|
{
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (max_duration)) {
|
|
|
|
GST_WARNING_OBJECT (element, "The max-duration of a group has no "
|
|
|
|
"meaning, it can not be set to a valid GstClockTime value");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_set_duration (GESTimelineElement * element, GstClockTime duration)
|
|
|
|
{
|
2020-03-02 12:23:07 +00:00
|
|
|
GList *tmp, *children;
|
2013-06-26 21:08:57 +00:00
|
|
|
GstClockTime last_child_end = 0, new_end;
|
|
|
|
GESContainer *container = GES_CONTAINER (element);
|
|
|
|
GESGroupPrivate *priv = GES_GROUP (element)->priv;
|
|
|
|
|
|
|
|
if (priv->setting_value == TRUE)
|
|
|
|
/* Let GESContainer update itself */
|
|
|
|
return GES_TIMELINE_ELEMENT_CLASS (parent_class)->set_duration (element,
|
|
|
|
duration);
|
|
|
|
|
|
|
|
if (container->initiated_move == NULL) {
|
|
|
|
gboolean expending = (_DURATION (element) < duration);
|
|
|
|
|
|
|
|
new_end = _START (element) + duration;
|
2020-03-02 12:23:07 +00:00
|
|
|
/* get copy of children, since GESContainer may resort the group */
|
|
|
|
children = ges_container_get_children (container, FALSE);
|
2013-06-26 21:08:57 +00:00
|
|
|
container->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES;
|
2020-03-02 12:23:07 +00:00
|
|
|
for (tmp = children; tmp; tmp = tmp->next) {
|
2013-06-26 21:08:57 +00:00
|
|
|
GESTimelineElement *child = tmp->data;
|
|
|
|
GstClockTime n_dur;
|
|
|
|
|
|
|
|
if ((!expending && _END (child) > new_end) ||
|
|
|
|
(expending && (_END (child) >= _END (element)))) {
|
|
|
|
n_dur = MAX (0, ((gint64) (new_end - _START (child))));
|
|
|
|
_set_duration0 (child, n_dur);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
container->children_control_mode = GES_CHILDREN_UPDATE;
|
2020-03-02 12:23:07 +00:00
|
|
|
g_list_free_full (children, gst_object_unref);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (element); tmp; tmp = tmp->next) {
|
|
|
|
if (_DURATION (tmp->data))
|
|
|
|
last_child_end =
|
|
|
|
MAX (GES_TIMELINE_ELEMENT_END (tmp->data), last_child_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->setting_value = TRUE;
|
|
|
|
_set_duration0 (element, last_child_end - _START (element));
|
|
|
|
priv->setting_value = FALSE;
|
|
|
|
|
2019-05-02 15:41:10 +00:00
|
|
|
return -1;
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************
|
|
|
|
* *
|
|
|
|
* GESContainer virtual methods implementation *
|
|
|
|
* *
|
|
|
|
****************************************************/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_add_child (GESContainer * group, GESTimelineElement * child)
|
|
|
|
{
|
2020-04-21 10:36:58 +00:00
|
|
|
GESTimeline *timeline = GES_TIMELINE_ELEMENT_TIMELINE (group);
|
2013-06-26 21:08:57 +00:00
|
|
|
g_return_val_if_fail (GES_IS_CONTAINER (child), FALSE);
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
if (timeline && child->timeline != timeline) {
|
|
|
|
GST_WARNING_OBJECT (group, "Cannot add child %" GES_FORMAT
|
|
|
|
" because it belongs to timeline %" GST_PTR_FORMAT
|
|
|
|
" rather than the group's timeline %" GST_PTR_FORMAT,
|
|
|
|
GES_ARGS (child), child->timeline, timeline);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_child_added (GESContainer * group, GESTimelineElement * child)
|
|
|
|
{
|
2020-04-21 10:36:58 +00:00
|
|
|
GESGroup *self = GES_GROUP (group);
|
|
|
|
ChildSignalIds *sigids;
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2020-03-02 12:23:07 +00:00
|
|
|
/* NOTE: notifies are currently frozen by ges_container_add */
|
2020-04-21 10:36:58 +00:00
|
|
|
if (!GES_TIMELINE_ELEMENT_TIMELINE (group) && child->timeline) {
|
|
|
|
timeline_add_group (child->timeline, self);
|
|
|
|
timeline_emit_group_added (child->timeline, self);
|
2013-07-10 21:33:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
_update_our_values (self);
|
|
|
|
|
|
|
|
sigids = g_new0 (ChildSignalIds, 1);
|
|
|
|
/* doesn't take a ref to child since no data */
|
|
|
|
g_hash_table_insert (self->priv->child_sigids, child, sigids);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
if (GES_IS_CLIP (child)) {
|
2020-04-21 10:36:58 +00:00
|
|
|
sigids->layer = ges_clip_get_layer (GES_CLIP (child));
|
2015-06-05 16:49:51 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
sigids->child_clip_changed_layer_sid = g_signal_connect (child,
|
|
|
|
"notify::layer", (GCallback) _child_clip_changed_layer_cb, group);
|
2015-06-05 16:49:51 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
if (sigids->layer) {
|
|
|
|
sigids->child_priority_changed_sid = g_signal_connect (sigids->layer,
|
2015-06-05 16:49:51 +00:00
|
|
|
"notify::priority", (GCallback) _child_priority_changed_cb, child);
|
|
|
|
}
|
2020-04-21 10:36:58 +00:00
|
|
|
} else if (GES_IS_GROUP (child)) {
|
|
|
|
sigids->child_group_priority_changed_sid = g_signal_connect (child,
|
|
|
|
"notify::priority", (GCallback) _child_group_priority_changed, group);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-05 16:49:51 +00:00
|
|
|
static void
|
|
|
|
_disconnect_signals (GESGroup * group, GESTimelineElement * child,
|
|
|
|
ChildSignalIds * sigids)
|
|
|
|
{
|
|
|
|
if (sigids->child_group_priority_changed_sid) {
|
|
|
|
g_signal_handler_disconnect (child,
|
|
|
|
sigids->child_group_priority_changed_sid);
|
|
|
|
sigids->child_group_priority_changed_sid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sigids->child_clip_changed_layer_sid) {
|
|
|
|
g_signal_handler_disconnect (child, sigids->child_clip_changed_layer_sid);
|
|
|
|
sigids->child_clip_changed_layer_sid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sigids->child_priority_changed_sid) {
|
|
|
|
g_signal_handler_disconnect (sigids->layer,
|
|
|
|
sigids->child_priority_changed_sid);
|
|
|
|
sigids->child_priority_changed_sid = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
static void
|
|
|
|
_child_removed (GESContainer * group, GESTimelineElement * child)
|
|
|
|
{
|
2020-04-21 10:36:58 +00:00
|
|
|
GESGroup *self = GES_GROUP (group);
|
2015-06-05 16:49:51 +00:00
|
|
|
ChildSignalIds *sigids;
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2020-03-02 12:23:07 +00:00
|
|
|
/* NOTE: notifies are currently frozen by ges_container_add */
|
2013-06-26 21:08:57 +00:00
|
|
|
_ges_container_sort_children (group);
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
sigids = g_hash_table_lookup (self->priv->child_sigids, child);
|
|
|
|
|
|
|
|
g_assert (sigids);
|
|
|
|
_disconnect_signals (self, child, sigids);
|
|
|
|
g_hash_table_remove (self->priv->child_sigids, child);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
if (group->children == NULL) {
|
2013-06-26 21:08:57 +00:00
|
|
|
GST_FIXME_OBJECT (group, "Auto destroy myself?");
|
2019-01-23 12:07:58 +00:00
|
|
|
if (GES_TIMELINE_ELEMENT_TIMELINE (group))
|
2020-04-21 10:36:58 +00:00
|
|
|
timeline_remove_group (GES_TIMELINE_ELEMENT_TIMELINE (group), self);
|
2013-06-26 21:08:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:34:56 +00:00
|
|
|
_update_our_values (GES_GROUP (group));
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
_ungroup (GESContainer * group, gboolean recursive)
|
|
|
|
{
|
2016-02-16 12:49:57 +00:00
|
|
|
GPtrArray *children_array;
|
|
|
|
GESTimeline *timeline;
|
2013-06-26 21:08:57 +00:00
|
|
|
GList *children, *tmp, *ret = NULL;
|
|
|
|
|
2016-02-16 12:49:57 +00:00
|
|
|
/* We choose 16 just as an arbitrary value */
|
|
|
|
children_array = g_ptr_array_sized_new (16);
|
|
|
|
timeline = GES_TIMELINE_ELEMENT_TIMELINE (group);
|
|
|
|
|
2013-07-10 19:24:28 +00:00
|
|
|
children = ges_container_get_children (group, FALSE);
|
2013-06-26 21:08:57 +00:00
|
|
|
for (tmp = children; tmp; tmp = tmp->next) {
|
|
|
|
GESTimelineElement *child = tmp->data;
|
|
|
|
|
|
|
|
gst_object_ref (child);
|
|
|
|
ges_container_remove (group, child);
|
2016-02-16 12:49:57 +00:00
|
|
|
g_ptr_array_add (children_array, child);
|
2013-06-26 21:08:57 +00:00
|
|
|
ret = g_list_append (ret, child);
|
|
|
|
}
|
2016-03-11 16:29:08 +00:00
|
|
|
|
|
|
|
if (timeline)
|
2016-05-06 18:18:50 +00:00
|
|
|
timeline_emit_group_removed (timeline, (GESGroup *) group, children_array);
|
2016-02-16 12:49:57 +00:00
|
|
|
g_ptr_array_free (children_array, TRUE);
|
2013-06-26 21:08:57 +00:00
|
|
|
g_list_free_full (children, gst_object_unref);
|
|
|
|
|
2013-07-10 21:33:51 +00:00
|
|
|
/* No need to remove from the timeline here, this will be done in _child_removed */
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GESContainer *
|
|
|
|
_group (GList * containers)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GESTimeline *timeline = NULL;
|
2021-03-08 12:56:49 +00:00
|
|
|
GESContainer *ret = GES_CONTAINER (ges_group_new ());
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2013-07-10 21:33:51 +00:00
|
|
|
if (!containers)
|
|
|
|
return ret;
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
for (tmp = containers; tmp; tmp = tmp->next) {
|
|
|
|
if (!timeline) {
|
|
|
|
timeline = GES_TIMELINE_ELEMENT_TIMELINE (tmp->data);
|
|
|
|
} else if (timeline != GES_TIMELINE_ELEMENT_TIMELINE (tmp->data)) {
|
|
|
|
g_object_unref (ret);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-04-09 14:31:36 +00:00
|
|
|
if (!ges_container_add (ret, tmp->data)) {
|
|
|
|
GST_INFO ("%" GES_FORMAT " could not add child %p while"
|
|
|
|
" grouping", GES_ARGS (ret), tmp->data);
|
|
|
|
g_object_unref (ret);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 21:33:51 +00:00
|
|
|
/* No need to add to the timeline here, this will be done in _child_added */
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************
|
|
|
|
* *
|
|
|
|
* GObject virtual methods implementation *
|
|
|
|
* *
|
|
|
|
****************************************************/
|
|
|
|
static void
|
|
|
|
ges_group_get_property (GObject * object, guint property_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2014-10-27 15:51:42 +00:00
|
|
|
GESTimelineElement *self = GES_TIMELINE_ELEMENT (object);
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
switch (property_id) {
|
2014-10-27 15:51:42 +00:00
|
|
|
case PROP_START:
|
|
|
|
g_value_set_uint64 (value, self->start);
|
|
|
|
break;
|
|
|
|
case PROP_INPOINT:
|
|
|
|
g_value_set_uint64 (value, self->inpoint);
|
|
|
|
break;
|
|
|
|
case PROP_DURATION:
|
|
|
|
g_value_set_uint64 (value, self->duration);
|
|
|
|
break;
|
|
|
|
case PROP_MAX_DURATION:
|
|
|
|
g_value_set_uint64 (value, self->maxduration);
|
|
|
|
break;
|
|
|
|
case PROP_PRIORITY:
|
|
|
|
g_value_set_uint (value, self->priority);
|
|
|
|
break;
|
2013-06-26 21:08:57 +00:00
|
|
|
default:
|
2014-10-27 15:51:42 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_group_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2014-10-27 15:51:42 +00:00
|
|
|
GESTimelineElement *self = GES_TIMELINE_ELEMENT (object);
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
switch (property_id) {
|
2014-10-27 15:51:42 +00:00
|
|
|
case PROP_START:
|
|
|
|
ges_timeline_element_set_start (self, g_value_get_uint64 (value));
|
|
|
|
break;
|
|
|
|
case PROP_INPOINT:
|
|
|
|
ges_timeline_element_set_inpoint (self, g_value_get_uint64 (value));
|
|
|
|
break;
|
|
|
|
case PROP_DURATION:
|
|
|
|
ges_timeline_element_set_duration (self, g_value_get_uint64 (value));
|
|
|
|
break;
|
|
|
|
case PROP_PRIORITY:
|
|
|
|
ges_timeline_element_set_priority (self, g_value_get_uint (value));
|
|
|
|
break;
|
|
|
|
case PROP_MAX_DURATION:
|
|
|
|
ges_timeline_element_set_max_duration (self, g_value_get_uint64 (value));
|
|
|
|
break;
|
2013-06-26 21:08:57 +00:00
|
|
|
default:
|
2014-10-27 15:51:42 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
static void
|
|
|
|
ges_group_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
GESGroup *self = GES_GROUP (object);
|
|
|
|
|
|
|
|
g_clear_pointer (&self->priv->child_sigids, g_hash_table_unref);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
static void
|
|
|
|
ges_group_class_init (GESGroupClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GESContainerClass *container_class = GES_CONTAINER_CLASS (klass);
|
|
|
|
GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->get_property = ges_group_get_property;
|
|
|
|
object_class->set_property = ges_group_set_property;
|
2020-04-21 10:36:58 +00:00
|
|
|
object_class->dispose = ges_group_dispose;
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
element_class->set_duration = _set_duration;
|
|
|
|
element_class->set_inpoint = _set_inpoint;
|
2020-03-10 11:35:23 +00:00
|
|
|
element_class->set_max_duration = _set_max_duration;
|
2013-06-26 21:08:57 +00:00
|
|
|
element_class->set_start = _set_start;
|
|
|
|
element_class->set_priority = _set_priority;
|
2014-10-27 15:51:42 +00:00
|
|
|
|
|
|
|
/* We override start, inpoint, duration and max-duration from GESTimelineElement
|
|
|
|
* in order to makes sure those fields are not serialized.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* GESGroup:start:
|
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* An overwrite of the #GESTimelineElement:start property. For a
|
|
|
|
* #GESGroup, this is the earliest #GESTimelineElement:start time
|
|
|
|
* amongst its children.
|
2014-10-27 15:51:42 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_START] = g_param_spec_uint64 ("start", "Start",
|
|
|
|
"The position in the container", 0, G_MAXUINT64, 0,
|
|
|
|
G_PARAM_READWRITE | GES_PARAM_NO_SERIALIZATION);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GESGroup:in-point:
|
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* An overwrite of the #GESTimelineElement:in-point property. This has
|
|
|
|
* no meaning for a group and should not be set.
|
2014-10-27 15:51:42 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_INPOINT] =
|
|
|
|
g_param_spec_uint64 ("in-point", "In-point", "The in-point", 0,
|
|
|
|
G_MAXUINT64, 0, G_PARAM_READWRITE | GES_PARAM_NO_SERIALIZATION);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GESGroup:duration:
|
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* An overwrite of the #GESTimelineElement:duration property. For a
|
|
|
|
* #GESGroup, this is the difference between the earliest
|
|
|
|
* #GESTimelineElement:start time and the latest end time (given by
|
|
|
|
* #GESTimelineElement:start + #GESTimelineElement:duration) amongst
|
|
|
|
* its children.
|
2014-10-27 15:51:42 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_DURATION] =
|
|
|
|
g_param_spec_uint64 ("duration", "Duration", "The duration to use", 0,
|
|
|
|
G_MAXUINT64, GST_CLOCK_TIME_NONE,
|
|
|
|
G_PARAM_READWRITE | GES_PARAM_NO_SERIALIZATION);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GESGroup:max-duration:
|
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* An overwrite of the #GESTimelineElement:max-duration property. This
|
|
|
|
* has no meaning for a group and should not be set.
|
2014-10-27 15:51:42 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_MAX_DURATION] =
|
|
|
|
g_param_spec_uint64 ("max-duration", "Maximum duration",
|
|
|
|
"The maximum duration of the object", 0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | GES_PARAM_NO_SERIALIZATION);
|
|
|
|
|
|
|
|
/**
|
2020-01-09 12:09:15 +00:00
|
|
|
* GESGroup:priority:
|
2014-10-27 15:51:42 +00:00
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* An overwrite of the #GESTimelineElement:priority property.
|
|
|
|
* Setting #GESTimelineElement priorities is deprecated as all priority
|
|
|
|
* management is now done by GES itself.
|
2014-10-27 15:51:42 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_PRIORITY] = g_param_spec_uint ("priority", "Priority",
|
|
|
|
"The priority of the object", 0, G_MAXUINT, 0,
|
|
|
|
G_PARAM_READWRITE | GES_PARAM_NO_SERIALIZATION);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, PROP_LAST, properties);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
|
|
|
container_class->add_child = _add_child;
|
|
|
|
container_class->child_added = _child_added;
|
|
|
|
container_class->child_removed = _child_removed;
|
|
|
|
container_class->ungroup = _ungroup;
|
|
|
|
container_class->group = _group;
|
|
|
|
container_class->grouping_priority = 0;
|
|
|
|
}
|
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
static void
|
|
|
|
_free_sigid (gpointer mem)
|
|
|
|
{
|
|
|
|
ChildSignalIds *sigids = mem;
|
|
|
|
gst_clear_object (&sigids->layer);
|
|
|
|
g_free (mem);
|
|
|
|
}
|
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
static void
|
|
|
|
ges_group_init (GESGroup * self)
|
|
|
|
{
|
2018-09-06 01:55:02 +00:00
|
|
|
self->priv = ges_group_get_instance_private (self);
|
2013-06-26 21:08:57 +00:00
|
|
|
|
2020-04-21 10:36:58 +00:00
|
|
|
self->priv->child_sigids =
|
|
|
|
g_hash_table_new_full (NULL, NULL, NULL, _free_sigid);
|
2013-06-26 21:08:57 +00:00
|
|
|
}
|
2013-07-12 15:55:46 +00:00
|
|
|
|
|
|
|
/****************************************************
|
|
|
|
* *
|
|
|
|
* API implementation *
|
|
|
|
* *
|
|
|
|
****************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_group_new:
|
|
|
|
*
|
2020-01-09 12:09:15 +00:00
|
|
|
* Created a new empty group. You may wish to use
|
|
|
|
* ges_container_group() instead, which can return a different
|
|
|
|
* #GESContainer subclass if possible.
|
2013-07-12 15:55:46 +00:00
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating): The new empty group.
|
2013-07-12 15:55:46 +00:00
|
|
|
*/
|
|
|
|
GESGroup *
|
|
|
|
ges_group_new (void)
|
|
|
|
{
|
2020-03-25 01:23:16 +00:00
|
|
|
GESGroup *res;
|
|
|
|
GESAsset *asset = ges_asset_request (GES_TYPE_GROUP, NULL, NULL);
|
|
|
|
|
|
|
|
res = GES_GROUP (ges_asset_extract (asset, NULL));
|
|
|
|
gst_object_unref (asset);
|
|
|
|
|
|
|
|
return res;
|
2013-07-12 15:55:46 +00:00
|
|
|
}
|