| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef MEDIA_BASE_VIDEO_RENDERER_H_ | 5 #ifndef MEDIA_BASE_VIDEO_RENDERER_H_ |
| 6 #define MEDIA_BASE_VIDEO_RENDERER_H_ | 6 #define MEDIA_BASE_VIDEO_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "media/base/buffering_state.h" | 11 #include "media/base/buffering_state.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 #include "media/base/pipeline_status.h" | 13 #include "media/base/pipeline_status.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 class DemuxerStream; | 17 class DemuxerStream; |
| 18 class VideoDecoder; | 18 class VideoDecoder; |
| 19 | 19 |
| 20 class MEDIA_EXPORT VideoRenderer { | 20 class MEDIA_EXPORT VideoRenderer { |
| 21 public: | 21 public: |
| 22 // Used to update the pipeline's clock time. The parameter is the time that | |
| 23 // the clock should not exceed. | |
| 24 typedef base::Callback<void(base::TimeDelta)> TimeCB; | |
| 25 | |
| 26 // Used to query the current time or duration of the media. | 22 // Used to query the current time or duration of the media. |
| 27 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; | 23 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; |
| 28 | 24 |
| 29 VideoRenderer(); | 25 VideoRenderer(); |
| 30 | 26 |
| 31 // Stops all operations and fires all pending callbacks. | 27 // Stops all operations and fires all pending callbacks. |
| 32 virtual ~VideoRenderer(); | 28 virtual ~VideoRenderer(); |
| 33 | 29 |
| 34 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon | 30 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon |
| 35 // completion. | 31 // completion. |
| 36 // | 32 // |
| 37 // |statistics_cb| is executed periodically with video rendering stats, such | 33 // |statistics_cb| is executed periodically with video rendering stats, such |
| 38 // as dropped frames. | 34 // as dropped frames. |
| 39 // | 35 // |
| 40 // |time_cb| is executed whenever time has advanced by way of video rendering. | |
| 41 // | |
| 42 // |buffering_state_cb| is executed when video rendering has either run out of | 36 // |buffering_state_cb| is executed when video rendering has either run out of |
| 43 // data or has enough data to continue playback. | 37 // data or has enough data to continue playback. |
| 44 // | 38 // |
| 45 // |ended_cb| is executed when video rendering has reached the end of stream. | 39 // |ended_cb| is executed when video rendering has reached the end of stream. |
| 46 // | 40 // |
| 47 // |error_cb| is executed if an error was encountered. | 41 // |error_cb| is executed if an error was encountered. |
| 48 // | 42 // |
| 49 // |get_time_cb| is used to query the current media playback time. | 43 // |get_time_cb| is used to query the current media playback time. |
| 50 // | |
| 51 // |get_duration_cb| is used to query the media duration. | |
| 52 virtual void Initialize(DemuxerStream* stream, | 44 virtual void Initialize(DemuxerStream* stream, |
| 53 bool low_delay, | 45 bool low_delay, |
| 54 const PipelineStatusCB& init_cb, | 46 const PipelineStatusCB& init_cb, |
| 55 const StatisticsCB& statistics_cb, | 47 const StatisticsCB& statistics_cb, |
| 56 const TimeCB& time_cb, | |
| 57 const BufferingStateCB& buffering_state_cb, | 48 const BufferingStateCB& buffering_state_cb, |
| 58 const base::Closure& ended_cb, | 49 const base::Closure& ended_cb, |
| 59 const PipelineStatusCB& error_cb, | 50 const PipelineStatusCB& error_cb, |
| 60 const TimeDeltaCB& get_time_cb, | 51 const TimeDeltaCB& get_time_cb) = 0; |
| 61 const TimeDeltaCB& get_duration_cb) = 0; | |
| 62 | 52 |
| 63 // Discards any video data and stops reading from |stream|, executing | 53 // Discards any video data and stops reading from |stream|, executing |
| 64 // |callback| when completed. | 54 // |callback| when completed. |
| 65 // | 55 // |
| 66 // Clients should expect |buffering_state_cb| to be called with | 56 // Clients should expect |buffering_state_cb| to be called with |
| 67 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 57 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
| 68 virtual void Flush(const base::Closure& callback) = 0; | 58 virtual void Flush(const base::Closure& callback) = 0; |
| 69 | 59 |
| 70 // Starts playback by reading from |stream| and decoding and rendering video. | 60 // Starts playback by reading from |stream| and decoding and rendering video. |
| 71 // | 61 // |
| 72 // Only valid to call after a successful Initialize() or Flush(). | 62 // Only valid to call after a successful Initialize() or Flush(). |
| 73 virtual void StartPlaying() = 0; | 63 virtual void StartPlaying() = 0; |
| 74 | 64 |
| 75 private: | 65 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); | 66 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); |
| 77 }; | 67 }; |
| 78 | 68 |
| 79 } // namespace media | 69 } // namespace media |
| 80 | 70 |
| 81 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ | 71 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ |
| OLD | NEW |