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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 class AudioDecoderSelectorTest : public ::testing::Test { | 45 class AudioDecoderSelectorTest : public ::testing::Test { |
46 public: | 46 public: |
47 enum DecryptorCapability { | 47 enum DecryptorCapability { |
48 kNoCdm, // No CDM. Only possible for clear stream. | 48 kNoCdm, // No CDM. Only possible for clear stream. |
49 kNoDecryptor, // CDM is available but Decryptor is not supported. | 49 kNoDecryptor, // CDM is available but Decryptor is not supported. |
50 kDecryptOnly, | 50 kDecryptOnly, |
51 kDecryptAndDecode | 51 kDecryptAndDecode |
52 }; | 52 }; |
53 | 53 |
54 AudioDecoderSelectorTest() | 54 AudioDecoderSelectorTest() |
55 : media_log_(new MediaLog()), | 55 : traits_(&media_log_), |
56 traits_(media_log_), | |
57 demuxer_stream_( | 56 demuxer_stream_( |
58 new StrictMock<MockDemuxerStream>(DemuxerStream::AUDIO)), | 57 new StrictMock<MockDemuxerStream>(DemuxerStream::AUDIO)), |
59 decoder_1_(new StrictMock<MockAudioDecoder>()), | 58 decoder_1_(new StrictMock<MockAudioDecoder>()), |
60 decoder_2_(new StrictMock<MockAudioDecoder>()) { | 59 decoder_2_(new StrictMock<MockAudioDecoder>()) { |
61 all_decoders_.push_back(decoder_1_); | 60 all_decoders_.push_back(decoder_1_); |
62 all_decoders_.push_back(decoder_2_); | 61 all_decoders_.push_back(decoder_2_); |
63 // |cdm_context_| and |decryptor_| are conditionally created in | 62 // |cdm_context_| and |decryptor_| are conditionally created in |
64 // InitializeDecoderSelector(). | 63 // InitializeDecoderSelector(). |
65 } | 64 } |
66 | 65 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 .WillRepeatedly( | 104 .WillRepeatedly( |
106 RunCallback<1>(decryptor_capability == kDecryptAndDecode)); | 105 RunCallback<1>(decryptor_capability == kDecryptAndDecode)); |
107 } | 106 } |
108 } | 107 } |
109 | 108 |
110 DCHECK_GE(all_decoders_.size(), static_cast<size_t>(num_decoders)); | 109 DCHECK_GE(all_decoders_.size(), static_cast<size_t>(num_decoders)); |
111 all_decoders_.erase( | 110 all_decoders_.erase( |
112 all_decoders_.begin() + num_decoders, all_decoders_.end()); | 111 all_decoders_.begin() + num_decoders, all_decoders_.end()); |
113 | 112 |
114 decoder_selector_.reset(new AudioDecoderSelector( | 113 decoder_selector_.reset(new AudioDecoderSelector( |
115 message_loop_.task_runner(), std::move(all_decoders_), media_log_)); | 114 message_loop_.task_runner(), std::move(all_decoders_), &media_log_)); |
116 } | 115 } |
117 | 116 |
118 void SelectDecoder() { | 117 void SelectDecoder() { |
119 decoder_selector_->SelectDecoder( | 118 decoder_selector_->SelectDecoder( |
120 &traits_, demuxer_stream_.get(), cdm_context_.get(), | 119 &traits_, demuxer_stream_.get(), cdm_context_.get(), |
121 base::Bind(&AudioDecoderSelectorTest::MockOnDecoderSelected, | 120 base::Bind(&AudioDecoderSelectorTest::MockOnDecoderSelected, |
122 base::Unretained(this)), | 121 base::Unretained(this)), |
123 base::Bind(&AudioDecoderSelectorTest::OnDecoderOutput), | 122 base::Bind(&AudioDecoderSelectorTest::OnDecoderOutput), |
124 base::Bind(&AudioDecoderSelectorTest::OnWaitingForDecryptionKey)); | 123 base::Bind(&AudioDecoderSelectorTest::OnWaitingForDecryptionKey)); |
125 base::RunLoop().RunUntilIdle(); | 124 base::RunLoop().RunUntilIdle(); |
126 } | 125 } |
127 | 126 |
128 void SelectDecoderAndDestroy() { | 127 void SelectDecoderAndDestroy() { |
129 SelectDecoder(); | 128 SelectDecoder(); |
130 | 129 |
131 EXPECT_CALL(*this, OnDecoderSelected(IsNull(), IsNull())); | 130 EXPECT_CALL(*this, OnDecoderSelected(IsNull(), IsNull())); |
132 decoder_selector_.reset(); | 131 decoder_selector_.reset(); |
133 base::RunLoop().RunUntilIdle(); | 132 base::RunLoop().RunUntilIdle(); |
134 } | 133 } |
135 | 134 |
136 static void OnDecoderOutput(const scoped_refptr<AudioBuffer>& output) { | 135 static void OnDecoderOutput(const scoped_refptr<AudioBuffer>& output) { |
137 NOTREACHED(); | 136 NOTREACHED(); |
138 } | 137 } |
139 | 138 |
140 static void OnWaitingForDecryptionKey() { | 139 static void OnWaitingForDecryptionKey() { |
141 NOTREACHED(); | 140 NOTREACHED(); |
142 } | 141 } |
143 | 142 |
144 scoped_refptr<MediaLog> media_log_; | 143 MediaLog media_log_; |
145 | 144 |
146 // Stream traits specific to audio decoding. | 145 // Stream traits specific to audio decoding. |
147 DecoderStreamTraits<DemuxerStream::AUDIO> traits_; | 146 DecoderStreamTraits<DemuxerStream::AUDIO> traits_; |
148 | 147 |
149 // Declare |decoder_selector_| after |demuxer_stream_| and |decryptor_| since | 148 // Declare |decoder_selector_| after |demuxer_stream_| and |decryptor_| since |
150 // |demuxer_stream_| and |decryptor_| should outlive |decoder_selector_|. | 149 // |demuxer_stream_| and |decryptor_| should outlive |decoder_selector_|. |
151 std::unique_ptr<StrictMock<MockDemuxerStream>> demuxer_stream_; | 150 std::unique_ptr<StrictMock<MockDemuxerStream>> demuxer_stream_; |
152 | 151 |
153 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; | 152 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; |
154 | 153 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 // initialized and returned. | 428 // initialized and returned. |
430 EXPECT_CALL(*decoder_1_, Initialize(ClearConfig(), _, _, _)) | 429 EXPECT_CALL(*decoder_1_, Initialize(ClearConfig(), _, _, _)) |
431 .WillOnce(RunCallback<2>(true)); | 430 .WillOnce(RunCallback<2>(true)); |
432 EXPECT_CALL(*this, OnDecoderSelected(NotNull(), NotNull())); | 431 EXPECT_CALL(*this, OnDecoderSelected(NotNull(), NotNull())); |
433 #endif | 432 #endif |
434 | 433 |
435 SelectDecoder(); | 434 SelectDecoder(); |
436 } | 435 } |
437 | 436 |
438 } // namespace media | 437 } // namespace media |
OLD | NEW |