| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 | 169 |
| 170 class DemuxerStream : public base::RefCountedThreadSafe<DemuxerStream> { | 170 class DemuxerStream : public base::RefCountedThreadSafe<DemuxerStream> { |
| 171 public: | 171 public: |
| 172 // Returns the MediaFormat for this filter. | 172 // Returns the MediaFormat for this filter. |
| 173 virtual const MediaFormat& media_format() = 0; | 173 virtual const MediaFormat& media_format() = 0; |
| 174 | 174 |
| 175 // Schedules a read. When the |read_callback| is called, the downstream | 175 // Schedules a read. When the |read_callback| is called, the downstream |
| 176 // filter takes ownership of the buffer by AddRef()'ing the buffer. | 176 // filter takes ownership of the buffer by AddRef()'ing the buffer. |
| 177 // |
| 178 // TODO(scherkus): switch Read() callback to scoped_refptr<>. |
| 177 virtual void Read(Callback1<Buffer*>::Type* read_callback) = 0; | 179 virtual void Read(Callback1<Buffer*>::Type* read_callback) = 0; |
| 178 | 180 |
| 179 // Given a class that supports the |Interface| and a related static method | 181 // Given a class that supports the |Interface| and a related static method |
| 180 // interface_id(), which returns a const char*, this method returns true if | 182 // interface_id(), which returns a const char*, this method returns true if |
| 181 // the class returns an interface pointer and assigns the pointer to | 183 // the class returns an interface pointer and assigns the pointer to |
| 182 // |interface_out|. Otherwise this method returns false. | 184 // |interface_out|. Otherwise this method returns false. |
| 183 template <class Interface> | 185 template <class Interface> |
| 184 bool QueryInterface(Interface** interface_out) { | 186 bool QueryInterface(Interface** interface_out) { |
| 185 void* i = QueryInterface(Interface::interface_id()); | 187 void* i = QueryInterface(Interface::interface_id()); |
| 186 *interface_out = reinterpret_cast<Interface*>(i); | 188 *interface_out = reinterpret_cast<Interface*>(i); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 211 return mime_type::kMajorTypeVideo; | 213 return mime_type::kMajorTypeVideo; |
| 212 } | 214 } |
| 213 | 215 |
| 214 // Initializes this filter, returns true if successful, false otherwise. | 216 // Initializes this filter, returns true if successful, false otherwise. |
| 215 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; | 217 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; |
| 216 | 218 |
| 217 // Returns the MediaFormat for this filter. | 219 // Returns the MediaFormat for this filter. |
| 218 virtual const MediaFormat& media_format() = 0; | 220 virtual const MediaFormat& media_format() = 0; |
| 219 | 221 |
| 220 // Schedules a read. Decoder takes ownership of the callback. | 222 // Schedules a read. Decoder takes ownership of the callback. |
| 223 // |
| 224 // TODO(scherkus): switch Read() callback to scoped_refptr<>. |
| 221 virtual void Read(Callback1<VideoFrame*>::Type* read_callback) = 0; | 225 virtual void Read(Callback1<VideoFrame*>::Type* read_callback) = 0; |
| 222 }; | 226 }; |
| 223 | 227 |
| 224 | 228 |
| 225 class AudioDecoder : public MediaFilter { | 229 class AudioDecoder : public MediaFilter { |
| 226 public: | 230 public: |
| 227 static const FilterType filter_type() { | 231 static const FilterType filter_type() { |
| 228 return FILTER_AUDIO_DECODER; | 232 return FILTER_AUDIO_DECODER; |
| 229 } | 233 } |
| 230 | 234 |
| 231 static const char* major_mime_type() { | 235 static const char* major_mime_type() { |
| 232 return mime_type::kMajorTypeAudio; | 236 return mime_type::kMajorTypeAudio; |
| 233 } | 237 } |
| 234 | 238 |
| 235 // Initializes this filter, returns true if successful, false otherwise. | 239 // Initializes this filter, returns true if successful, false otherwise. |
| 236 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; | 240 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; |
| 237 | 241 |
| 238 // Returns the MediaFormat for this filter. | 242 // Returns the MediaFormat for this filter. |
| 239 virtual const MediaFormat& media_format() = 0; | 243 virtual const MediaFormat& media_format() = 0; |
| 240 | 244 |
| 241 // Schedules a read. Decoder takes ownership of the callback. | 245 // Schedules a read. Decoder takes ownership of the callback. |
| 246 // |
| 247 // TODO(scherkus): switch Read() callback to scoped_refptr<>. |
| 242 virtual void Read(Callback1<Buffer*>::Type* read_callbasck) = 0; | 248 virtual void Read(Callback1<Buffer*>::Type* read_callbasck) = 0; |
| 243 }; | 249 }; |
| 244 | 250 |
| 245 | 251 |
| 246 class VideoRenderer : public MediaFilter { | 252 class VideoRenderer : public MediaFilter { |
| 247 public: | 253 public: |
| 248 static const FilterType filter_type() { | 254 static const FilterType filter_type() { |
| 249 return FILTER_VIDEO_RENDERER; | 255 return FILTER_VIDEO_RENDERER; |
| 250 } | 256 } |
| 251 | 257 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 271 // Initializes this filter, returns true if successful, false otherwise. | 277 // Initializes this filter, returns true if successful, false otherwise. |
| 272 virtual bool Initialize(AudioDecoder* decoder) = 0; | 278 virtual bool Initialize(AudioDecoder* decoder) = 0; |
| 273 | 279 |
| 274 // Sets the output volume. | 280 // Sets the output volume. |
| 275 virtual void SetVolume(float volume) = 0; | 281 virtual void SetVolume(float volume) = 0; |
| 276 }; | 282 }; |
| 277 | 283 |
| 278 } // namespace media | 284 } // namespace media |
| 279 | 285 |
| 280 #endif // MEDIA_BASE_FILTERS_H_ | 286 #endif // MEDIA_BASE_FILTERS_H_ |
| OLD | NEW |