| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 // A base class that provides the plumbing for a decoder filters. | 5 // A base class that provides the plumbing for a decoder filters. |
| 6 | 6 |
| 7 #ifndef MEDIA_FILTERS_DECODER_BASE_H_ | 7 #ifndef MEDIA_FILTERS_DECODER_BASE_H_ |
| 8 #define MEDIA_FILTERS_DECODER_BASE_H_ | 8 #define MEDIA_FILTERS_DECODER_BASE_H_ |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Audio or Video decoder. | 63 // Audio or Video decoder. |
| 64 virtual void Read(Assignable<Output>* output) { | 64 virtual void Read(Assignable<Output>* output) { |
| 65 AutoLock auto_lock(lock_); | 65 AutoLock auto_lock(lock_); |
| 66 if (IsRunning()) { | 66 if (IsRunning()) { |
| 67 output->AddRef(); | 67 output->AddRef(); |
| 68 output_queue_.push_back(output); | 68 output_queue_.push_back(output); |
| 69 ScheduleProcessTask(); | 69 ScheduleProcessTask(); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 // AssignableBuffer callback. | 73 void OnReadComplete(Buffer* buffer) { |
| 74 virtual void OnAssignment(Buffer* buffer) { | |
| 75 AutoLock auto_lock(lock_); | 74 AutoLock auto_lock(lock_); |
| 76 if (IsRunning()) { | 75 if (IsRunning()) { |
| 77 buffer->AddRef(); | 76 buffer->AddRef(); |
| 78 input_queue_.push_back(buffer); | 77 input_queue_.push_back(buffer); |
| 79 --pending_reads_; | 78 --pending_reads_; |
| 80 ScheduleProcessTask(); | 79 ScheduleProcessTask(); |
| 81 } | 80 } |
| 82 } | 81 } |
| 83 | 82 |
| 84 protected: | 83 protected: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 bool did_read = false; | 175 bool did_read = false; |
| 177 if (IsRunning() && | 176 if (IsRunning() && |
| 178 pending_reads_ + input_queue_.size() < output_queue_.size()) { | 177 pending_reads_ + input_queue_.size() < output_queue_.size()) { |
| 179 did_read = true; | 178 did_read = true; |
| 180 size_t read = output_queue_.size() - pending_reads_ - input_queue_.size(); | 179 size_t read = output_queue_.size() - pending_reads_ - input_queue_.size(); |
| 181 pending_reads_ += read; | 180 pending_reads_ += read; |
| 182 { | 181 { |
| 183 AutoUnlock unlock(lock_); | 182 AutoUnlock unlock(lock_); |
| 184 while (read) { | 183 while (read) { |
| 185 demuxer_stream_-> | 184 demuxer_stream_-> |
| 186 Read(new AssignableBuffer<DecoderBase, Buffer>(this)); | 185 Read(NewCallback(this, &DecoderBase::OnReadComplete)); |
| 187 --read; | 186 --read; |
| 188 } | 187 } |
| 189 } | 188 } |
| 190 } | 189 } |
| 191 return did_read; | 190 return did_read; |
| 192 } | 191 } |
| 193 | 192 |
| 194 // If the |input_queue_| has any buffers, this method will call the derived | 193 // If the |input_queue_| has any buffers, this method will call the derived |
| 195 // class's OnDecode() method. | 194 // class's OnDecode() method. |
| 196 bool ProcessInput() { | 195 bool ProcessInput() { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // Queue of buffers supplied by the renderer through the Read() method. | 286 // Queue of buffers supplied by the renderer through the Read() method. |
| 288 typedef std::deque<Assignable<Output>*> OutputQueue; | 287 typedef std::deque<Assignable<Output>*> OutputQueue; |
| 289 OutputQueue output_queue_; | 288 OutputQueue output_queue_; |
| 290 | 289 |
| 291 DISALLOW_COPY_AND_ASSIGN(DecoderBase); | 290 DISALLOW_COPY_AND_ASSIGN(DecoderBase); |
| 292 }; | 291 }; |
| 293 | 292 |
| 294 } // namespace media | 293 } // namespace media |
| 295 | 294 |
| 296 #endif // MEDIA_FILTERS_DECODER_BASE_H_ | 295 #endif // MEDIA_FILTERS_DECODER_BASE_H_ |
| OLD | NEW |