Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: media/filters/fake_video_decoder.cc

Issue 490033002: Don't try to decode more than one EOS at a time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO for decoding_eos_ -> State. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, 69 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
70 const DecodeCB& decode_cb) { 70 const DecodeCB& decode_cb) {
71 DCHECK(thread_checker_.CalledOnValidThread()); 71 DCHECK(thread_checker_.CalledOnValidThread());
72 DCHECK(reset_cb_.IsNull()); 72 DCHECK(reset_cb_.IsNull());
73 DCHECK_LE(decoded_frames_.size(), 73 DCHECK_LE(decoded_frames_.size(),
74 decoding_delay_ + held_decode_callbacks_.size()); 74 decoding_delay_ + held_decode_callbacks_.size());
75 DCHECK_LT(static_cast<int>(held_decode_callbacks_.size()), 75 DCHECK_LT(static_cast<int>(held_decode_callbacks_.size()),
76 max_parallel_decoding_requests_); 76 max_parallel_decoding_requests_);
77 DCHECK_NE(state_, STATE_END_OF_STREAM);
77 78
78 int buffer_size = buffer->end_of_stream() ? 0 : buffer->data_size(); 79 int buffer_size = buffer->end_of_stream() ? 0 : buffer->data_size();
79 DecodeCB wrapped_decode_cb = base::Bind(&FakeVideoDecoder::OnFrameDecoded, 80 DecodeCB wrapped_decode_cb = base::Bind(&FakeVideoDecoder::OnFrameDecoded,
80 weak_factory_.GetWeakPtr(), 81 weak_factory_.GetWeakPtr(),
81 buffer_size, 82 buffer_size,
82 BindToCurrentLoop(decode_cb)); 83 BindToCurrentLoop(decode_cb));
83 84
84 if (state_ == STATE_ERROR) { 85 if (state_ == STATE_ERROR) {
85 wrapped_decode_cb.Run(kDecodeError); 86 wrapped_decode_cb.Run(kDecodeError);
86 return; 87 return;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 output_cb_.Run(decoded_frames_.front()); 217 output_cb_.Run(decoded_frames_.front());
217 decoded_frames_.pop_front(); 218 decoded_frames_.pop_front();
218 } else if (state_ == STATE_END_OF_STREAM) { 219 } else if (state_ == STATE_END_OF_STREAM) {
219 // Drain the queue if this was the last request in the stream, otherwise 220 // Drain the queue if this was the last request in the stream, otherwise
220 // just pop the last frame from the queue. 221 // just pop the last frame from the queue.
221 if (held_decode_callbacks_.empty()) { 222 if (held_decode_callbacks_.empty()) {
222 while (!decoded_frames_.empty()) { 223 while (!decoded_frames_.empty()) {
223 output_cb_.Run(decoded_frames_.front()); 224 output_cb_.Run(decoded_frames_.front());
224 decoded_frames_.pop_front(); 225 decoded_frames_.pop_front();
225 } 226 }
227 state_ = STATE_NORMAL;
226 } else if (!decoded_frames_.empty()) { 228 } else if (!decoded_frames_.empty()) {
227 output_cb_.Run(decoded_frames_.front()); 229 output_cb_.Run(decoded_frames_.front());
228 decoded_frames_.pop_front(); 230 decoded_frames_.pop_front();
229 } 231 }
230 } 232 }
231 233
232 decode_cb.Run(kOk); 234 decode_cb.Run(kOk);
233 } 235 }
234 236
235 void FakeVideoDecoder::DoReset() { 237 void FakeVideoDecoder::DoReset() {
236 DCHECK(thread_checker_.CalledOnValidThread()); 238 DCHECK(thread_checker_.CalledOnValidThread());
237 DCHECK(held_decode_callbacks_.empty()); 239 DCHECK(held_decode_callbacks_.empty());
238 DCHECK(!reset_cb_.IsNull()); 240 DCHECK(!reset_cb_.IsNull());
239 241
240 reset_cb_.RunOrHold(); 242 reset_cb_.RunOrHold();
241 } 243 }
242 244
243 } // namespace media 245 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698