| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "media/base/audio_decoder_config.h" | 7 #include "media/base/audio_decoder_config.h" |
| 8 #include "media/base/decoder_buffer.h" | 8 #include "media/base/decoder_buffer.h" |
| 9 #include "media/base/mock_callback.h" | 9 #include "media/base/mock_callback.h" |
| 10 #include "media/base/mock_demuxer_host.h" | 10 #include "media/base/mock_demuxer_host.h" |
| 11 #include "media/base/test_data_util.h" | 11 #include "media/base/test_data_util.h" |
| 12 #include "media/filters/chunk_demuxer.h" | 12 #include "media/filters/chunk_demuxer.h" |
| 13 #include "media/webm/cluster_builder.h" | 13 #include "media/webm/cluster_builder.h" |
| 14 #include "media/webm/webm_constants.h" | 14 #include "media/webm/webm_constants.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using ::testing::AnyNumber; | 17 using ::testing::AnyNumber; |
| 18 using ::testing::Exactly; | 18 using ::testing::Exactly; |
| 19 using ::testing::InSequence; | 19 using ::testing::InSequence; |
| 20 using ::testing::NotNull; | 20 using ::testing::NotNull; |
| 21 using ::testing::Return; | 21 using ::testing::Return; |
| 22 using ::testing::SaveArg; | 22 using ::testing::SaveArg; |
| 23 using ::testing::SetArgumentPointee; | 23 using ::testing::SetArgumentPointee; |
| 24 using ::testing::StrNe; |
| 24 using ::testing::_; | 25 using ::testing::_; |
| 25 | 26 |
| 26 namespace media { | 27 namespace media { |
| 27 | 28 |
| 28 static const uint8 kTracksHeader[] = { | 29 static const uint8 kTracksHeader[] = { |
| 29 0x16, 0x54, 0xAE, 0x6B, // Tracks ID | 30 0x16, 0x54, 0xAE, 0x6B, // Tracks ID |
| 30 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) | 31 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 static const int kTracksHeaderSize = sizeof(kTracksHeader); | 34 static const int kTracksHeaderSize = sizeof(kTracksHeader); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 } | 726 } |
| 726 | 727 |
| 727 return true; | 728 return true; |
| 728 } | 729 } |
| 729 | 730 |
| 730 MOCK_METHOD0(DemuxerOpened, void()); | 731 MOCK_METHOD0(DemuxerOpened, void()); |
| 731 // TODO(xhwang): This is a workaround of the issue that move-only parameters | 732 // TODO(xhwang): This is a workaround of the issue that move-only parameters |
| 732 // are not supported in mocked methods. Remove this when the issue is fixed | 733 // are not supported in mocked methods. Remove this when the issue is fixed |
| 733 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use | 734 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use |
| 734 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). | 735 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). |
| 735 MOCK_METHOD2(NeedKeyMock, void(const uint8* init_data, int init_data_size)); | 736 MOCK_METHOD3(NeedKeyMock, void(const std::string& type, |
| 736 void DemuxerNeedKey(scoped_array<uint8> init_data, int init_data_size) { | 737 const uint8* init_data, int init_data_size)); |
| 737 NeedKeyMock(init_data.get(), init_data_size); | 738 void DemuxerNeedKey(const std::string& type, |
| 739 scoped_array<uint8> init_data, int init_data_size) { |
| 740 NeedKeyMock(type, init_data.get(), init_data_size); |
| 738 } | 741 } |
| 739 | 742 |
| 740 MessageLoop message_loop_; | 743 MessageLoop message_loop_; |
| 741 MockDemuxerHost host_; | 744 MockDemuxerHost host_; |
| 742 | 745 |
| 743 scoped_refptr<ChunkDemuxer> demuxer_; | 746 scoped_refptr<ChunkDemuxer> demuxer_; |
| 744 | 747 |
| 745 private: | 748 private: |
| 746 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); | 749 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); |
| 747 }; | 750 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 759 if ((!has_audio && is_audio_encrypted) || | 762 if ((!has_audio && is_audio_encrypted) || |
| 760 (!has_video && is_video_encrypted)) { | 763 (!has_video && is_video_encrypted)) { |
| 761 continue; | 764 continue; |
| 762 } | 765 } |
| 763 | 766 |
| 764 CreateNewDemuxer(); | 767 CreateNewDemuxer(); |
| 765 | 768 |
| 766 if (is_audio_encrypted || is_video_encrypted) { | 769 if (is_audio_encrypted || is_video_encrypted) { |
| 767 int need_key_count = (is_audio_encrypted ? 1 : 0) + | 770 int need_key_count = (is_audio_encrypted ? 1 : 0) + |
| 768 (is_video_encrypted ? 1 : 0); | 771 (is_video_encrypted ? 1 : 0); |
| 769 EXPECT_CALL(*this, NeedKeyMock(NotNull(), 16)) | 772 EXPECT_CALL(*this, NeedKeyMock(StrNe(""), NotNull(), 16)) |
| 770 .Times(Exactly(need_key_count)); | 773 .Times(Exactly(need_key_count)); |
| 771 } | 774 } |
| 772 | 775 |
| 773 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 776 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
| 774 has_audio, has_video, is_audio_encrypted, is_video_encrypted)); | 777 has_audio, has_video, is_audio_encrypted, is_video_encrypted)); |
| 775 | 778 |
| 776 scoped_refptr<DemuxerStream> audio_stream = | 779 scoped_refptr<DemuxerStream> audio_stream = |
| 777 demuxer_->GetStream(DemuxerStream::AUDIO); | 780 demuxer_->GetStream(DemuxerStream::AUDIO); |
| 778 if (has_audio) { | 781 if (has_audio) { |
| 779 ASSERT_TRUE(audio_stream); | 782 ASSERT_TRUE(audio_stream); |
| (...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2424 | 2427 |
| 2425 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); | 2428 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); |
| 2426 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); | 2429 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); |
| 2427 | 2430 |
| 2428 EXPECT_CALL(host_, SetDuration( | 2431 EXPECT_CALL(host_, SetDuration( |
| 2429 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); | 2432 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); |
| 2430 demuxer_->EndOfStream(PIPELINE_OK); | 2433 demuxer_->EndOfStream(PIPELINE_OK); |
| 2431 } | 2434 } |
| 2432 | 2435 |
| 2433 } // namespace media | 2436 } // namespace media |
| OLD | NEW |