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

Side by Side Diff: media/filters/chunk_demuxer_unittest.cc

Issue 239343007: MSE: Make WebMClusterParser hold back buffers at or beyond buffer missing duration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some errors in comments. Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 // Split the cluster into two appends at an arbitrary point near the end. 1228 // Split the cluster into two appends at an arbitrary point near the end.
1229 int first_append_size = cluster_a->size() - 11; 1229 int first_append_size = cluster_a->size() - 11;
1230 int second_append_size = cluster_a->size() - first_append_size; 1230 int second_append_size = cluster_a->size() - first_append_size;
1231 1231
1232 // Append the first part of the cluster. 1232 // Append the first part of the cluster.
1233 AppendData(cluster_a->data(), first_append_size); 1233 AppendData(cluster_a->data(), first_append_size);
1234 1234
1235 ExpectRead(DemuxerStream::AUDIO, 0); 1235 ExpectRead(DemuxerStream::AUDIO, 0);
1236 ExpectRead(DemuxerStream::VIDEO, 0); 1236 ExpectRead(DemuxerStream::VIDEO, 0);
1237 ExpectRead(DemuxerStream::AUDIO, kAudioBlockDuration); 1237 ExpectRead(DemuxerStream::AUDIO, kAudioBlockDuration);
1238 // Note: We skip trying to read a video buffer here because computing 1238
1239 // the duration for this block relies on successfully parsing the last block 1239 // Note: No further reads are expected to be able to complete at this point.
1240 // in the cluster the cluster. 1240 // Video read cannot complete because computing the duration for the next
1241 ExpectRead(DemuxerStream::AUDIO, 2 * kAudioBlockDuration); 1241 // video buffer relies on parsing the next video block or reaching cluster
1242 // end. Audio read cannot complete because the next audio buffer, though
1243 // parsed and having duration, is held back by the parser because it has
1244 // timestamp (0.046s), which is higher than the currently held-back video
1245 // buffer's timestamp (0.033s).
acolwell GONE FROM CHROMIUM 2014/04/23 22:36:39 nit: What is the purpose of this comment? It doesn
wolenetz 2014/04/25 20:04:21 Done.
1242 1246
1243 Seek(base::TimeDelta::FromSeconds(5)); 1247 Seek(base::TimeDelta::FromSeconds(5));
1244 1248
1245 // Append the rest of the cluster. 1249 // Append the rest of the cluster.
1246 AppendData(cluster_a->data() + first_append_size, second_append_size); 1250 AppendData(cluster_a->data() + first_append_size, second_append_size);
1247 1251
1248 // Append the new cluster and verify that only the blocks 1252 // Append the new cluster and verify that only the blocks
1249 // in the new cluster are returned. 1253 // in the new cluster are returned.
1250 AppendCluster(GenerateCluster(5000, 6)); 1254 AppendCluster(GenerateCluster(5000, 6));
1251 GenerateExpectedReads(5000, 6); 1255 GenerateExpectedReads(5000, 6);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 &audio_read_done)); 1763 &audio_read_done));
1760 ReadVideo(base::Bind(&OnReadDone, 1764 ReadVideo(base::Bind(&OnReadDone,
1761 base::TimeDelta::FromMilliseconds(0), 1765 base::TimeDelta::FromMilliseconds(0),
1762 &video_read_done)); 1766 &video_read_done));
1763 1767
1764 // Make sure the reads haven't completed yet. 1768 // Make sure the reads haven't completed yet.
1765 EXPECT_FALSE(audio_read_done); 1769 EXPECT_FALSE(audio_read_done);
1766 EXPECT_FALSE(video_read_done); 1770 EXPECT_FALSE(video_read_done);
1767 1771
1768 // Append data one byte at a time until the audio read completes. 1772 // Append data one byte at a time until the audio read completes.
1773 // Initial (timestamp 0) audio and video reads should complete in the same
1774 // iteration since neither buffer originally had an embedded duration, so were
1775 // mutually holding back each other until enough data was available for the
1776 // parser to determine durations for each.
acolwell GONE FROM CHROMIUM 2014/04/23 22:36:39 nit: I don't think it is worth having this here ei
wolenetz 2014/04/25 20:04:21 Done.
1769 int i = 0; 1777 int i = 0;
1770 for (; i < cluster->size() && !audio_read_done; ++i) { 1778 for (; i < cluster->size() && !audio_read_done; ++i) {
1779 EXPECT_FALSE(video_read_done);
acolwell GONE FROM CHROMIUM 2014/04/23 22:36:39 nit: Remove since this test really shouldn't conce
wolenetz 2014/04/25 20:04:21 Done.
1771 AppendData(cluster->data() + i, 1); 1780 AppendData(cluster->data() + i, 1);
1772 message_loop_.RunUntilIdle(); 1781 message_loop_.RunUntilIdle();
1773 } 1782 }
1774 1783
1775 EXPECT_TRUE(audio_read_done); 1784 EXPECT_TRUE(audio_read_done);
1776 EXPECT_FALSE(video_read_done); 1785 EXPECT_TRUE(video_read_done);
1777 EXPECT_GT(i, 0); 1786 EXPECT_GT(i, 0);
1778 EXPECT_LT(i, cluster->size()); 1787 EXPECT_LT(i, cluster->size());
1779 1788
1780 // Append data one byte at a time until the video read completes.
1781 for (; i < cluster->size() && !video_read_done; ++i) {
1782 AppendData(cluster->data() + i, 1);
1783 message_loop_.RunUntilIdle();
1784 }
1785
1786 EXPECT_TRUE(video_read_done);
1787 EXPECT_LT(i, cluster->size());
1788
1789 audio_read_done = false; 1789 audio_read_done = false;
1790 video_read_done = false; 1790 video_read_done = false;
1791 ReadAudio(base::Bind(&OnReadDone, 1791 ReadAudio(base::Bind(&OnReadDone,
1792 base::TimeDelta::FromMilliseconds(23), 1792 base::TimeDelta::FromMilliseconds(23),
1793 &audio_read_done)); 1793 &audio_read_done));
1794 ReadVideo(base::Bind(&OnReadDone, 1794 ReadVideo(base::Bind(&OnReadDone,
1795 base::TimeDelta::FromMilliseconds(33), 1795 base::TimeDelta::FromMilliseconds(33),
1796 &video_read_done)); 1796 &video_read_done));
1797 1797
1798 // Make sure the reads haven't completed yet. 1798 // Make sure the reads haven't completed yet.
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3213 // Verify that audio & video streams continue to return expected values. 3213 // Verify that audio & video streams continue to return expected values.
3214 CheckExpectedBuffers(audio_stream, "160 180"); 3214 CheckExpectedBuffers(audio_stream, "160 180");
3215 CheckExpectedBuffers(video_stream, "180 210"); 3215 CheckExpectedBuffers(video_stream, "180 210");
3216 } 3216 }
3217 3217
3218 // TODO(wolenetz): Enable testing of new frame processor based on this flag, 3218 // TODO(wolenetz): Enable testing of new frame processor based on this flag,
3219 // once the new processor has landed. See http://crbug.com/249422. 3219 // once the new processor has landed. See http://crbug.com/249422.
3220 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); 3220 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true));
3221 3221
3222 } // namespace media 3222 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/formats/webm/webm_cluster_parser.h » ('j') | media/formats/webm/webm_cluster_parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698