summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@collabora.com>2013-06-10 17:46:51 -0400
committerSebastian Dröge <slomo@circular-chaos.org>2013-06-11 21:53:54 +0200
commit4652ffdf90993961de3bbe48c18eb389dc4cb966 (patch)
tree4c48cf9b20874a37d13f771dc572b2dba9c5f8db
parentea6d0f5232298e946d9fbc52e22dd75a188d5911 (diff)
gnl: Properly set operations basetime
For operations (especially mixers) to be able to do proper synchronization they need the segment from different sources to be in the same running time context. This commit makes sure that the basetime of the incoming segments of operations will be the same, and equal to the duration of the already "played" time of the operation at the position at which the new portion of the composition starts.
-rw-r--r--gnl/gnlcomposition.c8
-rw-r--r--gnl/gnlghostpad.c8
-rw-r--r--gnl/gnloperation.c17
-rw-r--r--gnl/gnloperation.h5
4 files changed, 36 insertions, 2 deletions
diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c
index fb15056..6a788a6 100644
--- a/gnl/gnlcomposition.c
+++ b/gnl/gnlcomposition.c
@@ -842,8 +842,8 @@ gnl_composition_set_update (GnlComposition * comp, gboolean update)
GST_DEBUG_OBJECT (comp, "update:%d [currently %d], update_required:%d",
update, priv->can_update, priv->update_required);
-
COMP_OBJECTS_LOCK (comp);
+
priv->can_update = update;
if (update && priv->update_required) {
@@ -1499,6 +1499,8 @@ get_stack_list (GnlComposition * comp, GstClockTime timestamp,
GST_OBJECT_NAME (object));
stack = g_list_insert_sorted (stack, object,
(GCompareFunc) priority_comp);
+ if (GNL_IS_OPERATION (object))
+ gnl_operation_update_base_time (GNL_OPERATION (object), timestamp);
}
} else {
GST_LOG_OBJECT (comp, "too far, stopping iteration");
@@ -1524,6 +1526,8 @@ get_stack_list (GnlComposition * comp, GstClockTime timestamp,
GST_OBJECT_NAME (object));
stack = g_list_insert_sorted (stack, object,
(GCompareFunc) priority_comp);
+ if (GNL_IS_OPERATION (object))
+ gnl_operation_update_base_time (GNL_OPERATION (object), timestamp);
}
} else {
GST_LOG_OBJECT (comp, "too far, stopping iteration");
@@ -1540,6 +1544,8 @@ get_stack_list (GnlComposition * comp, GstClockTime timestamp,
GST_OBJECT_NAME (tmp->data));
stack = g_list_insert_sorted (stack, tmp->data,
(GCompareFunc) priority_comp);
+ if (GNL_IS_OPERATION (tmp->data))
+ gnl_operation_update_base_time (GNL_OPERATION (tmp->data), timestamp);
}
/* convert that list to a stack */
diff --git a/gnl/gnlghostpad.c b/gnl/gnlghostpad.c
index 1757453..c275fd5 100644
--- a/gnl/gnlghostpad.c
+++ b/gnl/gnlghostpad.c
@@ -295,6 +295,12 @@ translate_incoming_segment (GnlObject * object, GstEvent * event)
segment.time = 0;
};
+ if (GNL_IS_OPERATION (object)) {
+ segment.base = GNL_OPERATION (object)->next_base_time;
+ GST_INFO_OBJECT (object, "Using operation base time %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (GNL_OPERATION (object)->next_base_time));
+ }
+
if (G_UNLIKELY (segment.time > G_MAXINT64))
GST_WARNING_OBJECT (object, "Return value too big...");
@@ -649,7 +655,7 @@ control_internal_pad (GstPad * ghostpad, GnlObject * object)
* @name: Name for the new pad
* @target: Target #GstPad to ghost
*
- * Adds a #GstGhostPad overridding the correct pad [query|event]_function so
+ * Adds a #GstGhostPad overridding the correct pad [query|event]_function so
* that time shifting is done correctly
* The #GstGhostPad is added to the #GnlObject
*
diff --git a/gnl/gnloperation.c b/gnl/gnloperation.c
index 90c3b84..c271c7b 100644
--- a/gnl/gnloperation.c
+++ b/gnl/gnloperation.c
@@ -183,6 +183,7 @@ gnl_operation_reset (GnlOperation * operation)
{
operation->num_sinks = 1;
operation->realsinks = 0;
+ operation->next_base_time = 0;
}
static void
@@ -791,3 +792,19 @@ gnl_operation_signal_input_priority_changed (GnlOperation * operation,
g_signal_emit (operation, gnl_operation_signals[INPUT_PRIORITY_CHANGED],
0, pad, priority);
}
+
+void
+gnl_operation_update_base_time (GnlOperation * operation,
+ GstClockTime timestamp)
+{
+ if (!gnl_object_to_media_time (GNL_OBJECT (operation),
+ timestamp, &operation->next_base_time)) {
+ GST_WARNING_OBJECT (operation, "Trying to set a basetime outside of "
+ "ourself");
+
+ return;
+ }
+
+ GST_INFO_OBJECT (operation, "Setting next_basetime to %"
+ GST_TIME_FORMAT, GST_TIME_ARGS (operation->next_base_time));
+}
diff --git a/gnl/gnloperation.h b/gnl/gnloperation.h
index afd29d1..3d6454b 100644
--- a/gnl/gnloperation.h
+++ b/gnl/gnloperation.h
@@ -62,6 +62,8 @@ G_BEGIN_DECLS
GstPad *ghostpad; /* src ghostpad */
GstElement *element; /* controlled element */
+
+ GstClockTime next_base_time;
};
struct _GnlOperationClass
@@ -77,6 +79,9 @@ void
gnl_operation_signal_input_priority_changed(GnlOperation * operation, GstPad *pad,
guint32 priority);
+void gnl_operation_update_base_time (GnlOperation *operation,
+ GstClockTime timestamp);
+
/* normal GOperation stuff */
GType gnl_operation_get_type (void);