| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 class VideoDecoderSelectorTest : public ::testing::Test { | 43 class VideoDecoderSelectorTest : public ::testing::Test { |
| 44 public: | 44 public: |
| 45 enum DecryptorCapability { | 45 enum DecryptorCapability { |
| 46 kNoCdm, // No CDM. Only possible for clear stream. | 46 kNoCdm, // No CDM. Only possible for clear stream. |
| 47 kNoDecryptor, // CDM is available but Decryptor is not supported. | 47 kNoDecryptor, // CDM is available but Decryptor is not supported. |
| 48 kDecryptOnly, | 48 kDecryptOnly, |
| 49 kDecryptAndDecode | 49 kDecryptAndDecode |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 VideoDecoderSelectorTest() | 52 VideoDecoderSelectorTest() |
| 53 : media_log_(new MediaLog()), | 53 : traits_(&media_log_), |
| 54 traits_(media_log_), | |
| 55 demuxer_stream_( | 54 demuxer_stream_( |
| 56 new StrictMock<MockDemuxerStream>(DemuxerStream::VIDEO)), | 55 new StrictMock<MockDemuxerStream>(DemuxerStream::VIDEO)), |
| 57 decoder_1_(new StrictMock<MockVideoDecoder>()), | 56 decoder_1_(new StrictMock<MockVideoDecoder>()), |
| 58 decoder_2_(new StrictMock<MockVideoDecoder>()) { | 57 decoder_2_(new StrictMock<MockVideoDecoder>()) { |
| 59 all_decoders_.push_back(decoder_1_); | 58 all_decoders_.push_back(decoder_1_); |
| 60 all_decoders_.push_back(decoder_2_); | 59 all_decoders_.push_back(decoder_2_); |
| 61 // |cdm_context_| and |decryptor_| are conditionally created in | 60 // |cdm_context_| and |decryptor_| are conditionally created in |
| 62 // InitializeDecoderSelector(). | 61 // InitializeDecoderSelector(). |
| 63 } | 62 } |
| 64 | 63 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 .WillRepeatedly( | 97 .WillRepeatedly( |
| 99 RunCallback<1>(decryptor_capability == kDecryptAndDecode)); | 98 RunCallback<1>(decryptor_capability == kDecryptAndDecode)); |
| 100 } | 99 } |
| 101 } | 100 } |
| 102 | 101 |
| 103 DCHECK_GE(all_decoders_.size(), static_cast<size_t>(num_decoders)); | 102 DCHECK_GE(all_decoders_.size(), static_cast<size_t>(num_decoders)); |
| 104 all_decoders_.erase( | 103 all_decoders_.erase( |
| 105 all_decoders_.begin() + num_decoders, all_decoders_.end()); | 104 all_decoders_.begin() + num_decoders, all_decoders_.end()); |
| 106 | 105 |
| 107 decoder_selector_.reset(new VideoDecoderSelector( | 106 decoder_selector_.reset(new VideoDecoderSelector( |
| 108 message_loop_.task_runner(), std::move(all_decoders_), media_log_)); | 107 message_loop_.task_runner(), std::move(all_decoders_), &media_log_)); |
| 109 } | 108 } |
| 110 | 109 |
| 111 void SelectDecoder() { | 110 void SelectDecoder() { |
| 112 decoder_selector_->SelectDecoder( | 111 decoder_selector_->SelectDecoder( |
| 113 &traits_, demuxer_stream_.get(), cdm_context_.get(), | 112 &traits_, demuxer_stream_.get(), cdm_context_.get(), |
| 114 base::Bind(&VideoDecoderSelectorTest::MockOnDecoderSelected, | 113 base::Bind(&VideoDecoderSelectorTest::MockOnDecoderSelected, |
| 115 base::Unretained(this)), | 114 base::Unretained(this)), |
| 116 base::Bind(&VideoDecoderSelectorTest::FrameReady, | 115 base::Bind(&VideoDecoderSelectorTest::FrameReady, |
| 117 base::Unretained(this)), | 116 base::Unretained(this)), |
| 118 base::Bind(&VideoDecoderSelectorTest::OnWaitingForDecryptionKey, | 117 base::Bind(&VideoDecoderSelectorTest::OnWaitingForDecryptionKey, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 129 } | 128 } |
| 130 | 129 |
| 131 void FrameReady(const scoped_refptr<VideoFrame>& frame) { | 130 void FrameReady(const scoped_refptr<VideoFrame>& frame) { |
| 132 NOTREACHED(); | 131 NOTREACHED(); |
| 133 } | 132 } |
| 134 | 133 |
| 135 void OnWaitingForDecryptionKey() { | 134 void OnWaitingForDecryptionKey() { |
| 136 NOTREACHED(); | 135 NOTREACHED(); |
| 137 } | 136 } |
| 138 | 137 |
| 139 scoped_refptr<MediaLog> media_log_; | 138 MediaLog media_log_; |
| 140 | 139 |
| 141 // Stream traits specific to video decoding. | 140 // Stream traits specific to video decoding. |
| 142 DecoderStreamTraits<DemuxerStream::VIDEO> traits_; | 141 DecoderStreamTraits<DemuxerStream::VIDEO> traits_; |
| 143 | 142 |
| 144 // Declare |decoder_selector_| after |demuxer_stream_| and |decryptor_| since | 143 // Declare |decoder_selector_| after |demuxer_stream_| and |decryptor_| since |
| 145 // |demuxer_stream_| and |decryptor_| should outlive |decoder_selector_|. | 144 // |demuxer_stream_| and |decryptor_| should outlive |decoder_selector_|. |
| 146 std::unique_ptr<StrictMock<MockDemuxerStream>> demuxer_stream_; | 145 std::unique_ptr<StrictMock<MockDemuxerStream>> demuxer_stream_; |
| 147 | 146 |
| 148 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; | 147 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; |
| 149 | 148 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // initialized and returned. | 425 // initialized and returned. |
| 427 EXPECT_CALL(*decoder_1_, Initialize(ClearConfig(), _, _, _, _)) | 426 EXPECT_CALL(*decoder_1_, Initialize(ClearConfig(), _, _, _, _)) |
| 428 .WillOnce(RunCallback<3>(true)); | 427 .WillOnce(RunCallback<3>(true)); |
| 429 EXPECT_CALL(*this, OnDecoderSelected(NotNull(), NotNull())); | 428 EXPECT_CALL(*this, OnDecoderSelected(NotNull(), NotNull())); |
| 430 #endif | 429 #endif |
| 431 | 430 |
| 432 SelectDecoder(); | 431 SelectDecoder(); |
| 433 } | 432 } |
| 434 | 433 |
| 435 } // namespace media | 434 } // namespace media |
| OLD | NEW |