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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 DCHECK(message_loop_->BelongsToCurrentThread()); | 52 DCHECK(message_loop_->BelongsToCurrentThread()); |
53 DCHECK(decode_cb_.IsNull()) << "Overlapping decodes are not supported."; | 53 DCHECK(decode_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->end_of_stream() ? 0 : buffer->data_size(); | 57 int buffer_size = buffer->end_of_stream() ? 0 : buffer->data_size(); |
58 decode_cb_.SetCallback(BindToCurrentLoop(base::Bind( | 58 decode_cb_.SetCallback(BindToCurrentLoop(base::Bind( |
59 &FakeVideoDecoder::OnFrameDecoded, weak_this_, buffer_size, decode_cb))); | 59 &FakeVideoDecoder::OnFrameDecoded, weak_this_, buffer_size, decode_cb))); |
60 | 60 |
61 if (buffer->end_of_stream() && decoded_frames_.empty()) { | 61 if (buffer->end_of_stream() && decoded_frames_.empty()) { |
62 decode_cb_.RunOrHold(kOk, VideoFrame::CreateEmptyFrame()); | 62 decode_cb_.RunOrHold(kOk, VideoFrame::CreateEOSFrame()); |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 if (!buffer->end_of_stream()) { | 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->timestamp()); | 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_)) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 int buffer_size, | 185 int buffer_size, |
186 const DecodeCB& decode_cb, | 186 const DecodeCB& decode_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 decode_cb.Run(status, video_frame); | 191 decode_cb.Run(status, video_frame); |
192 } | 192 } |
193 | 193 |
194 } // namespace media | 194 } // namespace media |
OLD | NEW |