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

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

Issue 4653005: Move FilterType into MediaFilterCollection (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « no previous file | media/base/filters.cc » ('j') | media/base/media_filter_collection.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 26 matching lines...) Expand all
37 37
38 namespace media { 38 namespace media {
39 39
40 class Buffer; 40 class Buffer;
41 class Decoder; 41 class Decoder;
42 class DemuxerStream; 42 class DemuxerStream;
43 class FilterHost; 43 class FilterHost;
44 class MediaFilter; 44 class MediaFilter;
45 class WritableBuffer; 45 class WritableBuffer;
46 46
47 // Identifies the type of filter implementation. Each filter has to be one of
48 // the following types. This is used to identify filter object during
49 // initialization of pipeline.
50 enum FilterType {
51 FILTER_DATA_SOURCE,
52 FILTER_DEMUXER,
53 FILTER_AUDIO_DECODER,
54 FILTER_VIDEO_DECODER,
55 FILTER_AUDIO_RENDERER,
56 FILTER_VIDEO_RENDERER
57 };
58
59 // Used for completing asynchronous methods. 47 // Used for completing asynchronous methods.
60 typedef Callback0::Type FilterCallback; 48 typedef Callback0::Type FilterCallback;
61 49
62 class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> { 50 class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> {
63 public: 51 public:
64 MediaFilter(); 52 MediaFilter();
65 53
66 // Return the type of this filter. All implementor has to provide this
67 // method.
68 virtual FilterType filter_type() const = 0;
69
70 // Return the major mime type for this filter. 54 // Return the major mime type for this filter.
71 virtual const char* major_mime_type() const; 55 virtual const char* major_mime_type() const;
72 56
73 // Sets the private member |host_|. This is the first method called by 57 // Sets the private member |host_|. This is the first method called by
74 // the FilterHost after a filter is created. The host holds a strong 58 // the FilterHost after a filter is created. The host holds a strong
75 // reference to the filter. The reference held by the host is guaranteed 59 // reference to the filter. The reference held by the host is guaranteed
76 // to be released before the host object is destroyed by the pipeline. 60 // to be released before the host object is destroyed by the pipeline.
77 virtual void set_host(FilterHost* host); 61 virtual void set_host(FilterHost* host);
78 62
79 virtual FilterHost* host(); 63 virtual FilterHost* host();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 DISALLOW_COPY_AND_ASSIGN(MediaFilter); 124 DISALLOW_COPY_AND_ASSIGN(MediaFilter);
141 }; 125 };
142 126
143 class DataSource : public MediaFilter { 127 class DataSource : public MediaFilter {
144 public: 128 public:
145 typedef Callback1<size_t>::Type ReadCallback; 129 typedef Callback1<size_t>::Type ReadCallback;
146 static const size_t kReadError = static_cast<size_t>(-1); 130 static const size_t kReadError = static_cast<size_t>(-1);
147 131
148 virtual bool IsUrlSupported(const std::string& url); 132 virtual bool IsUrlSupported(const std::string& url);
149 133
150 static FilterType static_filter_type() { return FILTER_DATA_SOURCE; }
151 virtual FilterType filter_type() const;
152
153 // Initialize a DataSource for the given URL, executing the callback upon 134 // Initialize a DataSource for the given URL, executing the callback upon
154 // completion. 135 // completion.
155 virtual void Initialize(const std::string& url, FilterCallback* callback) = 0; 136 virtual void Initialize(const std::string& url, FilterCallback* callback) = 0;
156 137
157 // Reads |size| bytes from |position| into |data|. And when the read is done 138 // Reads |size| bytes from |position| into |data|. And when the read is done
158 // or failed, |read_callback| is called with the number of bytes read or 139 // or failed, |read_callback| is called with the number of bytes read or
159 // kReadError in case of error. 140 // kReadError in case of error.
160 // TODO(hclam): should change |size| to int! It makes the code so messy 141 // TODO(hclam): should change |size| to int! It makes the code so messy
161 // with size_t and int all over the place.. 142 // with size_t and int all over the place..
162 virtual void Read(int64 position, size_t size, 143 virtual void Read(int64 position, size_t size,
163 uint8* data, ReadCallback* read_callback) = 0; 144 uint8* data, ReadCallback* read_callback) = 0;
164 145
165 // Returns true and the file size, false if the file size could not be 146 // Returns true and the file size, false if the file size could not be
166 // retrieved. 147 // retrieved.
167 virtual bool GetSize(int64* size_out) = 0; 148 virtual bool GetSize(int64* size_out) = 0;
168 149
169 // Returns true if we are performing streaming. In this case seeking is 150 // Returns true if we are performing streaming. In this case seeking is
170 // not possible. 151 // not possible.
171 virtual bool IsStreaming() = 0; 152 virtual bool IsStreaming() = 0;
172 }; 153 };
173 154
174 155
175 class Demuxer : public MediaFilter { 156 class Demuxer : public MediaFilter {
176 public: 157 public:
177 static FilterType static_filter_type() { return FILTER_DEMUXER; }
178 virtual FilterType filter_type() const;
179
180 virtual bool requires_message_loop() const; 158 virtual bool requires_message_loop() const;
181 virtual const char* message_loop_name() const; 159 virtual const char* message_loop_name() const;
182 160
183 // Initialize a Demuxer with the given DataSource, executing the callback upon 161 // Initialize a Demuxer with the given DataSource, executing the callback upon
184 // completion. 162 // completion.
185 virtual void Initialize(DataSource* data_source, 163 virtual void Initialize(DataSource* data_source,
186 FilterCallback* callback) = 0; 164 FilterCallback* callback) = 0;
187 165
188 // Returns the number of streams available 166 // Returns the number of streams available
189 virtual size_t GetNumberOfStreams() = 0; 167 virtual size_t GetNumberOfStreams() = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // public template function will assign the interface to a scoped_refptr<>. 204 // public template function will assign the interface to a scoped_refptr<>.
227 virtual void* QueryInterface(const char* interface_id) { return NULL; } 205 virtual void* QueryInterface(const char* interface_id) { return NULL; }
228 206
229 friend class base::RefCountedThreadSafe<DemuxerStream>; 207 friend class base::RefCountedThreadSafe<DemuxerStream>;
230 virtual ~DemuxerStream(); 208 virtual ~DemuxerStream();
231 }; 209 };
232 210
233 211
234 class VideoDecoder : public MediaFilter { 212 class VideoDecoder : public MediaFilter {
235 public: 213 public:
236 static FilterType static_filter_type() { return FILTER_VIDEO_DECODER; }
237 virtual FilterType filter_type() const;
238
239 virtual const char* major_mime_type() const; 214 virtual const char* major_mime_type() const;
240 virtual bool requires_message_loop() const; 215 virtual bool requires_message_loop() const;
241 virtual const char* message_loop_name() const; 216 virtual const char* message_loop_name() const;
242 217
243 218
244 // Initialize a VideoDecoder with the given DemuxerStream, executing the 219 // Initialize a VideoDecoder with the given DemuxerStream, executing the
245 // callback upon completion. 220 // callback upon completion.
246 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0; 221 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0;
247 222
248 // |set_fill_buffer_done_callback| install permanent callback from downstream 223 // |set_fill_buffer_done_callback| install permanent callback from downstream
(...skipping 25 matching lines...) Expand all
274 VideoDecoder(); 249 VideoDecoder();
275 virtual ~VideoDecoder(); 250 virtual ~VideoDecoder();
276 251
277 private: 252 private:
278 scoped_ptr<ConsumeVideoFrameCallback> consume_video_frame_callback_; 253 scoped_ptr<ConsumeVideoFrameCallback> consume_video_frame_callback_;
279 }; 254 };
280 255
281 256
282 class AudioDecoder : public MediaFilter { 257 class AudioDecoder : public MediaFilter {
283 public: 258 public:
284 static FilterType static_filter_type() { return FILTER_AUDIO_DECODER; }
285 virtual FilterType filter_type() const;
286
287 virtual const char* major_mime_type() const; 259 virtual const char* major_mime_type() const;
288 virtual bool requires_message_loop() const; 260 virtual bool requires_message_loop() const;
289 virtual const char* message_loop_name() const; 261 virtual const char* message_loop_name() const;
290 262
291 // Initialize a AudioDecoder with the given DemuxerStream, executing the 263 // Initialize a AudioDecoder with the given DemuxerStream, executing the
292 // callback upon completion. 264 // callback upon completion.
293 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0; 265 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0;
294 266
295 // |set_fill_buffer_done_callback| install permanent callback from downstream 267 // |set_fill_buffer_done_callback| install permanent callback from downstream
296 // filter (i.e. Renderer). The callback is used to deliver buffers at 268 // filter (i.e. Renderer). The callback is used to deliver buffers at
(...skipping 19 matching lines...) Expand all
316 AudioDecoder(); 288 AudioDecoder();
317 ~AudioDecoder(); 289 ~AudioDecoder();
318 290
319 private: 291 private:
320 scoped_ptr<ConsumeAudioSamplesCallback> consume_audio_samples_callback_; 292 scoped_ptr<ConsumeAudioSamplesCallback> consume_audio_samples_callback_;
321 }; 293 };
322 294
323 295
324 class VideoRenderer : public MediaFilter { 296 class VideoRenderer : public MediaFilter {
325 public: 297 public:
326 static FilterType static_filter_type() { return FILTER_VIDEO_RENDERER; }
327 virtual FilterType filter_type() const;
328
329 virtual const char* major_mime_type() const; 298 virtual const char* major_mime_type() const;
330 299
331 // Initialize a VideoRenderer with the given VideoDecoder, executing the 300 // Initialize a VideoRenderer with the given VideoDecoder, executing the
332 // callback upon completion. 301 // callback upon completion.
333 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback) = 0; 302 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback) = 0;
334 303
335 // Returns true if this filter has received and processed an end-of-stream 304 // Returns true if this filter has received and processed an end-of-stream
336 // buffer. 305 // buffer.
337 virtual bool HasEnded() = 0; 306 virtual bool HasEnded() = 0;
338 }; 307 };
339 308
340 309
341 class AudioRenderer : public MediaFilter { 310 class AudioRenderer : public MediaFilter {
342 public: 311 public:
343 static FilterType static_filter_type() { return FILTER_AUDIO_RENDERER; }
344 virtual FilterType filter_type() const;
345
346 virtual const char* major_mime_type() const; 312 virtual const char* major_mime_type() const;
347 313
348 // Initialize a AudioRenderer with the given AudioDecoder, executing the 314 // Initialize a AudioRenderer with the given AudioDecoder, executing the
349 // callback upon completion. 315 // callback upon completion.
350 virtual void Initialize(AudioDecoder* decoder, FilterCallback* callback) = 0; 316 virtual void Initialize(AudioDecoder* decoder, FilterCallback* callback) = 0;
351 317
352 // Returns true if this filter has received and processed an end-of-stream 318 // Returns true if this filter has received and processed an end-of-stream
353 // buffer. 319 // buffer.
354 virtual bool HasEnded() = 0; 320 virtual bool HasEnded() = 0;
355 321
356 // Sets the output volume. 322 // Sets the output volume.
357 virtual void SetVolume(float volume) = 0; 323 virtual void SetVolume(float volume) = 0;
358 }; 324 };
359 325
360 } // namespace media 326 } // namespace media
361 327
362 #endif // MEDIA_BASE_FILTERS_H_ 328 #endif // MEDIA_BASE_FILTERS_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/filters.cc » ('j') | media/base/media_filter_collection.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698