Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Unified Diff: media/filters/source_buffer_stream_unittest.cc

Issue 1018373003: Improving WebM video duration estimation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding tests and fixing bug Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/source_buffer_stream_unittest.cc
diff --git a/media/filters/source_buffer_stream_unittest.cc b/media/filters/source_buffer_stream_unittest.cc
index 87509c29cc16cde66daf2da70ec2c90b8f6a84d4..8b7fa407a36640d388f828f4c34cc0648c5af92b 100644
--- a/media/filters/source_buffer_stream_unittest.cc
+++ b/media/filters/source_buffer_stream_unittest.cc
@@ -293,6 +293,17 @@ class SourceBufferStreamTest : public testing::Test {
ss << "|" << buffer->GetDecodeTimestamp().InMilliseconds();
}
+ // Check duration if expected timestamp contains it.
+ if (timestamps[i].find('D') != std::string::npos) {
+ ss << "D" << buffer->duration().InMilliseconds();
+ }
+
+ // Check duration estimation if expected timestamp contains it.
+ if (timestamps[i].find('E') != std::string::npos &&
+ buffer->is_duration_estimated()) {
+ ss << "E";
+ }
+
// Handle preroll buffers.
if (EndsWith(timestamps[i], "P", true)) {
ASSERT_TRUE(buffer->is_key_frame());
@@ -446,6 +457,14 @@ class SourceBufferStreamTest : public testing::Test {
// only contains 1 buffer then the duration must be explicitly specified with
// this format.
//
+ // ##E:
+ // Indicates that the buffer with timestamp ## should be marked as containing
+ // an *estimated* duration. To use in combination with D, order as ##DzzE.
+ //
+ // ##P:
+ // Indicates the buffer with timestamp ## will also have a preroll buffer
+ // associated with it. The preroll buffer will just be dummy data.
+ //
// ##K:
// Indicates the buffer with timestamp ## reflects a keyframe. ##
wolenetz 2015/04/15 02:55:23 nit: drop the last ## on this line and the remaind
chcunningham 2015/04/16 18:04:16 Done.
// can be any of the 3 timestamp formats above.
@@ -471,6 +490,8 @@ class SourceBufferStreamTest : public testing::Test {
bool is_keyframe = false;
bool has_preroll = false;
bool last_splice_frame = false;
+ bool is_duration_estimated = false;
+
// Handle splice frame starts.
if (StartsWithASCII(timestamps[i], "S(", true)) {
CHECK(!splice_frame);
@@ -505,6 +526,12 @@ class SourceBufferStreamTest : public testing::Test {
timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1);
}
+ if (EndsWith(timestamps[i], "E", true)) {
+ is_duration_estimated = true;
+ // Remove the "E" off of the token.
+ timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1);
+ }
+
int duration_in_ms = 0;
size_t duration_pos = timestamps[i].find('D');
if (duration_pos != std::string::npos) {
@@ -531,6 +558,7 @@ class SourceBufferStreamTest : public testing::Test {
StreamParserBuffer::CopyFrom(&kDataA, kDataSize, is_keyframe,
DemuxerStream::AUDIO, 0);
buffer->set_timestamp(base::TimeDelta::FromMilliseconds(pts_in_ms));
+ buffer->set_is_duration_estimated(is_duration_estimated);
if (dts_in_ms != pts_in_ms) {
buffer->SetDecodeTimestamp(
@@ -3959,6 +3987,55 @@ TEST_F(SourceBufferStreamTest, RemoveShouldAlwaysExcludeEnd) {
CheckNoNextBuffer();
}
+TEST_F(SourceBufferStreamTest, RefinedDurationEstimates_BackOverlap) {
+ // Append a few buffers, the last one having estimated duration.
+ NewSegmentAppend("0K 5 10 20D10E");
+ CheckExpectedRangesByTimestamp("{ [0,30) }");
+ Seek(0);
+ CheckExpectedBuffers("0K 5 10 20D10E");
+ CheckNoNextBuffer();
+
+ // Append a buffer to the end that overlaps the *back* of the existing range.
+ // This should trigger the estimated duration to be recomputed as a timestamp
+ // delta.
+ AppendBuffers("25D10");
+ CheckExpectedRangesByTimestamp("{ [0,35) }");
+ Seek(0);
+ // The duration of the buffer at time 20 has changed from 10ms to 5ms.
+ CheckExpectedBuffers("0K 5 10 20D5E 25");
+ CheckNoNextBuffer();
+
+ // If the last buffer is removed, the adjusted duration should remain at 5ms.
+ RemoveInMs(25, 35, 35);
+ CheckExpectedRangesByTimestamp("{ [0,25) }");
+ Seek(0);
+ CheckExpectedBuffers("0K 5 10 20D5E");
wolenetz 2015/04/15 02:55:23 nit: and CheckNoNextBuffer();
chcunningham 2015/04/16 18:04:16 Done.
+}
+
+TEST_F(SourceBufferStreamTest, RefinedDurationEstimates_FrontOverlap) {
+ // Append a few buffers.
+ NewSegmentAppend("10K 15 20D5");
+ CheckExpectedRangesByTimestamp("{ [10,25) }");
+ SeekToTimestamp(base::TimeDelta::FromMilliseconds(10));
+ CheckExpectedBuffers("10K 15 20");
+ CheckNoNextBuffer();
+
+ // Append a new buffers, where the last has estimated duration that overlaps
wolenetz 2015/04/15 02:55:23 nit: "a new buffers" ?
chcunningham 2015/04/16 18:04:16 Done.
+ // the *front* of the existing range. The overlap should trigger refinement
+ // of the estimated duration from 7ms to 5ms.
+ NewSegmentAppend("0K 5D7E");
+ CheckExpectedRangesByTimestamp("{ [0,25) }");
+ Seek(0);
+ CheckExpectedBuffers("0K 5D5E 10K 15 20");
wolenetz 2015/04/15 02:55:23 nit: and CheckNoNextBuffer();
chcunningham 2015/04/16 18:04:16 Done.
+
+ // If the overlapped buffer at timestamp 10 is removed, the adjusted duration
+ // should remain adjusted.
+ RemoveInMs(10, 20, 25);
+ CheckExpectedRangesByTimestamp("{ [0,10) }");
+ Seek(0);
+ CheckExpectedBuffers("0K 5D5E");
wolenetz 2015/04/15 02:55:23 nit ditto
chcunningham 2015/04/16 18:04:16 Done.
+}
+
// TODO(vrk): Add unit tests where keyframes are unaligned between streams.
// (crbug.com/133557)

Powered by Google App Engine
This is Rietveld 408576698