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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DISALLOW_COPY_AND_ASSIGN(MediaFilter); | 90 DISALLOW_COPY_AND_ASSIGN(MediaFilter); |
91 }; | 91 }; |
92 | 92 |
93 | 93 |
94 class DataSource : public MediaFilter { | 94 class DataSource : public MediaFilter { |
95 public: | 95 public: |
96 static const FilterType filter_type() { | 96 static const FilterType filter_type() { |
97 return FILTER_DATA_SOURCE; | 97 return FILTER_DATA_SOURCE; |
98 } | 98 } |
99 | 99 |
100 static bool IsMediaFormatSupported(const MediaFormat* media_format) { | 100 static bool IsMediaFormatSupported(const MediaFormat& media_format) { |
101 std::string mime_type; | 101 std::string mime_type; |
102 return (media_format->GetAsString(MediaFormat::kMimeType, &mime_type) && | 102 return (media_format.GetAsString(MediaFormat::kMimeType, &mime_type) && |
103 mime_type == mime_type::kURL); | 103 mime_type == mime_type::kURL); |
104 } | 104 } |
105 | 105 |
106 static const size_t kReadError = static_cast<size_t>(-1); | 106 static const size_t kReadError = static_cast<size_t>(-1); |
107 | 107 |
108 // Initializes this filter, returns true if successful, false otherwise. | 108 // Initializes this filter, returns true if successful, false otherwise. |
109 virtual bool Initialize(const std::string& url) = 0; | 109 virtual bool Initialize(const std::string& url) = 0; |
110 | 110 |
111 // Returns the MediaFormat for this filter. | 111 // Returns the MediaFormat for this filter. |
112 virtual const MediaFormat* GetMediaFormat() = 0; | 112 virtual const MediaFormat& media_format() = 0; |
113 | 113 |
114 // Read the given amount of bytes into data, returns the number of bytes read | 114 // Read the given amount of bytes into data, returns the number of bytes read |
115 // if successful, kReadError otherwise. | 115 // if successful, kReadError otherwise. |
116 virtual size_t Read(uint8* data, size_t size) = 0; | 116 virtual size_t Read(uint8* data, size_t size) = 0; |
117 | 117 |
118 // Returns true and the current file position for this file, false if the | 118 // Returns true and the current file position for this file, false if the |
119 // file position could not be retrieved. | 119 // file position could not be retrieved. |
120 virtual bool GetPosition(int64* position_out) = 0; | 120 virtual bool GetPosition(int64* position_out) = 0; |
121 | 121 |
122 // Returns true if the file position could be set, false otherwise. | 122 // Returns true if the file position could be set, false otherwise. |
123 virtual bool SetPosition(int64 position) = 0; | 123 virtual bool SetPosition(int64 position) = 0; |
124 | 124 |
125 // Returns true and the file size, false if the file size could not be | 125 // Returns true and the file size, false if the file size could not be |
126 // retrieved. | 126 // retrieved. |
127 virtual bool GetSize(int64* size_out) = 0; | 127 virtual bool GetSize(int64* size_out) = 0; |
128 }; | 128 }; |
129 | 129 |
130 | 130 |
131 class Demuxer : public MediaFilter { | 131 class Demuxer : public MediaFilter { |
132 public: | 132 public: |
133 static const FilterType filter_type() { | 133 static const FilterType filter_type() { |
134 return FILTER_DEMUXER; | 134 return FILTER_DEMUXER; |
135 } | 135 } |
136 | 136 |
137 static bool IsMediaFormatSupported(const MediaFormat* media_format) { | 137 static bool IsMediaFormatSupported(const MediaFormat& media_format) { |
138 std::string mime_type; | 138 std::string mime_type; |
139 return (media_format->GetAsString(MediaFormat::kMimeType, &mime_type) && | 139 return (media_format.GetAsString(MediaFormat::kMimeType, &mime_type) && |
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 scoped_refptr<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 : public base::RefCountedThreadSafe<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& media_format() = 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 | 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 | 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 | 164 // the class returns an interface pointer and assigns the pointer to |
165 // |interface_out|. Otherwise this method returns false. | 165 // |interface_out|. Otherwise this method returns false. |
166 template <class Interface> | 166 template <class Interface> |
167 bool QueryInterface(scoped_refptr<Interface>* interface_out) { | 167 bool QueryInterface(scoped_refptr<Interface>* interface_out) { |
(...skipping 23 matching lines...) Expand all Loading... |
191 } | 191 } |
192 | 192 |
193 static const char* major_mime_type() { | 193 static const char* major_mime_type() { |
194 return mime_type::kMajorTypeVideo; | 194 return mime_type::kMajorTypeVideo; |
195 } | 195 } |
196 | 196 |
197 // Initializes this filter, returns true if successful, false otherwise. | 197 // Initializes this filter, returns true if successful, false otherwise. |
198 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; | 198 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; |
199 | 199 |
200 // Returns the MediaFormat for this filter. | 200 // Returns the MediaFormat for this filter. |
201 virtual const MediaFormat* GetMediaFormat() = 0; | 201 virtual const MediaFormat& media_format() = 0; |
202 | 202 |
203 // Schedules a read and takes ownership of the given buffer. | 203 // Schedules a read and takes ownership of the given buffer. |
204 virtual void Read(Assignable<VideoFrame>* video_frame) = 0; | 204 virtual void Read(Assignable<VideoFrame>* video_frame) = 0; |
205 }; | 205 }; |
206 | 206 |
207 | 207 |
208 class AudioDecoder : public MediaFilter { | 208 class AudioDecoder : public MediaFilter { |
209 public: | 209 public: |
210 static const FilterType filter_type() { | 210 static const FilterType filter_type() { |
211 return FILTER_AUDIO_DECODER; | 211 return FILTER_AUDIO_DECODER; |
212 } | 212 } |
213 | 213 |
214 static const char* major_mime_type() { | 214 static const char* major_mime_type() { |
215 return mime_type::kMajorTypeAudio; | 215 return mime_type::kMajorTypeAudio; |
216 } | 216 } |
217 | 217 |
218 // Initializes this filter, returns true if successful, false otherwise. | 218 // Initializes this filter, returns true if successful, false otherwise. |
219 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; | 219 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; |
220 | 220 |
221 // Returns the MediaFormat for this filter. | 221 // Returns the MediaFormat for this filter. |
222 virtual const MediaFormat* GetMediaFormat() = 0; | 222 virtual const MediaFormat& media_format() = 0; |
223 | 223 |
224 // Schedules a read and takes ownership of the given buffer. | 224 // Schedules a read and takes ownership of the given buffer. |
225 virtual void Read(Assignable<Buffer>* buffer) = 0; | 225 virtual void Read(Assignable<Buffer>* buffer) = 0; |
226 }; | 226 }; |
227 | 227 |
228 | 228 |
229 class VideoRenderer : public MediaFilter { | 229 class VideoRenderer : public MediaFilter { |
230 public: | 230 public: |
231 static const FilterType filter_type() { | 231 static const FilterType filter_type() { |
232 return FILTER_VIDEO_RENDERER; | 232 return FILTER_VIDEO_RENDERER; |
(...skipping 21 matching lines...) Expand all Loading... |
254 // Initializes this filter, returns true if successful, false otherwise. | 254 // Initializes this filter, returns true if successful, false otherwise. |
255 virtual bool Initialize(AudioDecoder* decoder) = 0; | 255 virtual bool Initialize(AudioDecoder* decoder) = 0; |
256 | 256 |
257 // Sets the output volume. | 257 // Sets the output volume. |
258 virtual void SetVolume(float volume) = 0; | 258 virtual void SetVolume(float volume) = 0; |
259 }; | 259 }; |
260 | 260 |
261 } // namespace media | 261 } // namespace media |
262 | 262 |
263 #endif // MEDIA_BASE_FILTERS_H_ | 263 #endif // MEDIA_BASE_FILTERS_H_ |
OLD | NEW |