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

Side by Side Diff: media/base/filters.h

Issue 9325044: Remove AudioDecoder from the Filter heirarchy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved audio_decoder_ out of Pipeline; AudioRendererBase is in charge of it now. Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Filters are connected in a strongly typed manner, with downstream filters 5 // Filters are connected in a strongly typed manner, with downstream filters
6 // always reading data from upstream filters. Upstream filters have no clue 6 // always reading data from upstream filters. Upstream filters have no clue
7 // who is actually reading from them, and return the results via callbacks. 7 // who is actually reading from them, and return the results via callbacks.
8 // 8 //
9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer 9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer
10 // DataSource <- Demuxer < 10 // DataSource <- Demuxer <
(...skipping 20 matching lines...) Expand all
31 #include "base/memory/scoped_ptr.h" 31 #include "base/memory/scoped_ptr.h"
32 #include "base/time.h" 32 #include "base/time.h"
33 #include "media/base/channel_layout.h" 33 #include "media/base/channel_layout.h"
34 #include "media/base/media_export.h" 34 #include "media/base/media_export.h"
35 #include "media/base/pipeline_status.h" 35 #include "media/base/pipeline_status.h"
36 #include "media/base/video_frame.h" 36 #include "media/base/video_frame.h"
37 #include "ui/gfx/size.h" 37 #include "ui/gfx/size.h"
38 38
39 namespace media { 39 namespace media {
40 40
41 class AudioDecoder;
41 class Buffer; 42 class Buffer;
42 class Decoder; 43 class Decoder;
43 class DemuxerStream; 44 class DemuxerStream;
44 class Filter; 45 class Filter;
45 class FilterHost; 46 class FilterHost;
46 47
47 struct PipelineStatistics; 48 struct PipelineStatistics;
48 49
49 // Used for completing asynchronous methods. 50 // Used for completing asynchronous methods.
50 typedef base::Callback<void(PipelineStatus)> FilterStatusCB; 51 typedef base::Callback<void(PipelineStatus)> FilterStatusCB;
51 52
52 // These functions copy |*cb|, call Reset() on |*cb|, and then call Run() 53 // These functions copy |*cb|, call Reset() on |*cb|, and then call Run()
53 // on the copy. This is used in the common case where you need to clear 54 // on the copy. This is used in the common case where you need to clear
54 // a callback member variable before running the callback. 55 // a callback member variable before running the callback.
55 MEDIA_EXPORT void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status); 56 MEDIA_EXPORT void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status);
56 MEDIA_EXPORT void ResetAndRunCB(base::Closure* cb); 57 MEDIA_EXPORT void ResetAndRunCB(base::Closure* cb);
57 58
58 // Used for updating pipeline statistics.
59 typedef base::Callback<void(const PipelineStatistics&)> StatisticsCallback;
60
61 class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> { 59 class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> {
62 public: 60 public:
63 Filter(); 61 Filter();
64 62
65 // Sets the private member |host_|. This is the first method called by 63 // Sets the private member |host_|. This is the first method called by
66 // the FilterHost after a filter is created. The host holds a strong 64 // the FilterHost after a filter is created. The host holds a strong
67 // reference to the filter. The reference held by the host is guaranteed 65 // reference to the filter. The reference held by the host is guaranteed
68 // to be released before the host object is destroyed by the pipeline. 66 // to be released before the host object is destroyed by the pipeline.
69 virtual void set_host(FilterHost* host); 67 virtual void set_host(FilterHost* host);
70 68
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // the duration. Default implementation does nothing; derived decoders may 160 // the duration. Default implementation does nothing; derived decoders may
163 // override as needed. http://crbug.com/110228 tracks removing this. 161 // override as needed. http://crbug.com/110228 tracks removing this.
164 virtual void PrepareForShutdownHack(); 162 virtual void PrepareForShutdownHack();
165 163
166 protected: 164 protected:
167 VideoDecoder(); 165 VideoDecoder();
168 virtual ~VideoDecoder(); 166 virtual ~VideoDecoder();
169 }; 167 };
170 168
171 169
172 class MEDIA_EXPORT AudioDecoder : public Filter {
173 public:
174 // Initialize a AudioDecoder with the given DemuxerStream, executing the
175 // callback upon completion.
176 // stats_callback is used to update global pipeline statistics.
177 virtual void Initialize(DemuxerStream* stream,
178 const PipelineStatusCB& callback,
179 const StatisticsCallback& stats_callback) = 0;
180
181 // Request samples to be decoded and returned via the provided callback.
182 // Only one read may be in flight at any given time.
183 //
184 // Implementations guarantee that the callback will not be called from within
185 // this method.
186 //
187 // Non-NULL sample buffer pointers will contain decoded audio data or may
188 // indicate the end of the stream. A NULL buffer pointer indicates an aborted
189 // Read(). This can happen if the DemuxerStream gets flushed and doesn't have
190 // any more data to return.
191 typedef base::Callback<void(scoped_refptr<Buffer>)> ReadCB;
192 virtual void Read(const ReadCB& callback) = 0;
193
194 // Returns various information about the decoded audio format.
195 virtual int bits_per_channel() = 0;
196 virtual ChannelLayout channel_layout() = 0;
197 virtual int samples_per_second() = 0;
198
199 protected:
200 AudioDecoder();
201 virtual ~AudioDecoder();
202 };
203
204
205 class MEDIA_EXPORT VideoRenderer : public Filter { 170 class MEDIA_EXPORT VideoRenderer : public Filter {
206 public: 171 public:
207 // Used to update the pipeline's clock time. The parameter is the time that 172 // Used to update the pipeline's clock time. The parameter is the time that
208 // the clock should not exceed. 173 // the clock should not exceed.
209 typedef base::Callback<void(base::TimeDelta)> VideoTimeCB; 174 typedef base::Callback<void(base::TimeDelta)> VideoTimeCB;
210 175
211 // Initialize a VideoRenderer with the given VideoDecoder, executing the 176 // Initialize a VideoRenderer with the given VideoDecoder, executing the
212 // callback upon completion. 177 // callback upon completion.
213 virtual void Initialize(VideoDecoder* decoder, 178 virtual void Initialize(VideoDecoder* decoder,
214 const PipelineStatusCB& callback, 179 const PipelineStatusCB& callback,
(...skipping 12 matching lines...) Expand all
227 // current time, and the second parameter is the time that the clock must not 192 // current time, and the second parameter is the time that the clock must not
228 // exceed. 193 // exceed.
229 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> AudioTimeCB; 194 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> AudioTimeCB;
230 195
231 // Initialize a AudioRenderer with the given AudioDecoder, executing the 196 // Initialize a AudioRenderer with the given AudioDecoder, executing the
232 // |init_callback| upon completion. |underflow_callback| is called when the 197 // |init_callback| upon completion. |underflow_callback| is called when the
233 // renderer runs out of data to pass to the audio card during playback. 198 // renderer runs out of data to pass to the audio card during playback.
234 // If the |underflow_callback| is called ResumeAfterUnderflow() must be called 199 // If the |underflow_callback| is called ResumeAfterUnderflow() must be called
235 // to resume playback. Pause(), Seek(), or Stop() cancels the underflow 200 // to resume playback. Pause(), Seek(), or Stop() cancels the underflow
236 // condition. 201 // condition.
237 virtual void Initialize(AudioDecoder* decoder, 202 virtual void Initialize(const scoped_refptr<AudioDecoder> decoder,
scherkus (not reviewing) 2012/02/06 21:04:04 const-ref
Ami GONE FROM CHROMIUM 2012/02/06 21:38:48 Done.
238 const PipelineStatusCB& init_callback, 203 const PipelineStatusCB& init_callback,
239 const base::Closure& underflow_callback, 204 const base::Closure& underflow_callback,
240 const AudioTimeCB& time_cb) = 0; 205 const AudioTimeCB& time_cb) = 0;
241 206
242 // Returns true if this filter has received and processed an end-of-stream 207 // Returns true if this filter has received and processed an end-of-stream
243 // buffer. 208 // buffer.
244 virtual bool HasEnded() = 0; 209 virtual bool HasEnded() = 0;
245 210
246 // Sets the output volume. 211 // Sets the output volume.
247 virtual void SetVolume(float volume) = 0; 212 virtual void SetVolume(float volume) = 0;
248 213
249 // Resumes playback after underflow occurs. 214 // Resumes playback after underflow occurs.
250 // |buffer_more_audio| is set to true if you want to increase the size of the 215 // |buffer_more_audio| is set to true if you want to increase the size of the
251 // decoded audio buffer. 216 // decoded audio buffer.
252 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; 217 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0;
253 }; 218 };
254 219
255 } // namespace media 220 } // namespace media
256 221
257 #endif // MEDIA_BASE_FILTERS_H_ 222 #endif // MEDIA_BASE_FILTERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698