| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 decoder_->Initialize(demuxer_, NewExpectedStatusCB(status), | 99 decoder_->Initialize(demuxer_, NewExpectedStatusCB(status), |
| 100 base::Bind(&MockStatisticsCB::OnStatistics, | 100 base::Bind(&MockStatisticsCB::OnStatistics, |
| 101 base::Unretained(&statistics_cb_))); | 101 base::Unretained(&statistics_cb_))); |
| 102 message_loop_.RunUntilIdle(); | 102 message_loop_.RunUntilIdle(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void Initialize() { | 105 void Initialize() { |
| 106 EXPECT_CALL(*decryptor_, InitializeVideoDecoderMock(_, _)) | 106 EXPECT_CALL(*decryptor_, InitializeVideoDecoderMock(_, _)) |
| 107 .Times(AtMost(1)) | 107 .Times(AtMost(1)) |
| 108 .WillOnce(RunCallback<1>(true)); | 108 .WillOnce(RunCallback<1>(true)); |
| 109 EXPECT_CALL(*decryptor_, RegisterKeyAddedCB(Decryptor::kVideo, _)) | 109 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _)) |
| 110 .WillOnce(SaveArg<1>(&key_added_cb_)); | 110 .WillOnce(SaveArg<1>(&key_added_cb_)); |
| 111 | 111 |
| 112 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, | 112 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, |
| 113 kCodedSize, kVisibleRect, kNaturalSize, | 113 kCodedSize, kVisibleRect, kNaturalSize, |
| 114 NULL, 0, true, true); | 114 NULL, 0, true, true); |
| 115 | 115 |
| 116 InitializeAndExpectStatus(config_, PIPELINE_OK); | 116 InitializeAndExpectStatus(config_, PIPELINE_OK); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void ReadAndExpectFrameReadyWith( | 119 void ReadAndExpectFrameReadyWith( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 void Reset() { | 211 void Reset() { |
| 212 EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo)) | 212 EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo)) |
| 213 .WillRepeatedly(InvokeWithoutArgs( | 213 .WillRepeatedly(InvokeWithoutArgs( |
| 214 this, &DecryptingVideoDecoderTest::AbortPendingVideoDecodeCB)); | 214 this, &DecryptingVideoDecoderTest::AbortPendingVideoDecodeCB)); |
| 215 | 215 |
| 216 decoder_->Reset(NewExpectedClosure()); | 216 decoder_->Reset(NewExpectedClosure()); |
| 217 message_loop_.RunUntilIdle(); | 217 message_loop_.RunUntilIdle(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void Stop() { | 220 void Stop() { |
| 221 EXPECT_CALL(*decryptor_, RegisterKeyAddedCB(Decryptor::kVideo, | 221 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, |
| 222 IsNullCallback())) | 222 IsNullCallback())) |
| 223 .Times(AtMost(1)); | 223 .Times(AtMost(1)); |
| 224 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo)) | 224 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo)) |
| 225 .WillRepeatedly(InvokeWithoutArgs( | 225 .WillRepeatedly(InvokeWithoutArgs( |
| 226 this, &DecryptingVideoDecoderTest::AbortAllPendingCBs)); | 226 this, &DecryptingVideoDecoderTest::AbortAllPendingCBs)); |
| 227 | 227 |
| 228 decoder_->Stop(NewExpectedClosure()); | 228 decoder_->Stop(NewExpectedClosure()); |
| 229 message_loop_.RunUntilIdle(); | 229 message_loop_.RunUntilIdle(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 MOCK_METHOD1(RequestDecryptorNotification, void(const DecryptorReadyCB&)); | 232 MOCK_METHOD1(RequestDecryptorNotification, void(const DecryptorReadyCB&)); |
| 233 | 233 |
| 234 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, | 234 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, |
| 235 const scoped_refptr<VideoFrame>&)); | 235 const scoped_refptr<VideoFrame>&)); |
| 236 | 236 |
| 237 MessageLoop message_loop_; | 237 MessageLoop message_loop_; |
| 238 scoped_refptr<DecryptingVideoDecoder> decoder_; | 238 scoped_refptr<DecryptingVideoDecoder> decoder_; |
| 239 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; | 239 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; |
| 240 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; | 240 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; |
| 241 MockStatisticsCB statistics_cb_; | 241 MockStatisticsCB statistics_cb_; |
| 242 VideoDecoderConfig config_; | 242 VideoDecoderConfig config_; |
| 243 | 243 |
| 244 DemuxerStream::ReadCB pending_demuxer_read_cb_; | 244 DemuxerStream::ReadCB pending_demuxer_read_cb_; |
| 245 Decryptor::DecoderInitCB pending_init_cb_; | 245 Decryptor::DecoderInitCB pending_init_cb_; |
| 246 Decryptor::KeyAddedCB key_added_cb_; | 246 Decryptor::NewKeyCB key_added_cb_; |
| 247 Decryptor::VideoDecodeCB pending_video_decode_cb_; | 247 Decryptor::VideoDecodeCB pending_video_decode_cb_; |
| 248 | 248 |
| 249 // Constant buffer/frames to be returned by the |demuxer_| and |decryptor_|. | 249 // Constant buffer/frames to be returned by the |demuxer_| and |decryptor_|. |
| 250 scoped_refptr<DecoderBuffer> encrypted_buffer_; | 250 scoped_refptr<DecoderBuffer> encrypted_buffer_; |
| 251 scoped_refptr<VideoFrame> decoded_video_frame_; | 251 scoped_refptr<VideoFrame> decoded_video_frame_; |
| 252 scoped_refptr<VideoFrame> null_video_frame_; | 252 scoped_refptr<VideoFrame> null_video_frame_; |
| 253 scoped_refptr<VideoFrame> end_of_stream_video_frame_; | 253 scoped_refptr<VideoFrame> end_of_stream_video_frame_; |
| 254 | 254 |
| 255 private: | 255 private: |
| 256 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoderTest); | 256 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoderTest); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 EXPECT_CALL(*demuxer_, Read(_)) | 597 EXPECT_CALL(*demuxer_, Read(_)) |
| 598 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, | 598 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, |
| 599 scoped_refptr<DecoderBuffer>())); | 599 scoped_refptr<DecoderBuffer>())); |
| 600 | 600 |
| 601 // TODO(xhwang): Update this test when kConfigChanged is supported in | 601 // TODO(xhwang): Update this test when kConfigChanged is supported in |
| 602 // DecryptingVideoDecoder. | 602 // DecryptingVideoDecoder. |
| 603 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_); | 603 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_); |
| 604 } | 604 } |
| 605 | 605 |
| 606 } // namespace media | 606 } // namespace media |
| OLD | NEW |