OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string> |
| 6 #include <vector> |
| 7 |
| 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" |
| 10 #include "base/message_loop.h" |
| 11 #include "media/base/decoder_buffer.h" |
| 12 #include "media/base/decrypt_config.h" |
| 13 #include "media/base/mock_callback.h" |
| 14 #include "media/base/mock_filters.h" |
| 15 #include "media/base/video_frame.h" |
| 16 #include "media/filters/ffmpeg_decoder_unittest.h" |
| 17 #include "media/crypto/decrypting_video_decoder.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 |
| 20 using ::testing::_; |
| 21 using ::testing::Invoke; |
| 22 using ::testing::IsNull; |
| 23 using ::testing::ReturnRef; |
| 24 using ::testing::SaveArg; |
| 25 using ::testing::StrictMock; |
| 26 |
| 27 namespace media { |
| 28 |
| 29 static const VideoFrame::Format kVideoFormat = VideoFrame::YV12; |
| 30 static const gfx::Size kCodedSize(320, 240); |
| 31 static const gfx::Rect kVisibleRect(320, 240); |
| 32 static const gfx::Size kNaturalSize(320, 240); |
| 33 static const uint8 kFakeKeyId[] = { 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44 }; |
| 34 static const uint8 kFakeIv[DecryptConfig::kDecryptionKeySize] = { 0 }; |
| 35 |
| 36 // Create a fake non-empty encrypted buffer. |
| 37 static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() { |
| 38 const int buffer_size = 16; // Need a non-empty buffer; |
| 39 const int encrypted_frame_offset = 1; // This should be non-zero. |
| 40 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size)); |
| 41 buffer->SetDecryptConfig(scoped_ptr<DecryptConfig>(new DecryptConfig( |
| 42 std::string(reinterpret_cast<const char*>(kFakeKeyId), |
| 43 arraysize(kFakeKeyId)), |
| 44 std::string(reinterpret_cast<const char*>(kFakeIv), |
| 45 DecryptConfig::kDecryptionKeySize), |
| 46 encrypted_frame_offset, |
| 47 std::vector<SubsampleEntry>()))); |
| 48 return buffer; |
| 49 } |
| 50 |
| 51 ACTION_P(ReturnBuffer, buffer) { |
| 52 arg0.Run(buffer ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer); |
| 53 } |
| 54 |
| 55 ACTION(ReturnConfigChanged) { |
| 56 arg0.Run(DemuxerStream::kConfigChanged, scoped_refptr<DecoderBuffer>(NULL)); |
| 57 } |
| 58 |
| 59 ACTION_P(RunCallback1, param) { |
| 60 arg1.Run(param); |
| 61 } |
| 62 |
| 63 ACTION_P2(RunCallback2, param1, param2) { |
| 64 arg1.Run(param1, param2); |
| 65 } |
| 66 |
| 67 class DecryptingVideoDecoderTest : public testing::Test { |
| 68 public: |
| 69 DecryptingVideoDecoderTest() |
| 70 : decryptor_(new StrictMock<MockDecryptor>()), |
| 71 decoder_(NULL), |
| 72 demuxer_(new StrictMock<MockDemuxerStream>()), |
| 73 read_cb_(base::Bind(&DecryptingVideoDecoderTest::FrameReady, |
| 74 base::Unretained(this))) { |
| 75 |
| 76 decoder_ = new StrictMock<DecryptingVideoDecoder>( |
| 77 base::Bind(&Identity<scoped_refptr<base::MessageLoopProxy> >, |
| 78 message_loop_.message_loop_proxy()), |
| 79 decryptor_.get()); |
| 80 |
| 81 // Initialize various test buffers. |
| 82 encrypted_buffer_ = CreateFakeEncryptedBuffer(); |
| 83 end_of_stream_buffer_ = DecoderBuffer::CreateEOSBuffer(); |
| 84 decoded_video_frame_ = VideoFrame::CreateBlackFrame(kCodedSize); |
| 85 } |
| 86 |
| 87 virtual ~DecryptingVideoDecoderTest() {} |
| 88 |
| 89 void Initialize() { |
| 90 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _)) |
| 91 .WillOnce(RunCallback1(true)); |
| 92 |
| 93 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, |
| 94 kCodedSize, kVisibleRect, kNaturalSize, |
| 95 NULL, 0, true, true); |
| 96 |
| 97 InitializeWithConfig(config_); |
| 98 } |
| 99 |
| 100 void InitializeWithConfigAndStatus(const VideoDecoderConfig& config, |
| 101 PipelineStatus status) { |
| 102 EXPECT_CALL(*demuxer_, video_decoder_config()) |
| 103 .WillRepeatedly(ReturnRef(config)); |
| 104 |
| 105 decoder_->Initialize(demuxer_, NewExpectedStatusCB(status), |
| 106 base::Bind(&MockStatisticsCB::OnStatistics, |
| 107 base::Unretained(&statistics_cb_))); |
| 108 message_loop_.RunAllPending(); |
| 109 } |
| 110 |
| 111 void InitializeWithConfig(const VideoDecoderConfig& config) { |
| 112 InitializeWithConfigAndStatus(config, PIPELINE_OK); |
| 113 } |
| 114 |
| 115 void RunPendingVideoDecodeCB() { |
| 116 if (!video_decode_cb_.is_null()) { |
| 117 base::ResetAndReturn(&video_decode_cb_).Run( |
| 118 Decryptor::kSuccess, scoped_refptr<VideoFrame>(NULL)); |
| 119 } |
| 120 } |
| 121 |
| 122 void Reset() { |
| 123 EXPECT_CALL(*decryptor_, CancelDecryptAndDecodeVideo()) |
| 124 .WillOnce(Invoke(this, |
| 125 &DecryptingVideoDecoderTest::RunPendingVideoDecodeCB)); |
| 126 |
| 127 decoder_->Reset(NewExpectedClosure()); |
| 128 message_loop_.RunAllPending(); |
| 129 } |
| 130 |
| 131 void Stop() { |
| 132 EXPECT_CALL(*decryptor_, StopVideoDecoder()) |
| 133 .WillOnce(Invoke(this, |
| 134 &DecryptingVideoDecoderTest::RunPendingVideoDecodeCB)); |
| 135 |
| 136 decoder_->Stop(NewExpectedClosure()); |
| 137 message_loop_.RunAllPending(); |
| 138 } |
| 139 |
| 140 // Sets up expectations and actions to put DecryptingVideoDecoder in an active |
| 141 // decoding state. |
| 142 void EnterDecodingState() { |
| 143 VideoDecoder::Status status; |
| 144 scoped_refptr<VideoFrame> video_frame; |
| 145 DecryptAndDecodeSingleFrame(encrypted_buffer_, &status, &video_frame); |
| 146 |
| 147 EXPECT_EQ(VideoDecoder::kOk, status); |
| 148 ASSERT_TRUE(video_frame); |
| 149 EXPECT_FALSE(video_frame->IsEndOfStream()); |
| 150 } |
| 151 |
| 152 // Sets up expectations and actions to put DecryptingVideoDecoder in an end |
| 153 // of stream state. |
| 154 void EnterEndOfStreamState() { |
| 155 scoped_refptr<VideoFrame> video_frame; |
| 156 VideoDecoder::Status status; |
| 157 Read(&status, &video_frame); |
| 158 |
| 159 EXPECT_EQ(VideoDecoder::kOk, status); |
| 160 ASSERT_TRUE(video_frame); |
| 161 EXPECT_TRUE(video_frame->IsEndOfStream()); |
| 162 } |
| 163 |
| 164 // Decodes the single compressed frame in |buffer| and writes the |
| 165 // uncompressed output to |video_frame|. This method works with single |
| 166 // and multithreaded decoders. End of stream buffers are used to trigger |
| 167 // the frame to be returned in the multithreaded decoder case. |
| 168 void DecryptAndDecodeSingleFrame(const scoped_refptr<DecoderBuffer>& buffer, |
| 169 VideoDecoder::Status* status, |
| 170 scoped_refptr<VideoFrame>* video_frame) { |
| 171 EXPECT_CALL(*demuxer_, Read(_)) |
| 172 .WillOnce(ReturnBuffer(buffer)) |
| 173 .WillRepeatedly(ReturnBuffer(end_of_stream_buffer_)); |
| 174 |
| 175 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) |
| 176 .WillOnce(RunCallback2(Decryptor::kSuccess, decoded_video_frame_)) |
| 177 .WillRepeatedly(RunCallback2(Decryptor::kSuccess, |
| 178 VideoFrame::CreateEmptyFrame())); |
| 179 |
| 180 EXPECT_CALL(statistics_cb_, OnStatistics(_)); |
| 181 Read(status, video_frame); |
| 182 } |
| 183 |
| 184 void Read(VideoDecoder::Status* status, |
| 185 scoped_refptr<VideoFrame>* video_frame) { |
| 186 EXPECT_CALL(*this, FrameReady(_, _)) |
| 187 .WillOnce(DoAll(SaveArg<0>(status), SaveArg<1>(video_frame))); |
| 188 |
| 189 decoder_->Read(read_cb_); |
| 190 message_loop_.RunAllPending(); |
| 191 } |
| 192 |
| 193 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, |
| 194 const scoped_refptr<VideoFrame>&)); |
| 195 |
| 196 MessageLoop message_loop_; |
| 197 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; |
| 198 scoped_refptr<StrictMock<DecryptingVideoDecoder> > decoder_; |
| 199 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; |
| 200 MockStatisticsCB statistics_cb_; |
| 201 VideoDecoderConfig config_; |
| 202 |
| 203 VideoDecoder::ReadCB read_cb_; |
| 204 Decryptor::VideoDecodeCB video_decode_cb_; |
| 205 |
| 206 scoped_refptr<DecoderBuffer> encrypted_buffer_; |
| 207 scoped_refptr<DecoderBuffer> end_of_stream_buffer_; |
| 208 scoped_refptr<VideoFrame> decoded_video_frame_; |
| 209 |
| 210 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoderTest); |
| 212 }; |
| 213 |
| 214 TEST_F(DecryptingVideoDecoderTest, Initialize_Normal) { |
| 215 Initialize(); |
| 216 } |
| 217 |
| 218 // Ensure that DecryptingVideoDecoder only acceptes encrypted video. |
| 219 TEST_F(DecryptingVideoDecoderTest, Initialize_UnencryptedVideoConfig) { |
| 220 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, |
| 221 kVideoFormat, |
| 222 kCodedSize, kVisibleRect, kNaturalSize, |
| 223 NULL, 0, false); |
| 224 |
| 225 InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); |
| 226 } |
| 227 |
| 228 // Ensure decoder handles unsupported video configs without crashing. |
| 229 TEST_F(DecryptingVideoDecoderTest, Initialize_InvalidVideoConfig) { |
| 230 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, |
| 231 VideoFrame::INVALID, |
| 232 kCodedSize, kVisibleRect, kNaturalSize, |
| 233 NULL, 0, true); |
| 234 |
| 235 InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| 236 } |
| 237 |
| 238 // Ensure decoder handles unsupported video configs without crashing. |
| 239 TEST_F(DecryptingVideoDecoderTest, Initialize_UnsupportedVideoConfig) { |
| 240 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _)) |
| 241 .WillOnce(RunCallback1(false)); |
| 242 |
| 243 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, |
| 244 kVideoFormat, |
| 245 kCodedSize, kVisibleRect, kNaturalSize, |
| 246 NULL, 0, true); |
| 247 |
| 248 InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); |
| 249 } |
| 250 |
| 251 // Test normal decrypt and decode case. |
| 252 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_Normal) { |
| 253 Initialize(); |
| 254 |
| 255 // Simulate decoding a single frame. |
| 256 VideoDecoder::Status status; |
| 257 scoped_refptr<VideoFrame> video_frame; |
| 258 DecryptAndDecodeSingleFrame(encrypted_buffer_, &status, &video_frame); |
| 259 |
| 260 EXPECT_EQ(VideoDecoder::kOk, status); |
| 261 ASSERT_TRUE(video_frame); |
| 262 EXPECT_FALSE(video_frame->IsEndOfStream()); |
| 263 } |
| 264 |
| 265 // Test the case where the decryptor returns error when doing decrypt and |
| 266 // decode. |
| 267 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_DecodeError) { |
| 268 Initialize(); |
| 269 |
| 270 EXPECT_CALL(*demuxer_, Read(_)) |
| 271 .WillRepeatedly(ReturnBuffer(encrypted_buffer_)); |
| 272 |
| 273 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) |
| 274 .WillRepeatedly(RunCallback2(Decryptor::kError, |
| 275 scoped_refptr<VideoFrame>(NULL))); |
| 276 |
| 277 VideoDecoder::Status status; |
| 278 scoped_refptr<VideoFrame> video_frame; |
| 279 Read(&status, &video_frame); |
| 280 |
| 281 EXPECT_EQ(VideoDecoder::kDecodeError, status); |
| 282 EXPECT_FALSE(video_frame); |
| 283 } |
| 284 |
| 285 // Test the case where the decryptor does not have the decryption key to do |
| 286 // decrypt and decode. |
| 287 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_NoKey) { |
| 288 Initialize(); |
| 289 |
| 290 EXPECT_CALL(*demuxer_, Read(_)) |
| 291 .WillRepeatedly(ReturnBuffer(encrypted_buffer_)); |
| 292 |
| 293 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) |
| 294 .WillRepeatedly(RunCallback2(Decryptor::kNoKey, |
| 295 scoped_refptr<VideoFrame>(NULL))); |
| 296 |
| 297 VideoDecoder::Status status; |
| 298 scoped_refptr<VideoFrame> video_frame; |
| 299 Read(&status, &video_frame); |
| 300 |
| 301 EXPECT_EQ(VideoDecoder::kDecodeError, status); |
| 302 EXPECT_FALSE(video_frame); |
| 303 } |
| 304 |
| 305 // Test the case where the decryptor returns kNeedMoreData to ask for more |
| 306 // buffers before it can produce a frame. |
| 307 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_NeedMoreData) { |
| 308 Initialize(); |
| 309 |
| 310 EXPECT_CALL(*demuxer_, Read(_)) |
| 311 .Times(2) |
| 312 .WillRepeatedly(ReturnBuffer(encrypted_buffer_)); |
| 313 |
| 314 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) |
| 315 .WillOnce(RunCallback2(Decryptor::kNeedMoreData, |
| 316 scoped_refptr<VideoFrame>(NULL))) |
| 317 .WillRepeatedly(RunCallback2(Decryptor::kSuccess, decoded_video_frame_)); |
| 318 |
| 319 EXPECT_CALL(statistics_cb_, OnStatistics(_)) |
| 320 .Times(2); |
| 321 |
| 322 VideoDecoder::Status status; |
| 323 scoped_refptr<VideoFrame> video_frame; |
| 324 Read(&status, &video_frame); |
| 325 |
| 326 EXPECT_EQ(VideoDecoder::kOk, status); |
| 327 EXPECT_EQ(decoded_video_frame_, video_frame); |
| 328 } |
| 329 |
| 330 // Test the case where the decryptor receives end-of-stream buffer. |
| 331 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_EndOfStream) { |
| 332 Initialize(); |
| 333 EnterDecodingState(); |
| 334 EnterEndOfStreamState(); |
| 335 } |
| 336 |
| 337 // Test resetting when decoder has initialized but has not decoded any frame. |
| 338 TEST_F(DecryptingVideoDecoderTest, Reset_Initialized) { |
| 339 Initialize(); |
| 340 Reset(); |
| 341 } |
| 342 |
| 343 // Test resetting when decoder has decoded single frame. |
| 344 TEST_F(DecryptingVideoDecoderTest, Reset_Decoding) { |
| 345 Initialize(); |
| 346 EnterDecodingState(); |
| 347 Reset(); |
| 348 } |
| 349 |
| 350 // Test resetting when decoder has hit end of stream. |
| 351 TEST_F(DecryptingVideoDecoderTest, Reset_EndOfStream) { |
| 352 Initialize(); |
| 353 EnterDecodingState(); |
| 354 EnterEndOfStreamState(); |
| 355 Reset(); |
| 356 } |
| 357 |
| 358 // Test resetting when there is a pending read on the demuxer. |
| 359 TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingRead) { |
| 360 Initialize(); |
| 361 |
| 362 DemuxerStream::ReadCB read_cb; |
| 363 EXPECT_CALL(*demuxer_, Read(_)) |
| 364 .WillOnce(SaveArg<0>(&read_cb)); |
| 365 decoder_->Read(read_cb_); |
| 366 message_loop_.RunAllPending(); |
| 367 // Make sure the Read() on the decoder triggers a Read() on the demuxer. |
| 368 EXPECT_FALSE(read_cb.is_null()); |
| 369 |
| 370 Reset(); |
| 371 |
| 372 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); |
| 373 read_cb.Run(DemuxerStream::kOk, encrypted_buffer_); |
| 374 message_loop_.RunAllPending(); |
| 375 } |
| 376 |
| 377 // Test resetting when there is a pending decrypt on the decryptor. |
| 378 TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDecryptAndDecode) { |
| 379 Initialize(); |
| 380 |
| 381 EXPECT_CALL(*demuxer_, Read(_)) |
| 382 .WillRepeatedly(ReturnBuffer(encrypted_buffer_)); |
| 383 |
| 384 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(encrypted_buffer_, _)) |
| 385 .WillOnce(SaveArg<1>(&video_decode_cb_)); |
| 386 |
| 387 decoder_->Read(read_cb_); |
| 388 message_loop_.RunAllPending(); |
| 389 // Make sure the Read() on the decoder triggers a DecryptAndDecode() on the |
| 390 // decryptor. |
| 391 EXPECT_FALSE(video_decode_cb_.is_null()); |
| 392 |
| 393 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); |
| 394 Reset(); |
| 395 } |
| 396 |
| 397 // Test stopping when decoder has initialized but has not decoded any frame. |
| 398 TEST_F(DecryptingVideoDecoderTest, Stop_Initialized) { |
| 399 Initialize(); |
| 400 Stop(); |
| 401 } |
| 402 |
| 403 // Test stopping when decoder has decoded single frame. |
| 404 TEST_F(DecryptingVideoDecoderTest, Stop_Decoding) { |
| 405 Initialize(); |
| 406 EnterDecodingState(); |
| 407 Stop(); |
| 408 } |
| 409 |
| 410 // Test stopping when decoder has hit end of stream. |
| 411 TEST_F(DecryptingVideoDecoderTest, Stop_EndOfStream) { |
| 412 Initialize(); |
| 413 EnterDecodingState(); |
| 414 EnterEndOfStreamState(); |
| 415 Stop(); |
| 416 } |
| 417 |
| 418 // Test stopping when there is a pending read on the demuxer. |
| 419 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingRead) { |
| 420 Initialize(); |
| 421 |
| 422 DemuxerStream::ReadCB read_cb; |
| 423 EXPECT_CALL(*demuxer_, Read(_)) |
| 424 .WillOnce(SaveArg<0>(&read_cb)); |
| 425 |
| 426 decoder_->Read(read_cb_); |
| 427 message_loop_.RunAllPending(); |
| 428 |
| 429 // Make sure the Read() on the decoder triggers a Read() on the demuxer. |
| 430 EXPECT_FALSE(read_cb.is_null()); |
| 431 |
| 432 Stop(); |
| 433 |
| 434 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); |
| 435 |
| 436 read_cb.Run(DemuxerStream::kOk, encrypted_buffer_); |
| 437 message_loop_.RunAllPending(); |
| 438 } |
| 439 |
| 440 // Test stopping when there is a pending decrypt on the decryptor. |
| 441 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecryptAndDecode) { |
| 442 Initialize(); |
| 443 |
| 444 EXPECT_CALL(*demuxer_, Read(_)) |
| 445 .WillRepeatedly(ReturnBuffer(encrypted_buffer_)); |
| 446 |
| 447 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(encrypted_buffer_, _)) |
| 448 .WillOnce(SaveArg<1>(&video_decode_cb_)); |
| 449 |
| 450 decoder_->Read(read_cb_); |
| 451 message_loop_.RunAllPending(); |
| 452 // Make sure the Read() on the decoder triggers a DecryptAndDecode() on the |
| 453 // decryptor. |
| 454 EXPECT_FALSE(video_decode_cb_.is_null()); |
| 455 |
| 456 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); |
| 457 Stop(); |
| 458 } |
| 459 |
| 460 // Test aborted read on the demuxer stream. |
| 461 TEST_F(DecryptingVideoDecoderTest, AbortPendingRead) { |
| 462 Initialize(); |
| 463 |
| 464 EXPECT_CALL(*demuxer_, Read(_)) |
| 465 .WillOnce(ReturnBuffer(scoped_refptr<DecoderBuffer>())); |
| 466 |
| 467 VideoDecoder::Status status; |
| 468 scoped_refptr<VideoFrame> video_frame; |
| 469 |
| 470 Read(&status, &video_frame); |
| 471 |
| 472 EXPECT_EQ(VideoDecoder::kOk, status); |
| 473 EXPECT_FALSE(video_frame); |
| 474 } |
| 475 |
| 476 // Test aborted read on the demuxer stream when the decoder is being reset. |
| 477 TEST_F(DecryptingVideoDecoderTest, AbortPendingReadDuringReset) { |
| 478 Initialize(); |
| 479 |
| 480 // Issue Read on demuxer and save the ReadCB in |read_cb|. |
| 481 DemuxerStream::ReadCB read_cb; |
| 482 EXPECT_CALL(*demuxer_, Read(_)) |
| 483 .WillOnce(SaveArg<0>(&read_cb)); |
| 484 decoder_->Read(read_cb_); |
| 485 message_loop_.RunAllPending(); |
| 486 ASSERT_FALSE(read_cb.is_null()); |
| 487 |
| 488 Reset(); |
| 489 |
| 490 // Signal an aborted demuxer read. |
| 491 read_cb.Run(DemuxerStream::kAborted, NULL); |
| 492 |
| 493 // Make sure we get a NULL video frame returned. |
| 494 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); |
| 495 message_loop_.RunAllPending(); |
| 496 } |
| 497 |
| 498 // Test config change on the demuxer stream. |
| 499 TEST_F(DecryptingVideoDecoderTest, ConfigChanged) { |
| 500 Initialize(); |
| 501 |
| 502 EXPECT_CALL(*demuxer_, Read(_)) |
| 503 .WillOnce(ReturnConfigChanged()); |
| 504 |
| 505 VideoDecoder::Status status; |
| 506 scoped_refptr<VideoFrame> video_frame; |
| 507 |
| 508 Read(&status, &video_frame); |
| 509 // TODO(xhwang): Update this test when kConfigChanged is supported in |
| 510 // DecryptingVideoDecoder. |
| 511 EXPECT_EQ(VideoDecoder::kDecodeError, status); |
| 512 EXPECT_FALSE(video_frame); |
| 513 } |
| 514 |
| 515 } // namespace media |
OLD | NEW |