QVariant Timeline:: data(const QModelIndex &index, int role) const { GESTimelineObject * object; object = ges_simple_timeline_layer_nth(layer, index.row()); if (!object) { return QVariant::fromValue(QString("Invalid index")); } switch (role) { case thumb_uri_role: return thumbForObject(object); case media_uri_role: return mediaUri(object); case duration_role: return QVariant::fromValue((double) GES_TIMELINE_OBJECT_DURATION(object)); case inpoint_role: return QVariant::fromValue((double) GES_TIMELINE_OBJECT_INPOINT(object)); case outpoint_role: return QVariant::fromValue((double) GES_TIMELINE_OBJECT_INPOINT(object) + GES_TIMELINE_OBJECT_DURATION(object)); case duration_only_role: gboolean is_image; g_object_get (G_OBJECT(object), "is-image", (gboolean *) &is_image, NULL); return QVariant::fromValue((bool) is_image); default: return QVariant::fromValue(QString("Invalid role " + role)); }; }
void Timeline:: privDurationChanged(GESTimelineObject *obj) { qDebug() << GES_TIMELINE_OBJECT_DURATION (obj); gint index = ges_simple_timeline_layer_index(layer, obj); if (index == -1) { qDebug() << "houston, we have a problem"; return; } emit dataChanged(createIndex(index, 0), createIndex(index + 1, 1)); }
static void gstl_recalculate (GESSimpleTimelineLayer * self) { GList *tmp; gint64 pos = 0; gint priority = 0; gint transition_priority = 0; gint height; GESTimelineObject *prev_object = NULL; GESTimelineObject *prev_transition = NULL; gboolean valid = TRUE; GESSimpleTimelineLayerPrivate *priv = self->priv; priority = GES_TIMELINE_LAYER (self)->min_gnl_priority + 2; GST_DEBUG ("recalculating values"); if (priv->objects && GES_IS_TIMELINE_TRANSITION (priv->objects->data)) { valid = FALSE; } for (tmp = priv->objects; tmp; tmp = tmp->next) { GESTimelineObject *obj; guint64 dur; GList *l_next; obj = (GESTimelineObject *) tmp->data; dur = GES_TIMELINE_OBJECT_DURATION (obj); height = GES_TIMELINE_OBJECT_HEIGHT (obj); if (GES_IS_TIMELINE_SOURCE (obj)) { GST_LOG ("%p obj: height: %d: priority %d", obj, height, priority); if (G_UNLIKELY (GES_TIMELINE_OBJECT_START (obj) != pos)) { ges_timeline_object_set_start (obj, pos); } if (G_UNLIKELY (GES_TIMELINE_OBJECT_PRIORITY (obj) != priority)) { ges_timeline_object_set_priority (obj, priority); } transition_priority = MAX (0, priority - 1); priority += height; pos += dur; g_assert (priority != -1); } else if (GES_IS_TIMELINE_TRANSITION (obj)) { pos -= dur; if (pos < 0) pos = 0; GST_LOG ("%p obj: height: %d: trans_priority %d Position: %" G_GINT64_FORMAT ", duration %" G_GINT64_FORMAT, obj, height, transition_priority, pos, dur); g_assert (transition_priority != -1); if (G_UNLIKELY (GES_TIMELINE_OBJECT_START (obj) != pos)) ges_timeline_object_set_start (obj, pos); if (G_UNLIKELY (GES_TIMELINE_OBJECT_PRIORITY (obj) != transition_priority)) { ges_timeline_object_set_priority (obj, transition_priority); } /* sanity checks */ l_next = g_list_next (tmp); if (GES_IS_TIMELINE_TRANSITION (prev_object)) { GST_ERROR ("two transitions in sequence!"); valid = FALSE; } if (prev_object && (GES_TIMELINE_OBJECT_DURATION (prev_object) < dur)) { GST_ERROR ("transition duration exceeds that of previous neighbor!"); valid = FALSE; } if (l_next && (GES_TIMELINE_OBJECT_DURATION (l_next->data) < dur)) { GST_ERROR ("transition duration exceeds that of next neighbor!"); valid = FALSE; } if (prev_transition) { guint64 start, end; end = (GES_TIMELINE_OBJECT_DURATION (prev_transition) + GES_TIMELINE_OBJECT_START (prev_transition)); start = pos; if (end > start) { GST_ERROR ("%" G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT ": " "overlapping transitions!", start, end); valid = FALSE; } } prev_transition = obj; } prev_object = obj; } if (prev_object && GES_IS_TIMELINE_TRANSITION (prev_object)) { valid = FALSE; } GST_DEBUG ("Finished recalculating: final start pos is: %" GST_TIME_FORMAT, GST_TIME_ARGS (pos)); GES_TIMELINE_LAYER (self)->max_gnl_priority = priority; if (valid != self->priv->valid) { self->priv->valid = valid; g_object_notify (G_OBJECT (self), "valid"); } }