| 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 OnAssignment | 7 // who is actually reading from them, and return the results via OnAssignment |
| 8 // using the AssignableInterface<SomeBufferType> interface: | 8 // using the AssignableInterface<SomeBufferType> interface: |
| 9 // | 9 // |
| 10 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer | 10 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 mime_type == mime_type::kApplicationOctetStream); | 140 mime_type == mime_type::kApplicationOctetStream); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Initializes this filter, returns true if successful, false otherwise. | 143 // Initializes this filter, returns true if successful, false otherwise. |
| 144 virtual bool Initialize(DataSource* data_source) = 0; | 144 virtual bool Initialize(DataSource* data_source) = 0; |
| 145 | 145 |
| 146 // Returns the number of streams available | 146 // Returns the number of streams available |
| 147 virtual size_t GetNumberOfStreams() = 0; | 147 virtual size_t GetNumberOfStreams() = 0; |
| 148 | 148 |
| 149 // Returns the stream for the given index, NULL otherwise | 149 // Returns the stream for the given index, NULL otherwise |
| 150 virtual DemuxerStream* GetStream(int stream_id) = 0; | 150 virtual scoped_refptr<DemuxerStream> GetStream(int stream_id) = 0; |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 | 153 |
| 154 class DemuxerStream { | 154 class DemuxerStream : public base::RefCountedThreadSafe<DemuxerStream> { |
| 155 public: | 155 public: |
| 156 // Returns the MediaFormat for this filter. | 156 // Returns the MediaFormat for this filter. |
| 157 virtual const MediaFormat* GetMediaFormat() = 0; | 157 virtual const MediaFormat* GetMediaFormat() = 0; |
| 158 | 158 |
| 159 // Schedules a read and takes ownership of the given buffer. | 159 // Schedules a read and takes ownership of the given buffer. |
| 160 virtual void Read(Assignable<Buffer>* buffer) = 0; | 160 virtual void Read(Assignable<Buffer>* buffer) = 0; |
| 161 | 161 |
| 162 // Given a class that supports the |Interface| and a related static method |
| 163 // interface_id(), which returns a const char*, this method returns true if |
| 164 // the class returns an interface pointer and assigns the pointer to |
| 165 // |interface_out|. Otherwise this method returns false. |
| 166 template <class Interface> |
| 167 bool QueryInterface(scoped_refptr<Interface>* interface_out) { |
| 168 void* i = QueryInterface(Interface::interface_id()); |
| 169 *interface_out = reinterpret_cast<Interface*>(i); |
| 170 return (NULL != i); |
| 171 }; |
| 172 |
| 162 protected: | 173 protected: |
| 174 // Optional method that is implemented by filters that support extended |
| 175 // interfaces. The filter should return a pointer to the interface |
| 176 // associated with the |interface_id| string if they support it, otherwise |
| 177 // return NULL to indicate the interface is unknown. The derived filter |
| 178 // should NOT AddRef() the interface. The DemuxerStream::QueryInterface() |
| 179 // public template function will assign the interface to a scoped_refptr<>. |
| 180 virtual void* QueryInterface(const char* interface_id) { return NULL; } |
| 181 |
| 182 friend class base::RefCountedThreadSafe<DemuxerStream>; |
| 163 virtual ~DemuxerStream() {} | 183 virtual ~DemuxerStream() {} |
| 164 }; | 184 }; |
| 165 | 185 |
| 166 | 186 |
| 167 class VideoDecoder : public MediaFilter { | 187 class VideoDecoder : public MediaFilter { |
| 168 public: | 188 public: |
| 169 static const FilterType filter_type() { | 189 static const FilterType filter_type() { |
| 170 return FILTER_VIDEO_DECODER; | 190 return FILTER_VIDEO_DECODER; |
| 171 } | 191 } |
| 172 | 192 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // Initializes this filter, returns true if successful, false otherwise. | 254 // Initializes this filter, returns true if successful, false otherwise. |
| 235 virtual bool Initialize(AudioDecoder* decoder) = 0; | 255 virtual bool Initialize(AudioDecoder* decoder) = 0; |
| 236 | 256 |
| 237 // Sets the output volume. | 257 // Sets the output volume. |
| 238 virtual void SetVolume(float volume) = 0; | 258 virtual void SetVolume(float volume) = 0; |
| 239 }; | 259 }; |
| 240 | 260 |
| 241 } // namespace media | 261 } // namespace media |
| 242 | 262 |
| 243 #endif // MEDIA_BASE_FILTERS_H_ | 263 #endif // MEDIA_BASE_FILTERS_H_ |
| OLD | NEW |