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 <list> | |
9 | |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/time.h" | 12 #include "base/time.h" |
11 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
12 #include "media/base/pipeline_status.h" | 14 #include "media/base/pipeline_status.h" |
13 | 15 |
14 namespace gfx { | 16 namespace gfx { |
15 class Size; | 17 class Size; |
16 } | 18 } |
17 | 19 |
18 namespace media { | 20 namespace media { |
19 | 21 |
22 class DemuxerStream; | |
20 class VideoDecoder; | 23 class VideoDecoder; |
21 | 24 |
22 class MEDIA_EXPORT VideoRenderer | 25 class MEDIA_EXPORT VideoRenderer |
23 : public base::RefCountedThreadSafe<VideoRenderer> { | 26 : public base::RefCountedThreadSafe<VideoRenderer> { |
24 public: | 27 public: |
28 typedef std::list<scoped_refptr<VideoDecoder> > VideoDecoderList; | |
29 | |
25 // Used to update the pipeline's clock time. The parameter is the time that | 30 // Used to update the pipeline's clock time. The parameter is the time that |
26 // the clock should not exceed. | 31 // the clock should not exceed. |
27 typedef base::Callback<void(base::TimeDelta)> TimeCB; | 32 typedef base::Callback<void(base::TimeDelta)> TimeCB; |
28 | 33 |
29 // Executed when the natural size of the video has changed. | 34 // Executed when the natural size of the video has changed. |
30 typedef base::Callback<void(const gfx::Size& size)> NaturalSizeChangedCB; | 35 typedef base::Callback<void(const gfx::Size& size)> NaturalSizeChangedCB; |
31 | 36 |
32 // Used to query the current time or duration of the media. | 37 // Used to query the current time or duration of the media. |
33 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; | 38 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; |
34 | 39 |
35 // Initialize a VideoRenderer with the given VideoDecoder, executing | 40 // Initialize a VideoRenderer with the given VideoDecoder, executing |
scherkus (not reviewing)
2012/08/14 22:00:24
docs need updating
acolwell GONE FROM CHROMIUM
2012/08/15 21:36:57
Done.
| |
36 // |init_cb| callback upon completion. | 41 // |init_cb| callback upon completion. |
37 // | 42 // |
38 // |statistics_cb| is executed periodically with video rendering stats, such | 43 // |statistics_cb| is executed periodically with video rendering stats, such |
39 // as dropped frames. | 44 // as dropped frames. |
40 // | 45 // |
41 // |time_cb| is executed whenever time has advanced by way of video rendering. | 46 // |time_cb| is executed whenever time has advanced by way of video rendering. |
42 // | 47 // |
43 // |size_changed_cb| is executed whenever the dimensions of the video has | 48 // |size_changed_cb| is executed whenever the dimensions of the video has |
44 // changed. | 49 // changed. |
45 // | 50 // |
46 // |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. |
47 // | 52 // |
48 // |error_cb| is executed if an error was encountered. | 53 // |error_cb| is executed if an error was encountered. |
49 // | 54 // |
50 // |get_time_cb| is used to query the current media playback time. | 55 // |get_time_cb| is used to query the current media playback time. |
51 // | 56 // |
52 // |get_duration_cb| is used to query the media duration. | 57 // |get_duration_cb| is used to query the media duration. |
53 virtual void Initialize(const scoped_refptr<VideoDecoder>& decoder, | 58 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
59 const VideoDecoderList& decoders, | |
54 const PipelineStatusCB& init_cb, | 60 const PipelineStatusCB& init_cb, |
55 const StatisticsCB& statistics_cb, | 61 const StatisticsCB& statistics_cb, |
56 const TimeCB& time_cb, | 62 const TimeCB& time_cb, |
57 const NaturalSizeChangedCB& size_changed_cb, | 63 const NaturalSizeChangedCB& size_changed_cb, |
58 const base::Closure& ended_cb, | 64 const base::Closure& ended_cb, |
59 const PipelineStatusCB& error_cb, | 65 const PipelineStatusCB& error_cb, |
60 const TimeDeltaCB& get_time_cb, | 66 const TimeDeltaCB& get_time_cb, |
61 const TimeDeltaCB& get_duration_cb) = 0; | 67 const TimeDeltaCB& get_duration_cb) = 0; |
62 | 68 |
63 // Start audio decoding and rendering at the current playback rate, executing | 69 // Start audio decoding and rendering at the current playback rate, executing |
(...skipping 14 matching lines...) Expand all Loading... | |
78 virtual void Preroll(base::TimeDelta time, | 84 virtual void Preroll(base::TimeDelta time, |
79 const PipelineStatusCB& callback) = 0; | 85 const PipelineStatusCB& callback) = 0; |
80 | 86 |
81 // Stop all operations in preparation for being deleted, executing |callback| | 87 // Stop all operations in preparation for being deleted, executing |callback| |
82 // when complete. | 88 // when complete. |
83 virtual void Stop(const base::Closure& callback) = 0; | 89 virtual void Stop(const base::Closure& callback) = 0; |
84 | 90 |
85 // Updates the current playback rate. | 91 // Updates the current playback rate. |
86 virtual void SetPlaybackRate(float playback_rate) = 0; | 92 virtual void SetPlaybackRate(float playback_rate) = 0; |
87 | 93 |
94 // Prepare decoder for shutdown. This is a HACK needed because | |
95 // PipelineImpl::Stop() goes through a Pause/Flush/Stop dance to all its | |
96 // filters, waiting for each state transition to complete before starting the | |
97 // next, but WebMediaPlayerImpl::Destroy() holds the renderer loop hostage for | |
98 // the duration. http://crbug.com/110228 tracks removing this. | |
99 virtual void PrepareForShutdownHack() = 0; | |
100 | |
88 protected: | 101 protected: |
89 friend class base::RefCountedThreadSafe<VideoRenderer>; | 102 friend class base::RefCountedThreadSafe<VideoRenderer>; |
90 | 103 |
91 VideoRenderer(); | 104 VideoRenderer(); |
92 virtual ~VideoRenderer(); | 105 virtual ~VideoRenderer(); |
93 | 106 |
94 private: | 107 private: |
95 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); | 108 DISALLOW_COPY_AND_ASSIGN(VideoRenderer); |
96 }; | 109 }; |
97 | 110 |
98 } // namespace media | 111 } // namespace media |
99 | 112 |
100 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ | 113 #endif // MEDIA_BASE_VIDEO_RENDERER_H_ |
OLD | NEW |