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 #include "media/base/time_source.h" |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 class DemuxerStream; | 19 class DemuxerStream; |
19 class VideoDecoder; | 20 class VideoDecoder; |
20 class VideoFrame; | 21 class VideoFrame; |
21 | 22 |
22 class MEDIA_EXPORT VideoRenderer { | 23 class MEDIA_EXPORT VideoRenderer { |
23 public: | 24 public: |
24 // Used to paint VideoFrame. | 25 // Used to paint VideoFrame. |
25 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; | 26 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; |
26 | 27 |
27 // Used to convert a media timestamp into a wall clock timestamp. | |
28 typedef base::Callback<base::TimeTicks(base::TimeDelta)> WallClockTimeCB; | |
29 | |
30 VideoRenderer(); | 28 VideoRenderer(); |
31 | 29 |
32 // Stops all operations and fires all pending callbacks. | 30 // Stops all operations and fires all pending callbacks. |
33 virtual ~VideoRenderer(); | 31 virtual ~VideoRenderer(); |
34 | 32 |
35 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon | 33 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon |
36 // completion. If initialization fails, only |init_cb| (not |error_cb|) will | 34 // completion. If initialization fails, only |init_cb| (not |error_cb|) will |
37 // be called. | 35 // be called. |
38 // | 36 // |
39 // |set_decryptor_ready_cb| is fired when a Decryptor is needed, i.e. when the | 37 // |set_decryptor_ready_cb| is fired when a Decryptor is needed, i.e. when the |
(...skipping 15 matching lines...) Expand all Loading... |
55 // |waiting_for_decryption_key_cb| is executed whenever the key needed to | 53 // |waiting_for_decryption_key_cb| is executed whenever the key needed to |
56 // decrypt the stream is not available. | 54 // decrypt the stream is not available. |
57 virtual void Initialize( | 55 virtual void Initialize( |
58 DemuxerStream* stream, | 56 DemuxerStream* stream, |
59 const PipelineStatusCB& init_cb, | 57 const PipelineStatusCB& init_cb, |
60 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 58 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
61 const StatisticsCB& statistics_cb, | 59 const StatisticsCB& statistics_cb, |
62 const BufferingStateCB& buffering_state_cb, | 60 const BufferingStateCB& buffering_state_cb, |
63 const base::Closure& ended_cb, | 61 const base::Closure& ended_cb, |
64 const PipelineStatusCB& error_cb, | 62 const PipelineStatusCB& error_cb, |
65 const WallClockTimeCB& wall_clock_time_cb, | 63 const TimeSource::WallClockTimeCB& wall_clock_time_cb, |
66 const base::Closure& waiting_for_decryption_key_cb) = 0; | 64 const base::Closure& waiting_for_decryption_key_cb) = 0; |
67 | 65 |
68 // Discards any video data and stops reading from |stream|, executing | 66 // Discards any video data and stops reading from |stream|, executing |
69 // |callback| when completed. | 67 // |callback| when completed. |
70 // | 68 // |
71 // Clients should expect |buffering_state_cb| to be called with | 69 // Clients should expect |buffering_state_cb| to be called with |
72 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 70 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
73 virtual void Flush(const base::Closure& callback) = 0; | 71 virtual void Flush(const base::Closure& callback) = 0; |
74 | 72 |
75 // Starts playback at |timestamp| by reading from |stream| and decoding and | 73 // Starts playback at |timestamp| by reading from |stream| and decoding and |
76 // rendering video. | 74 // rendering video. |
77 // | 75 // |
78 // Only valid to call after a successful Initialize() or Flush(). | 76 // Only valid to call after a successful Initialize() or Flush(). |
79 virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0; | 77 virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0; |
80 | 78 |
81 // Called when time starts or stops moving. Time progresses when a base time | 79 // Called when time starts or stops moving. Time progresses when a base time |
82 // has been set and the playback rate is > 0. If either condition changes, | 80 // has been set and the playback rate is > 0. If either condition changes, |
83 // |time_progressing| will be false. | 81 // |time_progressing| will be false. |
84 virtual void OnTimeStateChanged(bool time_progressing) = 0; | 82 virtual void OnTimeStateChanged(bool time_progressing) = 0; |
85 | 83 |
86 private: | 84 private: |
87 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); | 85 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); |
88 }; | 86 }; |
89 | 87 |
90 } // namespace media | 88 } // namespace media |
91 | 89 |
92 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ | 90 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ |
OLD | NEW |