summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@collabora.com>2013-03-28 19:07:30 +0100
committerEdward Hervey <edward@collabora.com>2013-03-28 19:07:30 +0100
commit692dc3c377a155b719de2eeb7c4c2697632e2dbc (patch)
tree55974626d4c5aa92bcb0bd7bec89ee44d44c9a20
parentd459463192a2fd0afcdc4c6f5bd47d3aa1c37c44 (diff)
composition: Ensure segment base time is correct
We update it based on accumulated segment time. Tests are also updated to check for valid base/time/duration
-rw-r--r--gnl/gnlcomposition.c33
-rw-r--r--tests/check/gnl/common.h27
-rw-r--r--tests/check/gnl/complex.c3
-rw-r--r--tests/check/gnl/gnloperation.c1
-rw-r--r--tests/check/gnl/seek.c5
-rw-r--r--tests/check/gnl/simple.c5
6 files changed, 63 insertions, 11 deletions
diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c
index 88a08d3..55d1285 100644
--- a/gnl/gnlcomposition.c
+++ b/gnl/gnlcomposition.c
@@ -133,6 +133,9 @@ struct _GnlCompositionPrivate
GstSegment *segment;
GstSegment *outside_segment;
+ /* Next running base_time to set on outgoing segment */
+ guint64 next_base_time;
+
/* number of pads we are waiting to appear so be can do proper linking */
guint waitingpads;
@@ -584,6 +587,7 @@ gnl_composition_reset (GnlComposition * comp)
priv->segment_start = GST_CLOCK_TIME_NONE;
priv->segment_stop = GST_CLOCK_TIME_NONE;
+ priv->next_base_time = 0;
gst_segment_init (priv->segment, GST_FORMAT_TIME);
gst_segment_init (priv->outside_segment, GST_FORMAT_TIME);
@@ -682,6 +686,12 @@ ghost_event_probe_handler (GstPad * ghostpad G_GNUC_UNUSED,
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEGMENT:
{
+ guint64 rstart, rstop;
+ const GstSegment *segment;
+ GstSegment copy;
+ GstEvent *event2;
+ /* next_base_time */
+
COMP_FLUSHING_LOCK (comp);
if (priv->pending_idle) {
GST_DEBUG_OBJECT (comp, "removing pending seek for main thread");
@@ -690,6 +700,26 @@ ghost_event_probe_handler (GstPad * ghostpad G_GNUC_UNUSED,
priv->pending_idle = 0;
priv->flushing = FALSE;
COMP_FLUSHING_UNLOCK (comp);
+
+ gst_event_parse_segment (event, &segment);
+ gst_segment_copy_into (segment, &copy);
+
+ rstart =
+ gst_segment_to_running_time (segment, GST_FORMAT_TIME,
+ segment->start);
+ rstop =
+ gst_segment_to_running_time (segment, GST_FORMAT_TIME, segment->stop);
+ copy.base = comp->priv->next_base_time;
+ GST_DEBUG_OBJECT (comp,
+ "Updating base time to %" GST_TIME_FORMAT ", next:%" GST_TIME_FORMAT,
+ GST_TIME_ARGS (comp->priv->next_base_time),
+ GST_TIME_ARGS (comp->priv->next_base_time + rstop - rstart));
+ comp->priv->next_base_time += rstop - rstart;
+
+ event2 = gst_event_new_segment (&copy);
+ GST_EVENT_SEQNUM (event2) = GST_EVENT_SEQNUM (event);
+ GST_PAD_PROBE_INFO_DATA (info) = event2;
+ gst_event_unref (event);
}
break;
case GST_EVENT_EOS:
@@ -1011,6 +1041,9 @@ handle_seek_event (GnlComposition * comp, GstEvent * event)
priv->segment->stop = MIN (priv->segment->stop, GNL_OBJECT_STOP (comp));
comp->priv->user_seek_flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
+ if (comp->priv->user_seek_flush)
+ comp->priv->next_base_time = 0;
+
seek_handling (comp, TRUE, FALSE);
}
diff --git a/tests/check/gnl/common.h b/tests/check/gnl/common.h
index 88f0a17..5ec207f 100644
--- a/tests/check/gnl/common.h
+++ b/tests/check/gnl/common.h
@@ -45,6 +45,7 @@ typedef struct _CollectStructure {
gboolean gotsegment;
GList *seen_segments;
GList *expected_segments;
+ guint64 expected_base;
} CollectStructure;
static GstElement *
@@ -66,33 +67,43 @@ composition_pad_added_cb (GstElement *composition, GstPad *pad, CollectStructure
/* return TRUE to discard the Segment */
static gboolean
-compare_segments (Segment * segment, GstEvent * event)
+compare_segments (CollectStructure *collect, Segment * segment, GstEvent * event)
{
const GstSegment *orig;
+ guint64 running_stop, running_start, running_duration;
gst_event_parse_segment (event, &orig);
GST_DEBUG ("Got Segment rate:%f, format:%s, start:%"GST_TIME_FORMAT
- ", stop:%"GST_TIME_FORMAT", position:%"GST_TIME_FORMAT
+ ", stop:%"GST_TIME_FORMAT", time:%"GST_TIME_FORMAT
", base:%"GST_TIME_FORMAT", offset:%"GST_TIME_FORMAT,
orig->rate, gst_format_get_name(orig->format), GST_TIME_ARGS (orig->start),
GST_TIME_ARGS (orig->stop),
- GST_TIME_ARGS (orig->position),
+ GST_TIME_ARGS (orig->time),
GST_TIME_ARGS (orig->base),
GST_TIME_ARGS (orig->offset));
+ GST_DEBUG ("[RUNNING] start:%"GST_TIME_FORMAT" [STREAM] start:%"GST_TIME_FORMAT,
+ GST_TIME_ARGS (gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->start)),
+ GST_TIME_ARGS (gst_segment_to_stream_time (orig, GST_FORMAT_TIME, orig->start)));
GST_DEBUG ("Expecting rate:%f, format:%s, start:%"GST_TIME_FORMAT
- ", stop:%"GST_TIME_FORMAT", position:%"GST_TIME_FORMAT,
+ ", stop:%"GST_TIME_FORMAT", position:%"GST_TIME_FORMAT", base:%"GST_TIME_FORMAT,
segment->rate, gst_format_get_name (segment->format),
GST_TIME_ARGS (segment->start),
GST_TIME_ARGS (segment->stop),
- GST_TIME_ARGS (segment->position));
+ GST_TIME_ARGS (segment->position),
+ GST_TIME_ARGS (collect->expected_base));
+ running_start = gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->start);
+ running_stop = gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->stop);
+ running_duration = running_stop - running_start;
fail_if (orig->rate != segment->rate);
fail_if (orig->format != segment->format);
- fail_unless_equals_uint64 (orig->start, segment->start);
- fail_unless_equals_uint64 (orig->stop, segment->stop);
fail_unless_equals_int64 (orig->time, segment->position);
+ fail_unless_equals_int64 (orig->base, collect->expected_base);
+ fail_unless_equals_uint64 (orig->stop - orig->start, segment->stop -segment->start);
+
+ collect->expected_base += running_duration;
GST_DEBUG ("Segment was valid, discarding expected Segment");
@@ -121,7 +132,7 @@ sinkpad_event_probe (GstPad * sinkpad, GstEvent * event, CollectStructure * coll
segment = (Segment *) collect->expected_segments->data;
- if (compare_segments (segment, event)) {
+ if (compare_segments (collect, segment, event)) {
collect->expected_segments = g_list_remove (collect->expected_segments, segment);
g_free (segment);
}
diff --git a/tests/check/gnl/complex.c b/tests/check/gnl/complex.c
index 14e830b..ee8aa07 100644
--- a/tests/check/gnl/complex.c
+++ b/tests/check/gnl/complex.c
@@ -75,6 +75,7 @@ fill_pipeline_and_check (GstElement * comp, GList * segments)
collect->expected_segments = listcopy;
collect->gotsegment = FALSE;
+ collect->expected_base = 0;
GST_DEBUG ("Setting pipeline to PLAYING again");
@@ -582,7 +583,6 @@ GST_START_TEST (test_renegotiation)
GST_DEBUG ("Resetted pipeline to READY");
/* Expected segments */
- /* Expected segments */
collect->expected_segments = g_list_append (collect->expected_segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
collect->expected_segments = g_list_append (collect->expected_segments,
@@ -592,6 +592,7 @@ GST_START_TEST (test_renegotiation)
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
collect->gotsegment = FALSE;
+ collect->expected_base = 0;
GST_DEBUG ("Setting pipeline to PLAYING again");
diff --git a/tests/check/gnl/gnloperation.c b/tests/check/gnl/gnloperation.c
index a91360c..e4499b9 100644
--- a/tests/check/gnl/gnloperation.c
+++ b/tests/check/gnl/gnloperation.c
@@ -73,6 +73,7 @@ fill_pipeline_and_check (GstElement * comp, GList * segments)
GST_DEBUG ("Resetted pipeline to READY");
+ collect->expected_base = 0;
collect->expected_segments = listcopy;
collect->gotsegment = FALSE;
diff --git a/tests/check/gnl/seek.c b/tests/check/gnl/seek.c
index 8689f90..07c2828 100644
--- a/tests/check/gnl/seek.c
+++ b/tests/check/gnl/seek.c
@@ -98,11 +98,14 @@ fill_pipeline_and_check (GstElement * comp, GList * segments, GList * seeks)
seeks = seeks->next;
- if (!sinfo->expect_failure)
+ if (!sinfo->expect_failure) {
+ collect->gotsegment = FALSE;
+ collect->expected_base = 0;
collect->expected_segments =
g_list_append (collect->expected_segments, segment_new (1.0,
GST_FORMAT_TIME, sinfo->start, sinfo->stop,
sinfo->position));
+ }
/* Seek to 0.5s */
GST_DEBUG ("Seeking to %" GST_TIME_FORMAT ", Expecting (%"
diff --git a/tests/check/gnl/simple.c b/tests/check/gnl/simple.c
index 0a11725..ba58f21 100644
--- a/tests/check/gnl/simple.c
+++ b/tests/check/gnl/simple.c
@@ -111,7 +111,8 @@ test_simplest_full (gboolean async)
/* Expected segments */
collect->expected_segments = g_list_append (collect->expected_segments,
segment_new (1.0, GST_FORMAT_TIME, 5 * GST_SECOND, 6 * GST_SECOND, 0));
-
+ collect->expected_base = 0;
+ collect->gotsegment = FALSE;
GST_DEBUG ("Setting pipeline to PLAYING again");
@@ -392,6 +393,7 @@ test_one_after_other_full (gboolean async)
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 3 * GST_SECOND, 1 * GST_SECOND));
collect->gotsegment = FALSE;
+ collect->expected_base = 0;
GST_DEBUG ("Setting pipeline to PLAYING again");
@@ -740,6 +742,7 @@ test_one_bin_after_other_full (gboolean async)
segment_new (1.0, GST_FORMAT_TIME,
1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
collect->gotsegment = FALSE;
+ collect->expected_base = 0;
GST_DEBUG ("Setting pipeline to PLAYING again");