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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback_helpers.h" | 6 #include "base/callback_helpers.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "media/base/gmock_callback_support.h" | 8 #include "media/base/gmock_callback_support.h" |
9 #include "media/base/mock_filters.h" | 9 #include "media/base/mock_filters.h" |
10 #include "media/base/test_helpers.h" | 10 #include "media/base/test_helpers.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 if (is_initialized_) | 72 if (is_initialized_) |
73 Stop(); | 73 Stop(); |
74 EXPECT_FALSE(is_initialized_); | 74 EXPECT_FALSE(is_initialized_); |
75 } | 75 } |
76 | 76 |
77 MOCK_METHOD1(SetDecryptorReadyCallback, void(const media::DecryptorReadyCB&)); | 77 MOCK_METHOD1(SetDecryptorReadyCallback, void(const media::DecryptorReadyCB&)); |
78 MOCK_METHOD2(OnInitialized, void(bool, bool)); | 78 MOCK_METHOD2(OnInitialized, void(bool, bool)); |
79 | 79 |
80 void OnStatistics(const PipelineStatistics& statistics) { | 80 void OnStatistics(const PipelineStatistics& statistics) { |
81 total_bytes_decoded_ += statistics.video_bytes_decoded; | 81 total_bytes_decoded_ += statistics.video_bytes_decoded; |
82 } | 82 } |
83 | 83 |
84 // Fake Decrypt() function used by DecryptingDemuxerStream. It does nothing | 84 // Fake Decrypt() function used by DecryptingDemuxerStream. It does nothing |
85 // but removes the DecryptConfig to make the buffer unencrypted. | 85 // but removes the DecryptConfig to make the buffer unencrypted. |
86 void Decrypt(Decryptor::StreamType stream_type, | 86 void Decrypt(Decryptor::StreamType stream_type, |
87 const scoped_refptr<DecoderBuffer>& encrypted, | 87 const scoped_refptr<DecoderBuffer>& encrypted, |
88 const Decryptor::DecryptCB& decrypt_cb) { | 88 const Decryptor::DecryptCB& decrypt_cb) { |
89 DCHECK_EQ(stream_type, Decryptor::kVideo); | 89 DCHECK_EQ(stream_type, Decryptor::kVideo); |
90 scoped_refptr<DecoderBuffer> decrypted = DecoderBuffer::CopyFrom( | 90 scoped_refptr<DecoderBuffer> decrypted = DecoderBuffer::CopyFrom( |
91 encrypted->data(), encrypted->data_size()); | 91 encrypted->data(), encrypted->data_size()); |
92 decrypted->set_timestamp(encrypted->timestamp()); | 92 decrypted->set_timestamp(encrypted->timestamp()); |
93 decrypted->set_duration(encrypted->duration()); | 93 decrypted->set_duration(encrypted->duration()); |
94 decrypt_cb.Run(Decryptor::kSuccess, decrypted); | 94 decrypt_cb.Run(Decryptor::kSuccess, decrypted); |
95 } | 95 } |
96 | 96 |
97 // Callback for VideoFrameStream::Read(). | 97 // Callback for VideoFrameStream::Read(). |
98 void FrameReady(VideoDecoder::Status status, | 98 void FrameReady(VideoFrameStream::Status status, |
99 const scoped_refptr<VideoFrame>& frame) { | 99 const scoped_refptr<VideoFrame>& frame) { |
100 DCHECK(pending_read_); | 100 DCHECK(pending_read_); |
101 ASSERT_EQ(VideoDecoder::kOk, status); | 101 // TODO(xhwang): Add test cases where the fake decoder returns error or |
| 102 // the fake demuxer aborts demuxer read. |
| 103 ASSERT_TRUE(status == VideoFrameStream::OK || |
| 104 status == VideoFrameStream::ABORTED); |
102 frame_read_ = frame; | 105 frame_read_ = frame; |
103 if (frame.get() && !frame->IsEndOfStream()) | 106 if (frame.get() && !frame->IsEndOfStream()) |
104 num_decoded_frames_++; | 107 num_decoded_frames_++; |
105 pending_read_ = false; | 108 pending_read_ = false; |
106 } | 109 } |
107 | 110 |
108 void OnReset() { | 111 void OnReset() { |
109 DCHECK(!pending_read_); | 112 DCHECK(!pending_read_); |
110 DCHECK(pending_reset_); | 113 DCHECK(pending_reset_); |
111 pending_reset_ = false; | 114 pending_reset_ = false; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 488 } |
486 | 489 |
487 TEST_P(VideoFrameStreamTest, Stop_AfterRead_AfterReset) { | 490 TEST_P(VideoFrameStreamTest, Stop_AfterRead_AfterReset) { |
488 Initialize(); | 491 Initialize(); |
489 Read(); | 492 Read(); |
490 Reset(); | 493 Reset(); |
491 Stop(); | 494 Stop(); |
492 } | 495 } |
493 | 496 |
494 } // namespace media | 497 } // namespace media |
OLD | NEW |