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 |
22 // Used to query the current time or duration of the media. | 26 // Used to query the current time or duration of the media. |
23 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; | 27 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; |
24 | 28 |
25 VideoRenderer(); | 29 VideoRenderer(); |
26 | 30 |
27 // Stops all operations and fires all pending callbacks. | 31 // Stops all operations and fires all pending callbacks. |
28 virtual ~VideoRenderer(); | 32 virtual ~VideoRenderer(); |
29 | 33 |
30 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon | 34 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon |
31 // completion. | 35 // completion. |
32 // | 36 // |
33 // |statistics_cb| is executed periodically with video rendering stats, such | 37 // |statistics_cb| is executed periodically with video rendering stats, such |
34 // as dropped frames. | 38 // as dropped frames. |
35 // | 39 // |
| 40 // |time_cb| is executed whenever time has advanced by way of video rendering. |
| 41 // |
36 // |buffering_state_cb| is executed when video rendering has either run out of | 42 // |buffering_state_cb| is executed when video rendering has either run out of |
37 // data or has enough data to continue playback. | 43 // data or has enough data to continue playback. |
38 // | 44 // |
39 // |ended_cb| is executed when video rendering has reached the end of stream. | 45 // |ended_cb| is executed when video rendering has reached the end of stream. |
40 // | 46 // |
41 // |error_cb| is executed if an error was encountered. | 47 // |error_cb| is executed if an error was encountered. |
42 // | 48 // |
43 // |get_time_cb| is used to query the current media playback time. | 49 // |get_time_cb| is used to query the current media playback time. |
| 50 // |
| 51 // |get_duration_cb| is used to query the media duration. |
44 virtual void Initialize(DemuxerStream* stream, | 52 virtual void Initialize(DemuxerStream* stream, |
45 bool low_delay, | 53 bool low_delay, |
46 const PipelineStatusCB& init_cb, | 54 const PipelineStatusCB& init_cb, |
47 const StatisticsCB& statistics_cb, | 55 const StatisticsCB& statistics_cb, |
| 56 const TimeCB& time_cb, |
48 const BufferingStateCB& buffering_state_cb, | 57 const BufferingStateCB& buffering_state_cb, |
49 const base::Closure& ended_cb, | 58 const base::Closure& ended_cb, |
50 const PipelineStatusCB& error_cb, | 59 const PipelineStatusCB& error_cb, |
51 const TimeDeltaCB& get_time_cb) = 0; | 60 const TimeDeltaCB& get_time_cb, |
| 61 const TimeDeltaCB& get_duration_cb) = 0; |
52 | 62 |
53 // Discards any video data and stops reading from |stream|, executing | 63 // Discards any video data and stops reading from |stream|, executing |
54 // |callback| when completed. | 64 // |callback| when completed. |
55 // | 65 // |
56 // Clients should expect |buffering_state_cb| to be called with | 66 // Clients should expect |buffering_state_cb| to be called with |
57 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 67 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
58 virtual void Flush(const base::Closure& callback) = 0; | 68 virtual void Flush(const base::Closure& callback) = 0; |
59 | 69 |
60 // Starts playback by reading from |stream| and decoding and rendering video. | 70 // Starts playback by reading from |stream| and decoding and rendering video. |
61 // | 71 // |
62 // Only valid to call after a successful Initialize() or Flush(). | 72 // Only valid to call after a successful Initialize() or Flush(). |
63 virtual void StartPlaying() = 0; | 73 virtual void StartPlaying() = 0; |
64 | 74 |
65 private: | 75 private: |
66 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); | 76 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); |
67 }; | 77 }; |
68 | 78 |
69 } // namespace media | 79 } // namespace media |
70 | 80 |
71 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ | 81 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ |
OLD | NEW |