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/decryptor.h" | 12 #include "media/base/decryptor.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 #include "media/base/pipeline_status.h" | 14 #include "media/base/pipeline_status.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 class DemuxerStream; | 18 class DemuxerStream; |
19 class VideoDecoder; | 19 class VideoDecoder; |
20 class VideoFrame; | 20 class VideoFrame; |
21 | 21 |
22 class MEDIA_EXPORT VideoRenderer { | 22 class MEDIA_EXPORT VideoRenderer { |
23 public: | 23 public: |
24 // Used to paint VideoFrame. | 24 // Used to paint VideoFrame. |
25 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; | 25 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; |
26 | 26 |
27 // Used to query the current time or duration of the media. | 27 // Used to query the current time or duration of the media. |
xhwang
2015/03/23 22:20:13
"time or duration" is not accurate now...
DaleCurtis
2015/03/25 00:31:44
Done.
| |
28 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; | 28 typedef base::Callback<base::TimeTicks(base::TimeDelta)> TimeConverterCB; |
xhwang
2015/03/23 22:20:13
nit: s/TimeConverterCB/WallClockTimeCB/ ?
DaleCurtis
2015/03/25 00:31:45
Done.
| |
29 | 29 |
30 VideoRenderer(); | 30 VideoRenderer(); |
31 | 31 |
32 // Stops all operations and fires all pending callbacks. | 32 // Stops all operations and fires all pending callbacks. |
33 virtual ~VideoRenderer(); | 33 virtual ~VideoRenderer(); |
34 | 34 |
35 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon | 35 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon |
36 // completion. If initialization fails, only |init_cb| (not |error_cb|) will | 36 // completion. If initialization fails, only |init_cb| (not |error_cb|) will |
37 // be called. | 37 // be called. |
38 // | 38 // |
39 // |set_decryptor_ready_cb| is fired when a Decryptor is needed, i.e. when the | 39 // |set_decryptor_ready_cb| is fired when a Decryptor is needed, i.e. when the |
40 // |stream| is encrypted. | 40 // |stream| is encrypted. |
41 // | 41 // |
42 // |statistics_cb| is executed periodically with video rendering stats, such | 42 // |statistics_cb| is executed periodically with video rendering stats, such |
43 // as dropped frames. | 43 // as dropped frames. |
44 // | 44 // |
45 // |buffering_state_cb| is executed when video rendering has either run out of | 45 // |buffering_state_cb| is executed when video rendering has either run out of |
46 // data or has enough data to continue playback. | 46 // data or has enough data to continue playback. |
47 // | 47 // |
48 // |paint_cb| is executed on the video frame timing thread whenever a new | 48 // |paint_cb| is executed on the video frame timing thread whenever a new |
49 // frame is available for painting. Can be called from any thread. | 49 // frame is available for painting. Can be called from any thread. |
50 // | 50 // |
51 // |ended_cb| is executed when video rendering has reached the end of stream. | 51 // |ended_cb| is executed when video rendering has reached the end of stream. |
52 // | 52 // |
53 // |error_cb| is executed if an error was encountered after initialization. | 53 // |error_cb| is executed if an error was encountered after initialization. |
54 // | 54 // |
55 // |get_time_cb| is used to query the current media playback time. | 55 // |time_converter_cb| is used to convert media timestamps into wallclock |
56 // timestamps. | |
56 // | 57 // |
57 // |waiting_for_decryption_key_cb| is executed whenever the key needed to | 58 // |waiting_for_decryption_key_cb| is executed whenever the key needed to |
58 // decrypt the stream is not available. | 59 // decrypt the stream is not available. |
59 virtual void Initialize( | 60 virtual void Initialize( |
60 DemuxerStream* stream, | 61 DemuxerStream* stream, |
61 const PipelineStatusCB& init_cb, | 62 const PipelineStatusCB& init_cb, |
62 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 63 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
63 const StatisticsCB& statistics_cb, | 64 const StatisticsCB& statistics_cb, |
64 const BufferingStateCB& buffering_state_cb, | 65 const BufferingStateCB& buffering_state_cb, |
65 const PaintCB& paint_cb, | 66 const PaintCB& paint_cb, |
66 const base::Closure& ended_cb, | 67 const base::Closure& ended_cb, |
67 const PipelineStatusCB& error_cb, | 68 const PipelineStatusCB& error_cb, |
68 const TimeDeltaCB& get_time_cb, | 69 const TimeConverterCB& time_converter_cb, |
69 const base::Closure& waiting_for_decryption_key_cb) = 0; | 70 const base::Closure& waiting_for_decryption_key_cb) = 0; |
70 | 71 |
71 // Discards any video data and stops reading from |stream|, executing | 72 // Discards any video data and stops reading from |stream|, executing |
72 // |callback| when completed. | 73 // |callback| when completed. |
73 // | 74 // |
74 // Clients should expect |buffering_state_cb| to be called with | 75 // Clients should expect |buffering_state_cb| to be called with |
75 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 76 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
76 virtual void Flush(const base::Closure& callback) = 0; | 77 virtual void Flush(const base::Closure& callback) = 0; |
77 | 78 |
78 // Starts playback at |timestamp| by reading from |stream| and decoding and | 79 // Starts playback at |timestamp| by reading from |stream| and decoding and |
79 // rendering video. | 80 // rendering video. |
80 // | 81 // |
81 // Only valid to call after a successful Initialize() or Flush(). | 82 // Only valid to call after a successful Initialize() or Flush(). |
82 virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0; | 83 virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0; |
83 | 84 |
84 private: | 85 private: |
85 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); | 86 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); |
86 }; | 87 }; |
87 | 88 |
88 } // namespace media | 89 } // namespace media |
89 | 90 |
90 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ | 91 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ |
OLD | NEW |