OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
14 #include "base/task.h" | 14 #include "base/task.h" |
15 #include "base/thread.h" | 15 #include "base/thread.h" |
16 #include "media/base/buffers.h" | 16 #include "media/base/buffers.h" |
17 #include "media/base/callback.h" | 17 #include "media/base/callback.h" |
18 #include "media/base/filters.h" | 18 #include "media/base/filters.h" |
19 #include "media/base/filter_host.h" | 19 #include "media/base/filter_host.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 // In this class, we over-specify method lookup via this-> to avoid unexpected | 23 // In this class, we over-specify method lookup via this-> to avoid unexpected |
24 // name resolution issues due to the two-phase lookup needed for dependent | 24 // name resolution issues due to the two-phase lookup needed for dependent |
25 // name resolution in templates. | 25 // name resolution in templates. |
26 template <class Decoder, class Output> | 26 template <class Decoder, class Output> |
27 class DecoderBase : public Decoder { | 27 class DecoderBase : public Decoder { |
28 public: | 28 public: |
29 | 29 |
30 // MediaFilter implementation. | 30 // Filter implementation. |
31 virtual void Stop(FilterCallback* callback) { | 31 virtual void Stop(FilterCallback* callback) { |
32 this->message_loop()->PostTask( | 32 this->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, |
38 FilterCallback* callback) { | 38 FilterCallback* callback) { |
39 this->message_loop()->PostTask( | 39 this->message_loop()->PostTask( |
40 FROM_HERE, | 40 FROM_HERE, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // the DecoderBase::Initialize() method before any reads are submitted to | 94 // the DecoderBase::Initialize() method before any reads are submitted to |
95 // the demuxer stream. Returns true if successful, otherwise false indicates | 95 // the demuxer stream. Returns true if successful, otherwise false indicates |
96 // a fatal error. The derived class should NOT call the filter host's | 96 // a fatal error. The derived class should NOT call the filter host's |
97 // InitializationComplete() method. If this method returns true, then the | 97 // InitializationComplete() method. If this method returns true, then the |
98 // base class will call the host to complete initialization. During this | 98 // base class will call the host to complete initialization. During this |
99 // call, the derived class must fill in the media_format_ member. | 99 // call, the derived class must fill in the media_format_ member. |
100 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success, | 100 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success, |
101 Task* done_cb) = 0; | 101 Task* done_cb) = 0; |
102 | 102 |
103 // Method that may be implemented by the derived class if desired. It will | 103 // Method that may be implemented by the derived class if desired. It will |
104 // be called from within the MediaFilter::Stop() method prior to stopping the | 104 // be called from within the Filter::Stop() method prior to stopping the |
105 // base class. | 105 // base class. |
106 virtual void DoStop(Task* done_cb) { | 106 virtual void DoStop(Task* done_cb) { |
107 AutoTaskRunner done_runner(done_cb); | 107 AutoTaskRunner done_runner(done_cb); |
108 } | 108 } |
109 | 109 |
110 // Derived class can implement this method and perform seeking logic prior | 110 // Derived class can implement this method and perform seeking logic prior |
111 // to the base class. | 111 // to the base class. |
112 virtual void DoSeek(base::TimeDelta time, Task* done_cb) = 0; | 112 virtual void DoSeek(base::TimeDelta time, Task* done_cb) = 0; |
113 | 113 |
114 // Method that must be implemented by the derived class. If the decode | 114 // Method that must be implemented by the derived class. If the decode |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 kStopped, | 301 kStopped, |
302 }; | 302 }; |
303 State state_; | 303 State state_; |
304 | 304 |
305 DISALLOW_COPY_AND_ASSIGN(DecoderBase); | 305 DISALLOW_COPY_AND_ASSIGN(DecoderBase); |
306 }; | 306 }; |
307 | 307 |
308 } // namespace media | 308 } // namespace media |
309 | 309 |
310 #endif // MEDIA_FILTERS_DECODER_BASE_H_ | 310 #endif // MEDIA_FILTERS_DECODER_BASE_H_ |
OLD | NEW |