OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // 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 16 matching lines...) Expand all Loading... |
27 template <class Decoder, class Output> | 27 template <class Decoder, class Output> |
28 class DecoderBase : public Decoder { | 28 class DecoderBase : public Decoder { |
29 public: | 29 public: |
30 // Filter implementation. | 30 // Filter implementation. |
31 virtual void Stop(FilterCallback* callback) { | 31 virtual void Stop(FilterCallback* callback) { |
32 message_loop_->PostTask( | 32 message_loop_->PostTask( |
33 FROM_HERE, | 33 FROM_HERE, |
34 NewRunnableMethod(this, &DecoderBase::StopTask, callback)); | 34 NewRunnableMethod(this, &DecoderBase::StopTask, callback)); |
35 } | 35 } |
36 | 36 |
37 virtual void Seek(base::TimeDelta time, | 37 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) { |
38 FilterCallback* callback) { | |
39 message_loop_->PostTask( | 38 message_loop_->PostTask( |
40 FROM_HERE, | 39 FROM_HERE, |
41 NewRunnableMethod(this, &DecoderBase::SeekTask, time, callback)); | 40 NewRunnableMethod(this, &DecoderBase::SeekTask, time, cb)); |
42 } | 41 } |
43 | 42 |
44 // Decoder implementation. | 43 // Decoder implementation. |
45 virtual void Initialize(DemuxerStream* demuxer_stream, | 44 virtual void Initialize(DemuxerStream* demuxer_stream, |
46 FilterCallback* callback, | 45 FilterCallback* callback, |
47 StatisticsCallback* stats_callback) { | 46 StatisticsCallback* stats_callback) { |
48 statistics_callback_.reset(stats_callback); | 47 statistics_callback_.reset(stats_callback); |
49 message_loop_->PostTask( | 48 message_loop_->PostTask( |
50 FROM_HERE, | 49 FROM_HERE, |
51 NewRunnableMethod(this, | 50 NewRunnableMethod(this, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // Throw away all buffers in all queues. | 162 // Throw away all buffers in all queues. |
164 result_queue_.clear(); | 163 result_queue_.clear(); |
165 state_ = kStopped; | 164 state_ = kStopped; |
166 | 165 |
167 if (callback) { | 166 if (callback) { |
168 callback->Run(); | 167 callback->Run(); |
169 delete callback; | 168 delete callback; |
170 } | 169 } |
171 } | 170 } |
172 | 171 |
173 void SeekTask(base::TimeDelta time, FilterCallback* callback) { | 172 void SeekTask(base::TimeDelta time, const FilterStatusCB& cb) { |
174 DCHECK_EQ(MessageLoop::current(), message_loop_); | 173 DCHECK_EQ(MessageLoop::current(), message_loop_); |
175 DCHECK_EQ(0u, pending_reads_) << "Pending reads should have completed"; | 174 DCHECK_EQ(0u, pending_reads_) << "Pending reads should have completed"; |
176 DCHECK_EQ(0u, pending_requests_) << "Pending requests should be empty"; | 175 DCHECK_EQ(0u, pending_requests_) << "Pending requests should be empty"; |
177 | 176 |
178 // Delegate to the subclass first. | 177 // Delegate to the subclass first. |
179 DoSeek(time, | 178 DoSeek(time, NewRunnableMethod(this, &DecoderBase::OnSeekComplete, cb)); |
180 NewRunnableMethod(this, &DecoderBase::OnSeekComplete, callback)); | |
181 } | 179 } |
182 | 180 |
183 void OnSeekComplete(FilterCallback* callback) { | 181 void OnSeekComplete(const FilterStatusCB& cb) { |
184 // Flush our decoded results. | 182 // Flush our decoded results. |
185 result_queue_.clear(); | 183 result_queue_.clear(); |
186 | 184 |
187 // Signal that we're done seeking. | 185 // Signal that we're done seeking. |
188 if (callback) { | 186 if (!cb.is_null()) |
189 callback->Run(); | 187 cb.Run(PIPELINE_OK); |
190 delete callback; | |
191 } | |
192 } | 188 } |
193 | 189 |
194 void InitializeTask(DemuxerStream* demuxer_stream, | 190 void InitializeTask(DemuxerStream* demuxer_stream, |
195 FilterCallback* callback) { | 191 FilterCallback* callback) { |
196 DCHECK_EQ(MessageLoop::current(), message_loop_); | 192 DCHECK_EQ(MessageLoop::current(), message_loop_); |
197 CHECK(kUninitialized == state_); | 193 CHECK(kUninitialized == state_); |
198 CHECK(!demuxer_stream_); | 194 CHECK(!demuxer_stream_); |
199 demuxer_stream_ = demuxer_stream; | 195 demuxer_stream_ = demuxer_stream; |
200 | 196 |
201 bool* success = new bool; | 197 bool* success = new bool; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 302 |
307 // Callback to update pipeline statistics. | 303 // Callback to update pipeline statistics. |
308 scoped_ptr<StatisticsCallback> statistics_callback_; | 304 scoped_ptr<StatisticsCallback> statistics_callback_; |
309 | 305 |
310 DISALLOW_COPY_AND_ASSIGN(DecoderBase); | 306 DISALLOW_COPY_AND_ASSIGN(DecoderBase); |
311 }; | 307 }; |
312 | 308 |
313 } // namespace media | 309 } // namespace media |
314 | 310 |
315 #endif // MEDIA_FILTERS_DECODER_BASE_H_ | 311 #endif // MEDIA_FILTERS_DECODER_BASE_H_ |
OLD | NEW |