ges: Move GESClipFlags to GESTimelineElementFlags

Keeping it internal

And add an internal method to get layer priority for GESTimelineElements
(dirty implementation to make it simple for now)
This commit is contained in:
Thibault Saunier 2019-02-09 18:59:08 -03:00 committed by Thibault Saunier
parent 85e4262917
commit 69456e4f14
3 changed files with 57 additions and 30 deletions

View file

@ -50,29 +50,12 @@ static gboolean _roll_end (GESTimelineElement * element, GstClockTime end);
static gboolean _trim (GESTimelineElement * element, GstClockTime start);
static void _compute_height (GESContainer * container);
typedef enum
{
GES_CLIP_IS_SPLITTING = (1 << 0),
GES_CLIP_IS_MOVING = (1 << 1),
} GESClipFlags;
#define FLAGS(obj) (GES_CLIP(obj)->priv->flags)
#define SET_FLAG(obj,flag) (FLAGS(obj) |= (flag))
#define UNSET_FLAG(obj,flag) (FLAGS(obj) &= ~(flag))
#define FLAG_IS_SET(obj,flag) (FLAGS(obj) == (flag))
struct _GESClipPrivate
{
/*< public > */
GESLayer *layer;
/*< private > */
/* Set to TRUE when the clip is doing updates of track element
* properties so we don't end up in infinite property update loops
*/
GESClipFlags flags;
guint nb_effects;
GList *copied_track_elements;
@ -203,10 +186,10 @@ _set_duration (GESTimelineElement * element, GstClockTime duration)
if (child != container->initiated_move) {
/* Make the snapping happen if in a timeline */
timeline = GES_TIMELINE_ELEMENT_TIMELINE (child);
if (timeline == NULL || FLAG_IS_SET (element, GES_CLIP_IS_SPLITTING) ||
(ges_timeline_trim_object_simple (timeline, child,
NULL, GES_EDGE_END, _START (child) + duration,
TRUE) == FALSE)) {
if (timeline == NULL
|| ELEMENT_FLAG_IS_SET (element, GES_CLIP_IS_SPLITTING)
|| (ges_timeline_trim_object_simple (timeline, child, NULL,
GES_EDGE_END, _START (child) + duration, TRUE) == FALSE)) {
_set_duration0 (GES_TIMELINE_ELEMENT (child), duration);
}
}
@ -868,7 +851,6 @@ ges_clip_init (GESClip * self)
/* FIXME, check why it was done this way _DURATION (self) = GST_SECOND; */
self->priv->layer = NULL;
self->priv->nb_effects = 0;
self->priv->flags = 0;
}
/**
@ -1014,7 +996,7 @@ ges_clip_set_layer (GESClip * clip, GESLayer * layer)
* it is actually the result of a move between layer (as we know
* that it will be added to another layer right after, and this
* is what imports here.) */
if (!FLAG_IS_SET (clip, GES_CLIP_IS_MOVING))
if (!ELEMENT_FLAG_IS_SET (clip, GES_CLIP_IS_MOVING))
g_object_notify_by_pspec (G_OBJECT (clip), properties[PROP_LAYER]);
}
@ -1051,9 +1033,9 @@ ges_clip_set_moving_from_layer (GESClip * clip, gboolean is_moving)
g_return_if_fail (GES_IS_CLIP (clip));
if (is_moving)
SET_FLAG (clip, GES_CLIP_IS_MOVING);
ELEMENT_SET_FLAG (clip, GES_CLIP_IS_MOVING);
else
UNSET_FLAG (clip, GES_CLIP_IS_MOVING);
ELEMENT_UNSET_FLAG (clip, GES_CLIP_IS_MOVING);
}
/**
@ -1072,7 +1054,7 @@ ges_clip_is_moving_from_layer (GESClip * clip)
{
g_return_val_if_fail (GES_IS_CLIP (clip), FALSE);
return FLAG_IS_SET (clip, GES_CLIP_IS_MOVING);
return ELEMENT_FLAG_IS_SET (clip, GES_CLIP_IS_MOVING);
}
/**
@ -1105,7 +1087,7 @@ ges_clip_move_to_layer (GESClip * clip, GESLayer * layer)
GST_DEBUG_OBJECT (clip, "moving to layer %p, priority: %d", layer,
ges_layer_get_priority (layer));
SET_FLAG (clip, GES_CLIP_IS_MOVING);
ELEMENT_SET_FLAG (clip, GES_CLIP_IS_MOVING);
gst_object_ref (clip);
ret = ges_layer_remove_clip (current_layer, clip);
@ -1115,7 +1097,7 @@ ges_clip_move_to_layer (GESClip * clip, GESLayer * layer)
}
ret = ges_layer_add_clip (layer, clip);
UNSET_FLAG (clip, GES_CLIP_IS_MOVING);
ELEMENT_UNSET_FLAG (clip, GES_CLIP_IS_MOVING);
gst_object_unref (clip);
g_object_notify_by_pspec (G_OBJECT (clip), properties[PROP_LAYER]);
@ -1424,9 +1406,9 @@ ges_clip_split (GESClip * clip, guint64 position)
position - start + inpoint);
}
SET_FLAG (clip, GES_CLIP_IS_SPLITTING);
ELEMENT_SET_FLAG (clip, GES_CLIP_IS_SPLITTING);
_set_duration0 (GES_TIMELINE_ELEMENT (clip), old_duration);
UNSET_FLAG (clip, GES_CLIP_IS_SPLITTING);
ELEMENT_UNSET_FLAG (clip, GES_CLIP_IS_SPLITTING);
if (GES_TIMELINE_ELEMENT_TIMELINE (clip)) {
for (tmp = GES_CONTAINER_CHILDREN (new_object); tmp; tmp = tmp->next) {

View file

@ -394,8 +394,25 @@ G_GNUC_INTERNAL GESVideoTestSource * ges_video_test_source_new (void);
/****************************************************
* GESTimelineElement *
****************************************************/
typedef enum
{
GES_CLIP_IS_SPLITTING = (1 << 0),
GES_CLIP_IS_MOVING = (1 << 1),
GES_TIMELINE_ELEMENT_SET_SIMPLE = (1 << 2),
} GESTimelineElementFlags;
G_GNUC_INTERNAL gdouble ges_timeline_element_get_media_duration_factor(GESTimelineElement *self);
G_GNUC_INTERNAL GESTimelineElement * ges_timeline_element_get_copied_from (GESTimelineElement *self);
G_GNUC_INTERNAL GESTimelineElementFlags ges_timeline_element_flags (GESTimelineElement *self);
G_GNUC_INTERNAL void ges_timeline_element_set_flags (GESTimelineElement *self, GESTimelineElementFlags flags);
/* FIXME: Provide a clean way to get layer prio generically */
G_GNUC_INTERNAL gint32 _layer_priority (GESTimelineElement * element);
#define ELEMENT_FLAGS(obj) (ges_timeline_element_flags (GES_TIMELINE_ELEMENT(obj)))
#define ELEMENT_SET_FLAG(obj,flag) (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) | (flag))))
#define ELEMENT_UNSET_FLAG(obj,flag) (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) & ~(flag))))
#define ELEMENT_FLAG_IS_SET(obj,flag) ((ELEMENT_FLAGS (obj) & (flag)) == (flag))
/******************************
* GESMultiFile internal API *

View file

@ -96,6 +96,8 @@ struct _GESTimelineElementPrivate
GHashTable *children_props;
GESTimelineElement *copied_from;
GESTimelineElementFlags flags;
};
typedef struct
@ -1903,3 +1905,29 @@ ges_timeline_element_get_copied_from (GESTimelineElement * self)
self->priv->copied_from = NULL;
return copied_from;
}
GESTimelineElementFlags
ges_timeline_element_flags (GESTimelineElement * self)
{
return self->priv->flags;
}
gint32
_layer_priority (GESTimelineElement * element)
{
if (GES_IS_CLIP (element))
return ges_clip_get_layer_priority (GES_CLIP (element));
if (GES_IS_TRACK_ELEMENT (element))
return element->priority / LAYER_HEIGHT;
return element->priority;
}
void
ges_timeline_element_set_flags (GESTimelineElement * self,
GESTimelineElementFlags flags)
{
self->priv->flags = flags;
}