| OLD | NEW |
| 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 Loading... |
| 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 | |
| 1239 // the duration for this block relies on successfully parsing the last block | |
| 1240 // in the cluster the cluster. | |
| 1241 ExpectRead(DemuxerStream::AUDIO, 2 * kAudioBlockDuration); | |
| 1242 | 1238 |
| 1243 Seek(base::TimeDelta::FromSeconds(5)); | 1239 Seek(base::TimeDelta::FromSeconds(5)); |
| 1244 | 1240 |
| 1245 // Append the rest of the cluster. | 1241 // Append the rest of the cluster. |
| 1246 AppendData(cluster_a->data() + first_append_size, second_append_size); | 1242 AppendData(cluster_a->data() + first_append_size, second_append_size); |
| 1247 | 1243 |
| 1248 // Append the new cluster and verify that only the blocks | 1244 // Append the new cluster and verify that only the blocks |
| 1249 // in the new cluster are returned. | 1245 // in the new cluster are returned. |
| 1250 AppendCluster(GenerateCluster(5000, 6)); | 1246 AppendCluster(GenerateCluster(5000, 6)); |
| 1251 GenerateExpectedReads(5000, 6); | 1247 GenerateExpectedReads(5000, 6); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 base::TimeDelta::FromMilliseconds(0), | 1754 base::TimeDelta::FromMilliseconds(0), |
| 1759 &audio_read_done)); | 1755 &audio_read_done)); |
| 1760 ReadVideo(base::Bind(&OnReadDone, | 1756 ReadVideo(base::Bind(&OnReadDone, |
| 1761 base::TimeDelta::FromMilliseconds(0), | 1757 base::TimeDelta::FromMilliseconds(0), |
| 1762 &video_read_done)); | 1758 &video_read_done)); |
| 1763 | 1759 |
| 1764 // Make sure the reads haven't completed yet. | 1760 // Make sure the reads haven't completed yet. |
| 1765 EXPECT_FALSE(audio_read_done); | 1761 EXPECT_FALSE(audio_read_done); |
| 1766 EXPECT_FALSE(video_read_done); | 1762 EXPECT_FALSE(video_read_done); |
| 1767 | 1763 |
| 1768 // Append data one byte at a time until the audio read completes. | 1764 // Append data one byte at a time until one or both reads complete. |
| 1769 int i = 0; | 1765 int i = 0; |
| 1770 for (; i < cluster->size() && !audio_read_done; ++i) { | 1766 for (; i < cluster->size() && !(audio_read_done || video_read_done); ++i) { |
| 1771 AppendData(cluster->data() + i, 1); | 1767 AppendData(cluster->data() + i, 1); |
| 1772 message_loop_.RunUntilIdle(); | 1768 message_loop_.RunUntilIdle(); |
| 1773 } | 1769 } |
| 1774 | 1770 |
| 1775 EXPECT_TRUE(audio_read_done); | 1771 EXPECT_TRUE(audio_read_done || video_read_done); |
| 1776 EXPECT_FALSE(video_read_done); | |
| 1777 EXPECT_GT(i, 0); | 1772 EXPECT_GT(i, 0); |
| 1778 EXPECT_LT(i, cluster->size()); | 1773 EXPECT_LT(i, cluster->size()); |
| 1779 | 1774 |
| 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; | 1775 audio_read_done = false; |
| 1790 video_read_done = false; | 1776 video_read_done = false; |
| 1791 ReadAudio(base::Bind(&OnReadDone, | 1777 ReadAudio(base::Bind(&OnReadDone, |
| 1792 base::TimeDelta::FromMilliseconds(23), | 1778 base::TimeDelta::FromMilliseconds(23), |
| 1793 &audio_read_done)); | 1779 &audio_read_done)); |
| 1794 ReadVideo(base::Bind(&OnReadDone, | 1780 ReadVideo(base::Bind(&OnReadDone, |
| 1795 base::TimeDelta::FromMilliseconds(33), | 1781 base::TimeDelta::FromMilliseconds(33), |
| 1796 &video_read_done)); | 1782 &video_read_done)); |
| 1797 | 1783 |
| 1798 // Make sure the reads haven't completed yet. | 1784 // Make sure the reads haven't completed yet. |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3213 // Verify that audio & video streams continue to return expected values. | 3199 // Verify that audio & video streams continue to return expected values. |
| 3214 CheckExpectedBuffers(audio_stream, "160 180"); | 3200 CheckExpectedBuffers(audio_stream, "160 180"); |
| 3215 CheckExpectedBuffers(video_stream, "180 210"); | 3201 CheckExpectedBuffers(video_stream, "180 210"); |
| 3216 } | 3202 } |
| 3217 | 3203 |
| 3218 // TODO(wolenetz): Enable testing of new frame processor based on this flag, | 3204 // TODO(wolenetz): Enable testing of new frame processor based on this flag, |
| 3219 // once the new processor has landed. See http://crbug.com/249422. | 3205 // once the new processor has landed. See http://crbug.com/249422. |
| 3220 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); | 3206 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); |
| 3221 | 3207 |
| 3222 } // namespace media | 3208 } // namespace media |
| OLD | NEW |