| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/filters/fake_video_decoder.h" | 5 #include "media/filters/fake_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "media/base/bind_to_current_loop.h" | 9 #include "media/base/bind_to_current_loop.h" |
| 10 #include "media/base/test_helpers.h" | 10 #include "media/base/test_helpers.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 decoded_frames_.clear(); | 41 decoded_frames_.clear(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 std::string FakeVideoDecoder::GetDisplayName() const { | 44 std::string FakeVideoDecoder::GetDisplayName() const { |
| 45 return "FakeVideoDecoder"; | 45 return "FakeVideoDecoder"; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config, | 48 void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| 49 bool low_delay, | 49 bool low_delay, |
| 50 const PipelineStatusCB& status_cb, | 50 const InitCB& init_cb, |
| 51 const OutputCB& output_cb) { | 51 const OutputCB& output_cb) { |
| 52 DCHECK(thread_checker_.CalledOnValidThread()); | 52 DCHECK(thread_checker_.CalledOnValidThread()); |
| 53 DCHECK(config.IsValidConfig()); | 53 DCHECK(config.IsValidConfig()); |
| 54 DCHECK(held_decode_callbacks_.empty()) | 54 DCHECK(held_decode_callbacks_.empty()) |
| 55 << "No reinitialization during pending decode."; | 55 << "No reinitialization during pending decode."; |
| 56 DCHECK(reset_cb_.IsNull()) << "No reinitialization during pending reset."; | 56 DCHECK(reset_cb_.IsNull()) << "No reinitialization during pending reset."; |
| 57 | 57 |
| 58 current_config_ = config; | 58 current_config_ = config; |
| 59 init_cb_.SetCallback(BindToCurrentLoop(status_cb)); | 59 init_cb_.SetCallback(BindToCurrentLoop(init_cb)); |
| 60 | 60 |
| 61 // Don't need BindToCurrentLoop() because |output_cb_| is only called from | 61 // Don't need BindToCurrentLoop() because |output_cb_| is only called from |
| 62 // RunDecodeCallback() which is posted from Decode(). | 62 // RunDecodeCallback() which is posted from Decode(). |
| 63 output_cb_ = output_cb; | 63 output_cb_ = output_cb; |
| 64 | 64 |
| 65 if (!decoded_frames_.empty()) { | 65 if (!decoded_frames_.empty()) { |
| 66 DVLOG(1) << "Decoded frames dropped during reinitialization."; | 66 DVLOG(1) << "Decoded frames dropped during reinitialization."; |
| 67 decoded_frames_.clear(); | 67 decoded_frames_.clear(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 if (fail_to_initialize_) { | 70 if (fail_to_initialize_) { |
| 71 state_ = STATE_ERROR; | 71 state_ = STATE_ERROR; |
| 72 init_cb_.RunOrHold(DECODER_ERROR_NOT_SUPPORTED); | 72 init_cb_.RunOrHold(false); |
| 73 } else { | 73 } else { |
| 74 state_ = STATE_NORMAL; | 74 state_ = STATE_NORMAL; |
| 75 init_cb_.RunOrHold(PIPELINE_OK); | 75 init_cb_.RunOrHold(true); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 79 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 80 const DecodeCB& decode_cb) { | 80 const DecodeCB& decode_cb) { |
| 81 DCHECK(thread_checker_.CalledOnValidThread()); | 81 DCHECK(thread_checker_.CalledOnValidThread()); |
| 82 DCHECK(reset_cb_.IsNull()); | 82 DCHECK(reset_cb_.IsNull()); |
| 83 DCHECK_LE(decoded_frames_.size(), | 83 DCHECK_LE(decoded_frames_.size(), |
| 84 decoding_delay_ + held_decode_callbacks_.size()); | 84 decoding_delay_ + held_decode_callbacks_.size()); |
| 85 DCHECK_LT(static_cast<int>(held_decode_callbacks_.size()), | 85 DCHECK_LT(static_cast<int>(held_decode_callbacks_.size()), |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 void FakeVideoDecoder::DoReset() { | 253 void FakeVideoDecoder::DoReset() { |
| 254 DCHECK(thread_checker_.CalledOnValidThread()); | 254 DCHECK(thread_checker_.CalledOnValidThread()); |
| 255 DCHECK(held_decode_callbacks_.empty()); | 255 DCHECK(held_decode_callbacks_.empty()); |
| 256 DCHECK(!reset_cb_.IsNull()); | 256 DCHECK(!reset_cb_.IsNull()); |
| 257 | 257 |
| 258 reset_cb_.RunOrHold(); | 258 reset_cb_.RunOrHold(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace media | 261 } // namespace media |
| OLD | NEW |