OLD | NEW |
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return mime_type::kMajorTypeVideo; | 258 return mime_type::kMajorTypeVideo; |
259 } | 259 } |
260 | 260 |
261 // Initialize a VideoDecoder with the given DemuxerStream, executing the | 261 // Initialize a VideoDecoder with the given DemuxerStream, executing the |
262 // callback upon completion. | 262 // callback upon completion. |
263 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0; | 263 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0; |
264 | 264 |
265 // Returns the MediaFormat for this filter. | 265 // Returns the MediaFormat for this filter. |
266 virtual const MediaFormat& media_format() = 0; | 266 virtual const MediaFormat& media_format() = 0; |
267 | 267 |
268 // Schedules a read. Decoder takes ownership of the callback. | 268 // |set_fill_buffer_done_callback| install permanent callback from downstream |
269 // | 269 // filter (i.e. Renderer). The callback is used to deliver video frames at |
270 // TODO(scherkus): switch Read() callback to scoped_refptr<>. | 270 // runtime to downstream filter |
271 virtual void Read(Callback1<VideoFrame*>::Type* read_callback) = 0; | 271 typedef Callback1<scoped_refptr<VideoFrame> >::Type FillBufferDoneCallback; |
| 272 void set_fill_buffer_done_callback(FillBufferDoneCallback* callback) { |
| 273 fill_buffer_done_callback_.reset(callback); |
| 274 } |
| 275 FillBufferDoneCallback* fill_buffer_done_callback() { |
| 276 return fill_buffer_done_callback_.get(); |
| 277 } |
| 278 |
| 279 // Render provides an output buffer for Decoder to write to. These buffers |
| 280 // will be recycled to renderer by fill_buffer_done_callback_; |
| 281 // We could also pass empty pointer here to let decoder provide buffers pool. |
| 282 virtual void FillThisBuffer(scoped_refptr<VideoFrame> frame) = 0; |
| 283 |
| 284 private: |
| 285 scoped_ptr<FillBufferDoneCallback> fill_buffer_done_callback_; |
272 }; | 286 }; |
273 | 287 |
274 | 288 |
275 class AudioDecoder : public MediaFilter { | 289 class AudioDecoder : public MediaFilter { |
276 public: | 290 public: |
277 static FilterType filter_type() { | 291 static FilterType filter_type() { |
278 return FILTER_AUDIO_DECODER; | 292 return FILTER_AUDIO_DECODER; |
279 } | 293 } |
280 | 294 |
281 static const char* major_mime_type() { | 295 static const char* major_mime_type() { |
282 return mime_type::kMajorTypeAudio; | 296 return mime_type::kMajorTypeAudio; |
283 } | 297 } |
284 | 298 |
285 // Initialize a AudioDecoder with the given DemuxerStream, executing the | 299 // Initialize a AudioDecoder with the given DemuxerStream, executing the |
286 // callback upon completion. | 300 // callback upon completion. |
287 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0; | 301 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0; |
288 | 302 |
289 // Returns the MediaFormat for this filter. | 303 // Returns the MediaFormat for this filter. |
290 virtual const MediaFormat& media_format() = 0; | 304 virtual const MediaFormat& media_format() = 0; |
291 | 305 |
292 // Schedules a read. Decoder takes ownership of the callback. | 306 // |set_fill_buffer_done_callback| install permanent callback from downstream |
293 // | 307 // filter (i.e. Renderer). The callback is used to deliver buffers at |
294 // TODO(scherkus): switch Read() callback to scoped_refptr<>. | 308 // runtime to downstream filter. |
295 virtual void Read(Callback1<Buffer*>::Type* read_callback) = 0; | 309 typedef Callback1<scoped_refptr<Buffer> >::Type FillBufferDoneCallback; |
| 310 void set_fill_buffer_done_callback(FillBufferDoneCallback* callback) { |
| 311 fill_buffer_done_callback_.reset(callback); |
| 312 } |
| 313 FillBufferDoneCallback* fill_buffer_done_callback() { |
| 314 return fill_buffer_done_callback_.get(); |
| 315 } |
| 316 |
| 317 // Render provides an output buffer for Decoder to write to. These buffers |
| 318 // will be recycled to renderer by fill_buffer_done_callback_; |
| 319 // We could also pass empty pointer here to let decoder provide buffers pool. |
| 320 virtual void FillThisBuffer(scoped_refptr<Buffer> buffer) = 0; |
| 321 |
| 322 private: |
| 323 scoped_ptr<FillBufferDoneCallback> fill_buffer_done_callback_; |
296 }; | 324 }; |
297 | 325 |
298 | 326 |
299 class VideoRenderer : public MediaFilter { | 327 class VideoRenderer : public MediaFilter { |
300 public: | 328 public: |
301 static FilterType filter_type() { | 329 static FilterType filter_type() { |
302 return FILTER_VIDEO_RENDERER; | 330 return FILTER_VIDEO_RENDERER; |
303 } | 331 } |
304 | 332 |
305 static const char* major_mime_type() { | 333 static const char* major_mime_type() { |
(...skipping 28 matching lines...) Expand all Loading... |
334 // buffer. | 362 // buffer. |
335 virtual bool HasEnded() = 0; | 363 virtual bool HasEnded() = 0; |
336 | 364 |
337 // Sets the output volume. | 365 // Sets the output volume. |
338 virtual void SetVolume(float volume) = 0; | 366 virtual void SetVolume(float volume) = 0; |
339 }; | 367 }; |
340 | 368 |
341 } // namespace media | 369 } // namespace media |
342 | 370 |
343 #endif // MEDIA_BASE_FILTERS_H_ | 371 #endif // MEDIA_BASE_FILTERS_H_ |
OLD | NEW |