| 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 "media/filters/chunk_demuxer.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 #include <stdint.h> | 8 #include <stdint.h> |
| 7 | |
| 8 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> |
| 9 | 11 |
| 10 #include "base/bind.h" | 12 #include "base/bind.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 13 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 16 #include "media/base/audio_decoder_config.h" | 18 #include "media/base/audio_decoder_config.h" |
| 17 #include "media/base/decoder_buffer.h" | 19 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/decrypt_config.h" | 20 #include "media/base/decrypt_config.h" |
| 19 #include "media/base/media_log.h" | 21 #include "media/base/media_log.h" |
| 20 #include "media/base/mock_demuxer_host.h" | 22 #include "media/base/mock_demuxer_host.h" |
| 21 #include "media/base/test_data_util.h" | 23 #include "media/base/test_data_util.h" |
| 22 #include "media/base/test_helpers.h" | 24 #include "media/base/test_helpers.h" |
| 23 #include "media/base/timestamp_constants.h" | 25 #include "media/base/timestamp_constants.h" |
| 24 #include "media/filters/chunk_demuxer.h" | |
| 25 #include "media/formats/webm/cluster_builder.h" | 26 #include "media/formats/webm/cluster_builder.h" |
| 26 #include "media/formats/webm/webm_constants.h" | 27 #include "media/formats/webm/webm_constants.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 using ::testing::AnyNumber; | 30 using ::testing::AnyNumber; |
| 30 using ::testing::Exactly; | 31 using ::testing::Exactly; |
| 31 using ::testing::InSequence; | 32 using ::testing::InSequence; |
| 32 using ::testing::NotNull; | 33 using ::testing::NotNull; |
| 33 using ::testing::Return; | 34 using ::testing::Return; |
| 34 using ::testing::SaveArg; | 35 using ::testing::SaveArg; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 void AppendData(const uint8_t* data, size_t length) { | 373 void AppendData(const uint8_t* data, size_t length) { |
| 373 AppendData(kSourceId, data, length); | 374 AppendData(kSourceId, data, length); |
| 374 } | 375 } |
| 375 | 376 |
| 376 void AppendCluster(const std::string& source_id, | 377 void AppendCluster(const std::string& source_id, |
| 377 scoped_ptr<Cluster> cluster) { | 378 scoped_ptr<Cluster> cluster) { |
| 378 AppendData(source_id, cluster->data(), cluster->size()); | 379 AppendData(source_id, cluster->data(), cluster->size()); |
| 379 } | 380 } |
| 380 | 381 |
| 381 void AppendCluster(scoped_ptr<Cluster> cluster) { | 382 void AppendCluster(scoped_ptr<Cluster> cluster) { |
| 382 AppendCluster(kSourceId, cluster.Pass()); | 383 AppendCluster(kSourceId, std::move(cluster)); |
| 383 } | 384 } |
| 384 | 385 |
| 385 void AppendCluster(int timecode, int block_count) { | 386 void AppendCluster(int timecode, int block_count) { |
| 386 AppendCluster(GenerateCluster(timecode, block_count)); | 387 AppendCluster(GenerateCluster(timecode, block_count)); |
| 387 } | 388 } |
| 388 | 389 |
| 389 void AppendSingleStreamCluster(const std::string& source_id, int track_number, | 390 void AppendSingleStreamCluster(const std::string& source_id, int track_number, |
| 390 int timecode, int block_count) { | 391 int timecode, int block_count) { |
| 391 int block_duration = 0; | 392 int block_duration = 0; |
| 392 switch (track_number) { | 393 switch (track_number) { |
| (...skipping 3582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3975 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 | 3976 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 |
| 3976 // byte block to stay under 100 bytes memory limit after append | 3977 // byte block to stay under 100 bytes memory limit after append |
| 3977 // 80 - 10 + 28 = 98). | 3978 // 80 - 10 + 28 = 98). |
| 3978 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to | 3979 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to |
| 3979 // remove at least 6 blocks to stay under limit. | 3980 // remove at least 6 blocks to stay under limit. |
| 3980 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); | 3981 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); |
| 3981 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); | 3982 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); |
| 3982 } | 3983 } |
| 3983 | 3984 |
| 3984 } // namespace media | 3985 } // namespace media |
| OLD | NEW |