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" | 5 #include "media/filters/chunk_demuxer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "media/base/audio_decoder_config.h" | 18 #include "media/base/audio_decoder_config.h" |
19 #include "media/base/decoder_buffer.h" | 19 #include "media/base/decoder_buffer.h" |
20 #include "media/base/decrypt_config.h" | 20 #include "media/base/decrypt_config.h" |
21 #include "media/base/media_log.h" | 21 #include "media/base/media_log.h" |
22 #include "media/base/mock_demuxer_host.h" | 22 #include "media/base/mock_demuxer_host.h" |
23 #include "media/base/test_data_util.h" | 23 #include "media/base/test_data_util.h" |
24 #include "media/base/test_helpers.h" | 24 #include "media/base/test_helpers.h" |
25 #include "media/base/timestamp_constants.h" | 25 #include "media/base/timestamp_constants.h" |
26 #include "media/formats/webm/cluster_builder.h" | 26 #include "media/formats/webm/cluster_builder.h" |
27 #include "media/formats/webm/webm_constants.h" | 27 #include "media/formats/webm/webm_constants.h" |
| 28 #include "media/media_features.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
29 | 30 |
30 using ::testing::AnyNumber; | 31 using ::testing::AnyNumber; |
31 using ::testing::Exactly; | 32 using ::testing::Exactly; |
32 using ::testing::InSequence; | 33 using ::testing::InSequence; |
33 using ::testing::NotNull; | 34 using ::testing::NotNull; |
34 using ::testing::Return; | 35 using ::testing::Return; |
35 using ::testing::SaveArg; | 36 using ::testing::SaveArg; |
36 using ::testing::SetArgumentPointee; | 37 using ::testing::SetArgumentPointee; |
37 using ::testing::_; | 38 using ::testing::_; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 type = "video/webm"; | 356 type = "video/webm"; |
356 } | 357 } |
357 | 358 |
358 if (!has_audio && !has_video) { | 359 if (!has_audio && !has_video) { |
359 return AddId(kSourceId, HAS_AUDIO | HAS_VIDEO); | 360 return AddId(kSourceId, HAS_AUDIO | HAS_VIDEO); |
360 } | 361 } |
361 | 362 |
362 return demuxer_->AddId(source_id, type, codecs); | 363 return demuxer_->AddId(source_id, type, codecs); |
363 } | 364 } |
364 | 365 |
| 366 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
365 ChunkDemuxer::Status AddIdForMp2tSource(const std::string& source_id) { | 367 ChunkDemuxer::Status AddIdForMp2tSource(const std::string& source_id) { |
366 std::vector<std::string> codecs; | 368 std::vector<std::string> codecs; |
367 std::string type = "video/mp2t"; | 369 std::string type = "video/mp2t"; |
368 codecs.push_back("mp4a.40.2"); | 370 codecs.push_back("mp4a.40.2"); |
369 codecs.push_back("avc1.640028"); | 371 codecs.push_back("avc1.640028"); |
370 return demuxer_->AddId(source_id, type, codecs); | 372 return demuxer_->AddId(source_id, type, codecs); |
371 } | 373 } |
| 374 #endif |
372 | 375 |
373 void AppendData(const uint8_t* data, size_t length) { | 376 void AppendData(const uint8_t* data, size_t length) { |
374 AppendData(kSourceId, data, length); | 377 AppendData(kSourceId, data, length); |
375 } | 378 } |
376 | 379 |
377 void AppendCluster(const std::string& source_id, | 380 void AppendCluster(const std::string& source_id, |
378 scoped_ptr<Cluster> cluster) { | 381 scoped_ptr<Cluster> cluster) { |
379 AppendData(source_id, cluster->data(), cluster->size()); | 382 AppendData(source_id, cluster->data(), cluster->size()); |
380 } | 383 } |
381 | 384 |
(...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3040 append_window_start_for_next_append_, | 3043 append_window_start_for_next_append_, |
3041 append_window_end_for_next_append_, | 3044 append_window_end_for_next_append_, |
3042 ×tamp_offset_map_[kSourceId]); | 3045 ×tamp_offset_map_[kSourceId]); |
3043 | 3046 |
3044 // After ResetParserState(), parsing should no longer be in the middle of a | 3047 // After ResetParserState(), parsing should no longer be in the middle of a |
3045 // media segment. | 3048 // media segment. |
3046 ASSERT_FALSE(demuxer_->IsParsingMediaSegment(kSourceId)); | 3049 ASSERT_FALSE(demuxer_->IsParsingMediaSegment(kSourceId)); |
3047 } | 3050 } |
3048 | 3051 |
3049 #if defined(USE_PROPRIETARY_CODECS) | 3052 #if defined(USE_PROPRIETARY_CODECS) |
3050 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) | 3053 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
3051 TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) { | 3054 TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) { |
3052 EXPECT_CALL(*this, DemuxerOpened()); | 3055 EXPECT_CALL(*this, DemuxerOpened()); |
3053 demuxer_->Initialize( | 3056 demuxer_->Initialize( |
3054 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); | 3057 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); |
3055 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); | 3058 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); |
3056 | 3059 |
3057 // For info: | 3060 // For info: |
3058 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode | 3061 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode |
3059 // Video: first PES: | 3062 // Video: first PES: |
3060 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] | 3063 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3976 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 | 3979 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 |
3977 // byte block to stay under 100 bytes memory limit after append | 3980 // byte block to stay under 100 bytes memory limit after append |
3978 // 80 - 10 + 28 = 98). | 3981 // 80 - 10 + 28 = 98). |
3979 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to | 3982 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to |
3980 // remove at least 6 blocks to stay under limit. | 3983 // remove at least 6 blocks to stay under limit. |
3981 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); | 3984 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); |
3982 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); | 3985 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); |
3983 } | 3986 } |
3984 | 3987 |
3985 } // namespace media | 3988 } // namespace media |
OLD | NEW |