mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
timelineobject: Give a direct access to the list of TrackObject
Avoid to have to copy the list each time we want to access it
This commit is contained in:
parent
f8037f857d
commit
5772bd4c91
2 changed files with 29 additions and 33 deletions
|
@ -119,9 +119,6 @@ struct _GESTimelineObjectPrivate
|
||||||
GESTimelineLayer *layer;
|
GESTimelineLayer *layer;
|
||||||
|
|
||||||
/*< private > */
|
/*< private > */
|
||||||
/* A list of TrackObject controlled by this TimelineObject sorted by
|
|
||||||
* priority */
|
|
||||||
GList *trackobjects;
|
|
||||||
|
|
||||||
/* Set to TRUE when the timelineobject is doing updates of track object
|
/* Set to TRUE when the timelineobject is doing updates of track object
|
||||||
* properties so we don't end up in infinite property update loops
|
* properties so we don't end up in infinite property update loops
|
||||||
|
@ -404,7 +401,7 @@ ges_timeline_object_init (GESTimelineObject * self)
|
||||||
GES_TYPE_TIMELINE_OBJECT, GESTimelineObjectPrivate);
|
GES_TYPE_TIMELINE_OBJECT, GESTimelineObjectPrivate);
|
||||||
self->duration = GST_SECOND;
|
self->duration = GST_SECOND;
|
||||||
self->height = 1;
|
self->height = 1;
|
||||||
self->priv->trackobjects = NULL;
|
self->trackobjects = NULL;
|
||||||
self->priv->layer = NULL;
|
self->priv->layer = NULL;
|
||||||
self->priv->nb_effects = 0;
|
self->priv->nb_effects = 0;
|
||||||
self->priv->is_moving = FALSE;
|
self->priv->is_moving = FALSE;
|
||||||
|
@ -484,7 +481,7 @@ void
|
||||||
default_set_max_duration (GESTimelineObject * object, guint64 maxduration)
|
default_set_max_duration (GESTimelineObject * object, guint64 maxduration)
|
||||||
{
|
{
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp))
|
for (tmp = object->trackobjects; tmp; tmp = g_list_next (tmp))
|
||||||
g_object_set (tmp->data, "max-duration", maxduration, NULL);
|
g_object_set (tmp->data, "max-duration", maxduration, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,7 +565,7 @@ ges_timeline_object_add_track_object (GESTimelineObject * object, GESTrackObject
|
||||||
GST_DEBUG
|
GST_DEBUG
|
||||||
("Moving non on top effect under other TrackObject-s, nb effects %i",
|
("Moving non on top effect under other TrackObject-s, nb effects %i",
|
||||||
priv->nb_effects);
|
priv->nb_effects);
|
||||||
for (tmp = g_list_nth (priv->trackobjects, priv->nb_effects); tmp;
|
for (tmp = g_list_nth (object->trackobjects, priv->nb_effects); tmp;
|
||||||
tmp = tmp->next) {
|
tmp = tmp->next) {
|
||||||
GESTrackObject *tmpo = GES_TRACK_OBJECT (tmp->data);
|
GESTrackObject *tmpo = GES_TRACK_OBJECT (tmp->data);
|
||||||
|
|
||||||
|
@ -582,8 +579,8 @@ ges_timeline_object_add_track_object (GESTimelineObject * object, GESTrackObject
|
||||||
priv->nb_effects++;
|
priv->nb_effects++;
|
||||||
}
|
}
|
||||||
|
|
||||||
object->priv->trackobjects =
|
object->trackobjects =
|
||||||
g_list_insert_sorted_with_data (object->priv->trackobjects, trobj,
|
g_list_insert_sorted_with_data (object->trackobjects, trobj,
|
||||||
(GCompareDataFunc) sort_track_effects, object);
|
(GCompareDataFunc) sort_track_effects, object);
|
||||||
|
|
||||||
ges_track_object_set_start (trobj, object->start);
|
ges_track_object_set_start (trobj, object->start);
|
||||||
|
@ -653,7 +650,7 @@ ges_timeline_object_release_track_object (GESTimelineObject * object,
|
||||||
GST_DEBUG ("object:%p, trackobject:%p", object, trackobject);
|
GST_DEBUG ("object:%p, trackobject:%p", object, trackobject);
|
||||||
klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
|
klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
|
||||||
|
|
||||||
if (!(g_list_find (object->priv->trackobjects, trackobject))) {
|
if (!(g_list_find (object->trackobjects, trackobject))) {
|
||||||
GST_WARNING ("TrackObject isn't controlled by this object");
|
GST_WARNING ("TrackObject isn't controlled by this object");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -677,8 +674,7 @@ ges_timeline_object_release_track_object (GESTimelineObject * object,
|
||||||
object->priv->mappings = g_list_delete_link (object->priv->mappings, tmp);
|
object->priv->mappings = g_list_delete_link (object->priv->mappings, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
object->priv->trackobjects =
|
object->trackobjects = g_list_remove (object->trackobjects, trackobject);
|
||||||
g_list_remove (object->priv->trackobjects, trackobject);
|
|
||||||
|
|
||||||
if (GES_IS_TRACK_EFFECT (trackobject)) {
|
if (GES_IS_TRACK_EFFECT (trackobject)) {
|
||||||
/* emit 'object-removed' */
|
/* emit 'object-removed' */
|
||||||
|
@ -787,7 +783,7 @@ ges_timeline_object_set_start_internal (GESTimelineObject * object,
|
||||||
|
|
||||||
object->priv->ignore_notifies = TRUE;
|
object->priv->ignore_notifies = TRUE;
|
||||||
|
|
||||||
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
for (tmp = object->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
||||||
tr = (GESTrackObject *) tmp->data;
|
tr = (GESTrackObject *) tmp->data;
|
||||||
map = find_object_mapping (object, tr);
|
map = find_object_mapping (object, tr);
|
||||||
|
|
||||||
|
@ -848,7 +844,7 @@ ges_timeline_object_set_inpoint_internal (GESTimelineObject * object,
|
||||||
GST_DEBUG ("object:%p, inpoint:%" GST_TIME_FORMAT,
|
GST_DEBUG ("object:%p, inpoint:%" GST_TIME_FORMAT,
|
||||||
object, GST_TIME_ARGS (inpoint));
|
object, GST_TIME_ARGS (inpoint));
|
||||||
|
|
||||||
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
for (tmp = object->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
||||||
tr = (GESTrackObject *) tmp->data;
|
tr = (GESTrackObject *) tmp->data;
|
||||||
|
|
||||||
if (ges_track_object_is_locked (tr))
|
if (ges_track_object_is_locked (tr))
|
||||||
|
@ -898,7 +894,7 @@ ges_timeline_object_set_duration_internal (GESTimelineObject * object,
|
||||||
snap = timeline && priv->initiated_move == NULL ? TRUE : FALSE;
|
snap = timeline && priv->initiated_move == NULL ? TRUE : FALSE;
|
||||||
|
|
||||||
object->priv->ignore_notifies = TRUE;
|
object->priv->ignore_notifies = TRUE;
|
||||||
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
for (tmp = object->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
||||||
tr = (GESTrackObject *) tmp->data;
|
tr = (GESTrackObject *) tmp->data;
|
||||||
|
|
||||||
if (ges_track_object_is_locked (tr)) {
|
if (ges_track_object_is_locked (tr)) {
|
||||||
|
@ -953,7 +949,7 @@ ges_timeline_object_set_priority_internal (GESTimelineObject * object,
|
||||||
get_layer_priorities (priv->layer, &layer_min_gnl_prio, &layer_max_gnl_prio);
|
get_layer_priorities (priv->layer, &layer_min_gnl_prio, &layer_max_gnl_prio);
|
||||||
|
|
||||||
priv->ignore_notifies = TRUE;
|
priv->ignore_notifies = TRUE;
|
||||||
for (tmp = priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
for (tmp = object->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
||||||
tr = (GESTrackObject *) tmp->data;
|
tr = (GESTrackObject *) tmp->data;
|
||||||
map = find_object_mapping (object, tr);
|
map = find_object_mapping (object, tr);
|
||||||
|
|
||||||
|
@ -979,7 +975,7 @@ ges_timeline_object_set_priority_internal (GESTimelineObject * object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->trackobjects = g_list_sort_with_data (priv->trackobjects,
|
object->trackobjects = g_list_sort_with_data (object->trackobjects,
|
||||||
(GCompareDataFunc) sort_track_effects, object);
|
(GCompareDataFunc) sort_track_effects, object);
|
||||||
priv->ignore_notifies = FALSE;
|
priv->ignore_notifies = FALSE;
|
||||||
|
|
||||||
|
@ -1120,7 +1116,7 @@ ges_timeline_object_find_track_object (GESTimelineObject * object,
|
||||||
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
|
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
|
||||||
g_return_val_if_fail (GES_IS_TRACK (track), NULL);
|
g_return_val_if_fail (GES_IS_TRACK (track), NULL);
|
||||||
|
|
||||||
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
for (tmp = object->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
||||||
otmp = (GESTrackObject *) tmp->data;
|
otmp = (GESTrackObject *) tmp->data;
|
||||||
|
|
||||||
if (ges_track_object_get_track (otmp) == track) {
|
if (ges_track_object_get_track (otmp) == track) {
|
||||||
|
@ -1177,7 +1173,7 @@ ges_timeline_object_get_track_objects (GESTimelineObject * object)
|
||||||
|
|
||||||
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
|
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
|
||||||
|
|
||||||
ret = g_list_copy (object->priv->trackobjects);
|
ret = g_list_copy (object->trackobjects);
|
||||||
|
|
||||||
for (tmp = ret; tmp; tmp = tmp->next) {
|
for (tmp = ret; tmp; tmp = tmp->next) {
|
||||||
g_object_ref (tmp->data);
|
g_object_ref (tmp->data);
|
||||||
|
@ -1235,7 +1231,7 @@ ges_timeline_object_get_top_effects (GESTimelineObject * object)
|
||||||
object->priv->nb_effects);
|
object->priv->nb_effects);
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
|
||||||
for (tmp = object->priv->trackobjects, i = 0; i < object->priv->nb_effects;
|
for (tmp = object->trackobjects, i = 0; i < object->priv->nb_effects;
|
||||||
tmp = tmp->next, i++) {
|
tmp = tmp->next, i++) {
|
||||||
ret = g_list_append (ret, g_object_ref (tmp->data));
|
ret = g_list_append (ret, g_object_ref (tmp->data));
|
||||||
}
|
}
|
||||||
|
@ -1285,12 +1281,10 @@ ges_timeline_object_set_top_effect_priority (GESTimelineObject * object,
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
guint current_prio;
|
guint current_prio;
|
||||||
GESTrackObject *tck_obj;
|
GESTrackObject *tck_obj;
|
||||||
GESTimelineObjectPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
|
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
|
||||||
|
|
||||||
tck_obj = GES_TRACK_OBJECT (effect);
|
tck_obj = GES_TRACK_OBJECT (effect);
|
||||||
priv = object->priv;
|
|
||||||
current_prio = ges_track_object_get_priority (tck_obj);
|
current_prio = ges_track_object_get_priority (tck_obj);
|
||||||
|
|
||||||
/* We don't change the priority */
|
/* We don't change the priority */
|
||||||
|
@ -1314,7 +1308,7 @@ ges_timeline_object_set_top_effect_priority (GESTimelineObject * object,
|
||||||
inc = +1;
|
inc = +1;
|
||||||
|
|
||||||
ges_track_object_set_priority (tck_obj, newpriority);
|
ges_track_object_set_priority (tck_obj, newpriority);
|
||||||
for (tmp = priv->trackobjects; tmp; tmp = tmp->next) {
|
for (tmp = object->trackobjects; tmp; tmp = tmp->next) {
|
||||||
GESTrackObject *tmpo = GES_TRACK_OBJECT (tmp->data);
|
GESTrackObject *tmpo = GES_TRACK_OBJECT (tmp->data);
|
||||||
guint tck_priority = ges_track_object_get_priority (tmpo);
|
guint tck_priority = ges_track_object_get_priority (tmpo);
|
||||||
|
|
||||||
|
@ -1324,7 +1318,7 @@ ges_timeline_object_set_top_effect_priority (GESTimelineObject * object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->trackobjects = g_list_sort_with_data (priv->trackobjects,
|
object->trackobjects = g_list_sort_with_data (object->trackobjects,
|
||||||
(GCompareDataFunc) sort_track_effects, object);
|
(GCompareDataFunc) sort_track_effects, object);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1361,13 +1355,13 @@ ges_timeline_object_edit (GESTimelineObject * object, GList * layers,
|
||||||
|
|
||||||
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
|
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
|
||||||
|
|
||||||
if (!G_UNLIKELY (object->priv->trackobjects)) {
|
if (!G_UNLIKELY (object->trackobjects)) {
|
||||||
GST_WARNING_OBJECT (object, "Trying to edit, but not containing"
|
GST_WARNING_OBJECT (object, "Trying to edit, but not containing"
|
||||||
"any TrackObject yet.");
|
"any TrackObject yet.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
for (tmp = object->trackobjects; tmp; tmp = g_list_next (tmp)) {
|
||||||
if (ges_track_object_is_locked (tmp->data)) {
|
if (ges_track_object_is_locked (tmp->data)) {
|
||||||
ret &= ges_track_object_edit (tmp->data, layers, mode, edge, position);
|
ret &= ges_track_object_edit (tmp->data, layers, mode, edge, position);
|
||||||
break;
|
break;
|
||||||
|
@ -1412,15 +1406,12 @@ ges_timeline_object_split (GESTimelineObject * object, guint64 position)
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
gboolean locked;
|
gboolean locked;
|
||||||
GESTimelineObject *new_object;
|
GESTimelineObject *new_object;
|
||||||
GESTimelineObjectPrivate *priv;
|
|
||||||
|
|
||||||
GstClockTime start, inpoint, duration;
|
GstClockTime start, inpoint, duration;
|
||||||
|
|
||||||
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
|
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
|
||||||
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (position), NULL);
|
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (position), NULL);
|
||||||
|
|
||||||
priv = object->priv;
|
|
||||||
|
|
||||||
duration = GES_TIMELINE_OBJECT_DURATION (object);
|
duration = GES_TIMELINE_OBJECT_DURATION (object);
|
||||||
start = GES_TIMELINE_OBJECT_START (object);
|
start = GES_TIMELINE_OBJECT_START (object);
|
||||||
inpoint = GES_TIMELINE_OBJECT_INPOINT (object);
|
inpoint = GES_TIMELINE_OBJECT_INPOINT (object);
|
||||||
|
@ -1453,7 +1444,7 @@ ges_timeline_object_split (GESTimelineObject * object, guint64 position)
|
||||||
/* We first set the new duration and the child mapping will be updated
|
/* We first set the new duration and the child mapping will be updated
|
||||||
* properly in the following loop */
|
* properly in the following loop */
|
||||||
object->duration = position - object->start;
|
object->duration = position - object->start;
|
||||||
for (tmp = priv->trackobjects; tmp; tmp = tmp->next) {
|
for (tmp = object->trackobjects; tmp; tmp = tmp->next) {
|
||||||
GESTrack *track;
|
GESTrack *track;
|
||||||
|
|
||||||
GESTrackObject *new_tckobj, *tckobj = GES_TRACK_OBJECT (tmp->data);
|
GESTrackObject *new_tckobj, *tckobj = GES_TRACK_OBJECT (tmp->data);
|
||||||
|
@ -1908,7 +1899,7 @@ update_height (GESTimelineObject * object)
|
||||||
guint32 min_prio = G_MAXUINT32, max_prio = 0;
|
guint32 min_prio = G_MAXUINT32, max_prio = 0;
|
||||||
|
|
||||||
/* Go over all childs and check if height has changed */
|
/* Go over all childs and check if height has changed */
|
||||||
for (tmp = object->priv->trackobjects; tmp; tmp = tmp->next) {
|
for (tmp = object->trackobjects; tmp; tmp = tmp->next) {
|
||||||
guint tck_priority =
|
guint tck_priority =
|
||||||
ges_track_object_get_priority (GES_TRACK_OBJECT (tmp->data));
|
ges_track_object_get_priority (GES_TRACK_OBJECT (tmp->data));
|
||||||
|
|
||||||
|
|
|
@ -156,10 +156,12 @@ typedef gboolean (*GESCreateTrackObjectsFunc) (GESTimelineObject * object,
|
||||||
* The #GESTimelineObject base class.
|
* The #GESTimelineObject base class.
|
||||||
*/
|
*/
|
||||||
struct _GESTimelineObject {
|
struct _GESTimelineObject {
|
||||||
/*< private >*/
|
|
||||||
GInitiallyUnowned parent;
|
GInitiallyUnowned parent;
|
||||||
|
|
||||||
GESTimelineObjectPrivate *priv;
|
/*< readonly >*/
|
||||||
|
/* A list of TrackObject controlled by this TimelineObject sorted by
|
||||||
|
* priority */
|
||||||
|
GList *trackobjects;
|
||||||
|
|
||||||
/* We don't add those properties to the priv struct for optimization purposes
|
/* We don't add those properties to the priv struct for optimization purposes
|
||||||
* start, inpoint, duration and fullduration are in nanoseconds */
|
* start, inpoint, duration and fullduration are in nanoseconds */
|
||||||
|
@ -171,6 +173,9 @@ struct _GESTimelineObject {
|
||||||
|
|
||||||
guint64 fullduration; /* Full usable duration of the object (-1: no duration) */
|
guint64 fullduration; /* Full usable duration of the object (-1: no duration) */
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
GESTimelineObjectPrivate *priv;
|
||||||
|
|
||||||
/* Padding for API extension */
|
/* Padding for API extension */
|
||||||
gpointer _ges_reserved[GES_PADDING_LARGE];
|
gpointer _ges_reserved[GES_PADDING_LARGE];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue