| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 init_cb_.RunOrHold(PIPELINE_OK); | 47 init_cb_.RunOrHold(PIPELINE_OK); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 50 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 51 const ReadCB& read_cb) { | 51 const ReadCB& read_cb) { |
| 52 DCHECK(message_loop_->BelongsToCurrentThread()); | 52 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 53 DCHECK(read_cb_.IsNull()) << "Overlapping decodes are not supported."; | 53 DCHECK(read_cb_.IsNull()) << "Overlapping decodes are not supported."; |
| 54 DCHECK(reset_cb_.IsNull()); | 54 DCHECK(reset_cb_.IsNull()); |
| 55 DCHECK_LE(decoded_frames_.size(), static_cast<size_t>(decoding_delay_)); | 55 DCHECK_LE(decoded_frames_.size(), static_cast<size_t>(decoding_delay_)); |
| 56 | 56 |
| 57 int buffer_size = buffer->IsEndOfStream() ? 0 : buffer->GetDataSize(); | 57 int buffer_size = buffer->end_of_stream() ? 0 : buffer->data_size(); |
| 58 read_cb_.SetCallback(BindToCurrentLoop(base::Bind( | 58 read_cb_.SetCallback(BindToCurrentLoop(base::Bind( |
| 59 &FakeVideoDecoder::OnFrameDecoded, weak_this_, buffer_size, read_cb))); | 59 &FakeVideoDecoder::OnFrameDecoded, weak_this_, buffer_size, read_cb))); |
| 60 | 60 |
| 61 if (buffer->IsEndOfStream() && decoded_frames_.empty()) { | 61 if (buffer->end_of_stream() && decoded_frames_.empty()) { |
| 62 read_cb_.RunOrHold(kOk, VideoFrame::CreateEmptyFrame()); | 62 read_cb_.RunOrHold(kOk, VideoFrame::CreateEmptyFrame()); |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 | 65 |
| 66 if (!buffer->IsEndOfStream()) { | 66 if (!buffer->end_of_stream()) { |
| 67 DCHECK(VerifyFakeVideoBufferForTest(buffer, current_config_)); | 67 DCHECK(VerifyFakeVideoBufferForTest(buffer, current_config_)); |
| 68 scoped_refptr<VideoFrame> video_frame = VideoFrame::CreateColorFrame( | 68 scoped_refptr<VideoFrame> video_frame = VideoFrame::CreateColorFrame( |
| 69 current_config_.coded_size(), 0, 0, 0, buffer->GetTimestamp()); | 69 current_config_.coded_size(), 0, 0, 0, buffer->timestamp()); |
| 70 decoded_frames_.push_back(video_frame); | 70 decoded_frames_.push_back(video_frame); |
| 71 | 71 |
| 72 if (decoded_frames_.size() <= static_cast<size_t>(decoding_delay_)) { | 72 if (decoded_frames_.size() <= static_cast<size_t>(decoding_delay_)) { |
| 73 read_cb_.RunOrHold(kNotEnoughData, scoped_refptr<VideoFrame>()); | 73 read_cb_.RunOrHold(kNotEnoughData, scoped_refptr<VideoFrame>()); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 scoped_refptr<VideoFrame> frame = decoded_frames_.front(); | 78 scoped_refptr<VideoFrame> frame = decoded_frames_.front(); |
| 79 decoded_frames_.pop_front(); | 79 decoded_frames_.pop_front(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 int buffer_size, | 185 int buffer_size, |
| 186 const ReadCB& read_cb, | 186 const ReadCB& read_cb, |
| 187 Status status, | 187 Status status, |
| 188 const scoped_refptr<VideoFrame>& video_frame) { | 188 const scoped_refptr<VideoFrame>& video_frame) { |
| 189 if (status == kOk || status == kNotEnoughData) | 189 if (status == kOk || status == kNotEnoughData) |
| 190 total_bytes_decoded_ += buffer_size; | 190 total_bytes_decoded_ += buffer_size; |
| 191 read_cb.Run(status, video_frame); | 191 read_cb.Run(status, video_frame); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace media | 194 } // namespace media |
| OLD | NEW |