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_FILTERS_VIDEO_RENDERER_BASE_H_ | 5 #ifndef MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // VideoRendererBase creates its own thread for the sole purpose of timing frame | 21 // VideoRendererBase creates its own thread for the sole purpose of timing frame |
22 // presentation. It handles reading from the decoder and stores the results in | 22 // presentation. It handles reading from the decoder and stores the results in |
23 // a queue of decoded frames and executing a callback when a frame is ready for | 23 // a queue of decoded frames and executing a callback when a frame is ready for |
24 // rendering. | 24 // rendering. |
25 class MEDIA_EXPORT VideoRendererBase | 25 class MEDIA_EXPORT VideoRendererBase |
26 : public VideoRenderer, | 26 : public VideoRenderer, |
27 public base::PlatformThread::Delegate { | 27 public base::PlatformThread::Delegate { |
28 public: | 28 public: |
29 typedef base::Callback<void(bool)> SetOpaqueCB; | 29 typedef base::Callback<void(bool)> SetOpaqueCB; |
30 | 30 |
| 31 // Maximum duration of the last frame. |
| 32 static base::TimeDelta kMaxLastFrameDuration(); |
| 33 |
31 // |paint_cb| is executed on the video frame timing thread whenever a new | 34 // |paint_cb| is executed on the video frame timing thread whenever a new |
32 // frame is available for painting via GetCurrentFrame(). | 35 // frame is available for painting via GetCurrentFrame(). |
33 // | 36 // |
34 // |set_opaque_cb| is executed when the renderer is initialized to inform | 37 // |set_opaque_cb| is executed when the renderer is initialized to inform |
35 // the player whether the decoder's output will be opaque or not. | 38 // the player whether the decoder's output will be opaque or not. |
36 // | 39 // |
37 // Implementors should avoid doing any sort of heavy work in this method and | 40 // Implementors should avoid doing any sort of heavy work in this method and |
38 // instead post a task to a common/worker thread to handle rendering. Slowing | 41 // instead post a task to a common/worker thread to handle rendering. Slowing |
39 // down the video thread may result in losing synchronization with audio. | 42 // down the video thread may result in losing synchronization with audio. |
40 // | 43 // |
41 // Setting |drop_frames_| to true causes the renderer to drop expired frames. | 44 // Setting |drop_frames_| to true causes the renderer to drop expired frames. |
42 // | 45 // |
43 // TODO(scherkus): pass the VideoFrame* to this callback and remove | 46 // TODO(scherkus): pass the VideoFrame* to this callback and remove |
44 // Get/PutCurrentFrame() http://crbug.com/108435 | 47 // Get/PutCurrentFrame() http://crbug.com/108435 |
45 VideoRendererBase(const base::Closure& paint_cb, | 48 VideoRendererBase(const base::Closure& paint_cb, |
46 const SetOpaqueCB& set_opaque_cb, | 49 const SetOpaqueCB& set_opaque_cb, |
47 bool drop_frames); | 50 bool drop_frames); |
48 | 51 |
49 // VideoRenderer implementation. | 52 // VideoRenderer implementation. |
50 virtual void Initialize(const scoped_refptr<VideoDecoder>& decoder, | 53 virtual void Initialize(const scoped_refptr<VideoDecoder>& decoder, |
51 const PipelineStatusCB& init_cb, | 54 const PipelineStatusCB& init_cb, |
52 const StatisticsCB& statistics_cb, | 55 const StatisticsCB& statistics_cb, |
53 const TimeCB& time_cb, | 56 const TimeCB& max_time_cb, |
54 const NaturalSizeChangedCB& size_changed_cb, | 57 const NaturalSizeChangedCB& size_changed_cb, |
55 const base::Closure& ended_cb, | 58 const base::Closure& ended_cb, |
56 const PipelineStatusCB& error_cb, | 59 const PipelineStatusCB& error_cb, |
57 const TimeDeltaCB& get_time_cb, | 60 const TimeDeltaCB& get_time_cb, |
58 const TimeDeltaCB& get_duration_cb) OVERRIDE; | 61 const TimeDeltaCB& get_duration_cb) OVERRIDE; |
59 virtual void Play(const base::Closure& callback) OVERRIDE; | 62 virtual void Play(const base::Closure& callback) OVERRIDE; |
60 virtual void Pause(const base::Closure& callback) OVERRIDE; | 63 virtual void Pause(const base::Closure& callback) OVERRIDE; |
61 virtual void Flush(const base::Closure& callback) OVERRIDE; | 64 virtual void Flush(const base::Closure& callback) OVERRIDE; |
62 virtual void Preroll(base::TimeDelta time, | 65 virtual void Preroll(base::TimeDelta time, |
63 const PipelineStatusCB& cb) OVERRIDE; | 66 const PipelineStatusCB& cb) OVERRIDE; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 bool drop_frames_; | 205 bool drop_frames_; |
203 | 206 |
204 float playback_rate_; | 207 float playback_rate_; |
205 | 208 |
206 // Playback operation callbacks. | 209 // Playback operation callbacks. |
207 base::Closure flush_cb_; | 210 base::Closure flush_cb_; |
208 PipelineStatusCB preroll_cb_; | 211 PipelineStatusCB preroll_cb_; |
209 | 212 |
210 // Event callbacks. | 213 // Event callbacks. |
211 StatisticsCB statistics_cb_; | 214 StatisticsCB statistics_cb_; |
212 TimeCB time_cb_; | 215 TimeCB max_time_cb_; |
213 NaturalSizeChangedCB size_changed_cb_; | 216 NaturalSizeChangedCB size_changed_cb_; |
214 base::Closure ended_cb_; | 217 base::Closure ended_cb_; |
215 PipelineStatusCB error_cb_; | 218 PipelineStatusCB error_cb_; |
216 TimeDeltaCB get_time_cb_; | 219 TimeDeltaCB get_time_cb_; |
217 TimeDeltaCB get_duration_cb_; | 220 TimeDeltaCB get_duration_cb_; |
218 | 221 |
219 base::TimeDelta preroll_timestamp_; | 222 base::TimeDelta preroll_timestamp_; |
220 | 223 |
221 // Delayed frame used during kPrerolling to determine whether | 224 // Delayed frame used during kPrerolling to determine whether |
222 // |preroll_timestamp_| is between this frame and the next one. | 225 // |preroll_timestamp_| is between this frame and the next one. |
223 scoped_refptr<VideoFrame> prerolling_delayed_frame_; | 226 scoped_refptr<VideoFrame> prerolling_delayed_frame_; |
224 | 227 |
225 // Embedder callback for notifying a new frame is available for painting. | 228 // Embedder callback for notifying a new frame is available for painting. |
226 base::Closure paint_cb_; | 229 base::Closure paint_cb_; |
227 | 230 |
228 // Callback to execute to inform the player if the video decoder's output is | 231 // Callback to execute to inform the player if the video decoder's output is |
229 // opaque. | 232 // opaque. |
230 SetOpaqueCB set_opaque_cb_; | 233 SetOpaqueCB set_opaque_cb_; |
231 | 234 |
232 // The last natural size |size_changed_cb_| was called with. | 235 // The last natural size |size_changed_cb_| was called with. |
233 gfx::Size last_natural_size_; | 236 gfx::Size last_natural_size_; |
234 | 237 |
235 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); | 238 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); |
236 }; | 239 }; |
237 | 240 |
238 } // namespace media | 241 } // namespace media |
239 | 242 |
240 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 243 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
OLD | NEW |