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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 }; | 50 }; |
51 | 51 |
52 class VideoFrameStreamTest | 52 class VideoFrameStreamTest |
53 : public testing::Test, | 53 : public testing::Test, |
54 public testing::WithParamInterface<VideoFrameStreamTestParams> { | 54 public testing::WithParamInterface<VideoFrameStreamTestParams> { |
55 public: | 55 public: |
56 VideoFrameStreamTest() | 56 VideoFrameStreamTest() |
57 : demuxer_stream_(new FakeDemuxerStream(kNumConfigs, | 57 : demuxer_stream_(new FakeDemuxerStream(kNumConfigs, |
58 kNumBuffersInOneConfig, | 58 kNumBuffersInOneConfig, |
59 GetParam().is_encrypted)), | 59 GetParam().is_encrypted)), |
60 cdm_context_(new StrictMock<MockCdmContext>()), | |
61 is_initialized_(false), | 60 is_initialized_(false), |
62 num_decoded_frames_(0), | 61 num_decoded_frames_(0), |
63 pending_initialize_(false), | 62 pending_initialize_(false), |
64 pending_read_(false), | 63 pending_read_(false), |
65 pending_reset_(false), | 64 pending_reset_(false), |
66 pending_stop_(false), | 65 pending_stop_(false), |
67 num_decoded_bytes_unreported_(0), | 66 num_decoded_bytes_unreported_(0), |
68 has_no_key_(false) { | 67 has_no_key_(false) { |
69 int decoding_delay = GetParam().decoding_delay; | 68 int decoding_delay = GetParam().decoding_delay; |
70 int parallel_decoding = GetParam().parallel_decoding; | 69 int parallel_decoding = GetParam().parallel_decoding; |
71 BytesDecodedCB bytes_decoded_cb = base::Bind( | 70 BytesDecodedCB bytes_decoded_cb = base::Bind( |
72 &VideoFrameStreamTest::OnBytesDecoded, base::Unretained(this)); | 71 &VideoFrameStreamTest::OnBytesDecoded, base::Unretained(this)); |
73 | 72 |
74 decoder1_ = new FakeVideoDecoder(decoding_delay, parallel_decoding, | 73 decoder1_ = new FakeVideoDecoder(decoding_delay, parallel_decoding, |
75 bytes_decoded_cb); | 74 bytes_decoded_cb); |
76 decoder2_ = new FakeVideoDecoder(decoding_delay, parallel_decoding, | 75 decoder2_ = new FakeVideoDecoder(decoding_delay, parallel_decoding, |
77 bytes_decoded_cb); | 76 bytes_decoded_cb); |
78 decoder3_ = new FakeVideoDecoder(decoding_delay, parallel_decoding, | 77 decoder3_ = new FakeVideoDecoder(decoding_delay, parallel_decoding, |
79 bytes_decoded_cb); | 78 bytes_decoded_cb); |
80 | 79 |
81 // TODO(xhwang): We should test the case where only certain decoder | 80 // TODO(xhwang): We should test the case where only certain decoder |
82 // supports encrypted streams. Currently this is hard to test becasue we use | 81 // supports encrypted streams. Currently this is hard to test because we use |
83 // parameterized tests which need to pass in all combinations. | 82 // parameterized tests which need to pass in all combinations. |
84 if (GetParam().is_encrypted && !GetParam().has_decryptor) { | 83 if (GetParam().is_encrypted && !GetParam().has_decryptor) { |
85 decoder1_->EnableEncryptedConfigSupport(); | 84 decoder1_->EnableEncryptedConfigSupport(); |
86 decoder2_->EnableEncryptedConfigSupport(); | 85 decoder2_->EnableEncryptedConfigSupport(); |
87 decoder3_->EnableEncryptedConfigSupport(); | 86 decoder3_->EnableEncryptedConfigSupport(); |
88 } | 87 } |
89 | 88 |
90 ScopedVector<VideoDecoder> decoders; | 89 ScopedVector<VideoDecoder> decoders; |
91 decoders.push_back(decoder1_); | 90 decoders.push_back(decoder1_); |
92 decoders.push_back(decoder2_); | 91 decoders.push_back(decoder2_); |
93 decoders.push_back(decoder3_); | 92 decoders.push_back(decoder3_); |
94 | 93 |
95 video_frame_stream_.reset(new VideoFrameStream( | 94 video_frame_stream_.reset(new VideoFrameStream( |
96 message_loop_.task_runner(), std::move(decoders), new MediaLog())); | 95 message_loop_.task_runner(), std::move(decoders), new MediaLog())); |
97 | 96 |
98 if (GetParam().has_decryptor) { | 97 if (GetParam().is_encrypted && GetParam().has_decryptor) { |
99 decryptor_.reset(new NiceMock<MockDecryptor>()); | 98 decryptor_.reset(new NiceMock<MockDecryptor>()); |
100 | 99 |
101 // Decryptor can only decrypt (not decrypt-and-decode) so that | 100 // Decryptor can only decrypt (not decrypt-and-decode) so that |
102 // DecryptingDemuxerStream will be used. | 101 // DecryptingDemuxerStream will be used. |
103 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _)) | 102 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _)) |
104 .WillRepeatedly(RunCallback<1>(false)); | 103 .WillRepeatedly(RunCallback<1>(false)); |
105 EXPECT_CALL(*decryptor_, Decrypt(_, _, _)) | 104 EXPECT_CALL(*decryptor_, Decrypt(_, _, _)) |
106 .WillRepeatedly(Invoke(this, &VideoFrameStreamTest::Decrypt)); | 105 .WillRepeatedly(Invoke(this, &VideoFrameStreamTest::Decrypt)); |
107 } | 106 } |
108 | 107 |
109 EXPECT_CALL(*cdm_context_, GetDecryptor()) | 108 if (GetParam().is_encrypted) { |
110 .WillRepeatedly(Return(decryptor_.get())); | 109 cdm_context_.reset(new StrictMock<MockCdmContext>()); |
| 110 |
| 111 EXPECT_CALL(*cdm_context_, GetDecryptor()) |
| 112 .WillRepeatedly(Return(decryptor_.get())); |
| 113 } |
111 } | 114 } |
112 | 115 |
113 ~VideoFrameStreamTest() { | 116 ~VideoFrameStreamTest() { |
114 // Check that the pipeline statistics callback was fired correctly. | 117 // Check that the pipeline statistics callback was fired correctly. |
115 EXPECT_EQ(num_decoded_bytes_unreported_, 0); | 118 EXPECT_EQ(num_decoded_bytes_unreported_, 0); |
116 | 119 |
117 is_initialized_ = false; | 120 is_initialized_ = false; |
118 decoder1_ = NULL; | 121 decoder1_ = NULL; |
119 decoder2_ = NULL; | 122 decoder2_ = NULL; |
120 decoder3_ = NULL; | 123 decoder3_ = NULL; |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1121 |
1119 TEST_P(VideoFrameStreamTest, Destroy_DuringFallbackDecoderSelection) { | 1122 TEST_P(VideoFrameStreamTest, Destroy_DuringFallbackDecoderSelection) { |
1120 Initialize(); | 1123 Initialize(); |
1121 decoder1_->SimulateFailureToInit(); | 1124 decoder1_->SimulateFailureToInit(); |
1122 EnterPendingState(DECODER_REINIT); | 1125 EnterPendingState(DECODER_REINIT); |
1123 decoder2_->HoldNextInit(); | 1126 decoder2_->HoldNextInit(); |
1124 SatisfyPendingCallback(DECODER_REINIT); | 1127 SatisfyPendingCallback(DECODER_REINIT); |
1125 } | 1128 } |
1126 | 1129 |
1127 } // namespace media | 1130 } // namespace media |
OLD | NEW |