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/decrypt_config.h" |
9 #include "media/base/mock_demuxer_host.h" | 10 #include "media/base/mock_demuxer_host.h" |
10 #include "media/base/test_data_util.h" | 11 #include "media/base/test_data_util.h" |
11 #include "media/base/test_helpers.h" | 12 #include "media/base/test_helpers.h" |
12 #include "media/filters/chunk_demuxer.h" | 13 #include "media/filters/chunk_demuxer.h" |
13 #include "media/webm/cluster_builder.h" | 14 #include "media/webm/cluster_builder.h" |
14 #include "media/webm/webm_constants.h" | 15 #include "media/webm/webm_constants.h" |
| 16 #include "media/webm/webm_crypto_helpers.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 | 18 |
17 using ::testing::AnyNumber; | 19 using ::testing::AnyNumber; |
18 using ::testing::Exactly; | 20 using ::testing::Exactly; |
19 using ::testing::InSequence; | 21 using ::testing::InSequence; |
20 using ::testing::NotNull; | 22 using ::testing::NotNull; |
21 using ::testing::Return; | 23 using ::testing::Return; |
22 using ::testing::SaveArg; | 24 using ::testing::SaveArg; |
23 using ::testing::SetArgumentPointee; | 25 using ::testing::SetArgumentPointee; |
24 using ::testing::_; | 26 using ::testing::_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 static const int kAudioTrackNum = 2; | 61 static const int kAudioTrackNum = 2; |
60 | 62 |
61 static const int kAudioBlockDuration = 23; | 63 static const int kAudioBlockDuration = 23; |
62 static const int kVideoBlockDuration = 33; | 64 static const int kVideoBlockDuration = 33; |
63 | 65 |
64 static const char kSourceId[] = "SourceId"; | 66 static const char kSourceId[] = "SourceId"; |
65 static const char kDefaultFirstClusterRange[] = "{ [0,46) }"; | 67 static const char kDefaultFirstClusterRange[] = "{ [0,46) }"; |
66 static const int kDefaultFirstClusterEndTimestamp = 66; | 68 static const int kDefaultFirstClusterEndTimestamp = 66; |
67 static const int kDefaultSecondClusterEndTimestamp = 132; | 69 static const int kDefaultSecondClusterEndTimestamp = 132; |
68 | 70 |
69 static const char kWebMInitDataType[] = "video/webm"; | |
70 | |
71 base::TimeDelta kDefaultDuration() { | 71 base::TimeDelta kDefaultDuration() { |
72 return base::TimeDelta::FromMilliseconds(201224); | 72 return base::TimeDelta::FromMilliseconds(201224); |
73 } | 73 } |
74 | 74 |
75 // Write an integer into buffer in the form of vint that spans 8 bytes. | 75 // Write an integer into buffer in the form of vint that spans 8 bytes. |
76 // The data pointed by |buffer| should be at least 8 bytes long. | 76 // The data pointed by |buffer| should be at least 8 bytes long. |
77 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF. | 77 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF. |
78 static void WriteInt64(uint8* buffer, int64 number) { | 78 static void WriteInt64(uint8* buffer, int64 number) { |
79 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF)); | 79 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF)); |
80 buffer[0] = 0x01; | 80 buffer[0] = 0x01; |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 if ((!has_audio && is_audio_encrypted) || | 777 if ((!has_audio && is_audio_encrypted) || |
778 (!has_video && is_video_encrypted)) { | 778 (!has_video && is_video_encrypted)) { |
779 continue; | 779 continue; |
780 } | 780 } |
781 | 781 |
782 CreateNewDemuxer(); | 782 CreateNewDemuxer(); |
783 | 783 |
784 if (is_audio_encrypted || is_video_encrypted) { | 784 if (is_audio_encrypted || is_video_encrypted) { |
785 int need_key_count = (is_audio_encrypted ? 1 : 0) + | 785 int need_key_count = (is_audio_encrypted ? 1 : 0) + |
786 (is_video_encrypted ? 1 : 0); | 786 (is_video_encrypted ? 1 : 0); |
787 EXPECT_CALL(*this, NeedKeyMock(kWebMInitDataType, NotNull(), 16)) | 787 EXPECT_CALL(*this, NeedKeyMock(kWebMEncryptInitDataType, NotNull(), |
| 788 DecryptConfig::kDecryptionKeySize)) |
788 .Times(Exactly(need_key_count)); | 789 .Times(Exactly(need_key_count)); |
789 } | 790 } |
790 | 791 |
791 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 792 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
792 has_audio, has_video, is_audio_encrypted, is_video_encrypted)); | 793 has_audio, has_video, is_audio_encrypted, is_video_encrypted)); |
793 | 794 |
794 scoped_refptr<DemuxerStream> audio_stream = | 795 scoped_refptr<DemuxerStream> audio_stream = |
795 demuxer_->GetStream(DemuxerStream::AUDIO); | 796 demuxer_->GetStream(DemuxerStream::AUDIO); |
796 if (has_audio) { | 797 if (has_audio) { |
797 ASSERT_TRUE(audio_stream); | 798 ASSERT_TRUE(audio_stream); |
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 // call. This can happen if video element gets destroyed before | 2538 // call. This can happen if video element gets destroyed before |
2538 // the pipeline has a chance to initialize the demuxer. | 2539 // the pipeline has a chance to initialize the demuxer. |
2539 TEST_F(ChunkDemuxerTest, TestShutdownBeforeInitialize) { | 2540 TEST_F(ChunkDemuxerTest, TestShutdownBeforeInitialize) { |
2540 demuxer_->Shutdown(); | 2541 demuxer_->Shutdown(); |
2541 demuxer_->Initialize( | 2542 demuxer_->Initialize( |
2542 &host_, CreateInitDoneCB(DEMUXER_ERROR_COULD_NOT_OPEN)); | 2543 &host_, CreateInitDoneCB(DEMUXER_ERROR_COULD_NOT_OPEN)); |
2543 message_loop_.RunUntilIdle(); | 2544 message_loop_.RunUntilIdle(); |
2544 } | 2545 } |
2545 | 2546 |
2546 } // namespace media | 2547 } // namespace media |
OLD | NEW |