Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_RENDERERS_VIDEO_RENDERER_IMPL_H_ | 5 #ifndef MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ |
| 6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ | 6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_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 17 matching lines...) Expand all Loading... | |
| 28 #include "media/renderers/gpu_video_accelerator_factories.h" | 28 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 29 #include "media/video/gpu_memory_buffer_video_frame_pool.h" | 29 #include "media/video/gpu_memory_buffer_video_frame_pool.h" |
| 30 | 30 |
| 31 namespace base { | 31 namespace base { |
| 32 class SingleThreadTaskRunner; | 32 class SingleThreadTaskRunner; |
| 33 class TickClock; | 33 class TickClock; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace media { | 36 namespace media { |
| 37 | 37 |
| 38 // VideoRendererImpl creates its own thread for the sole purpose of timing frame | 38 // VideoRendererImpl creates its own thread for the sole purpose of timing frame |
|
xhwang
2015/07/21 21:01:38
This needs to be updated :)
DaleCurtis
2015/07/22 00:44:44
I'll do so in the CL that removes the old pathway.
| |
| 39 // presentation. It handles reading from the VideoFrameStream and stores the | 39 // presentation. It handles reading from the VideoFrameStream and stores the |
| 40 // results in a queue of decoded frames and executing a callback when a frame is | 40 // results in a queue of decoded frames and executing a callback when a frame is |
| 41 // ready for rendering. | 41 // ready for rendering. |
| 42 class MEDIA_EXPORT VideoRendererImpl | 42 class MEDIA_EXPORT VideoRendererImpl |
| 43 : public VideoRenderer, | 43 : public VideoRenderer, |
| 44 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback), | 44 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback), |
| 45 public base::PlatformThread::Delegate { | 45 public base::PlatformThread::Delegate { |
| 46 public: | 46 public: |
| 47 // |decoders| contains the VideoDecoders to use when initializing. | 47 // |decoders| contains the VideoDecoders to use when initializing. |
| 48 // | 48 // |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 140 |
| 141 // Returns true if there is no more room for additional buffered frames. | 141 // Returns true if there is no more room for additional buffered frames. |
| 142 bool HaveReachedBufferingCap(); | 142 bool HaveReachedBufferingCap(); |
| 143 | 143 |
| 144 // Starts or stops |sink_| respectively. Do not call while |lock_| is held. | 144 // Starts or stops |sink_| respectively. Do not call while |lock_| is held. |
| 145 void StartSink(); | 145 void StartSink(); |
| 146 void StopSink(); | 146 void StopSink(); |
| 147 | 147 |
| 148 // Fires |ended_cb_| if there are no remaining usable frames and | 148 // Fires |ended_cb_| if there are no remaining usable frames and |
| 149 // |received_end_of_stream_| is true. Sets |rendered_end_of_stream_| if it | 149 // |received_end_of_stream_| is true. Sets |rendered_end_of_stream_| if it |
| 150 // does so. Returns algorithm_->EffectiveFramesQueued(). | 150 // does so. |
| 151 size_t MaybeFireEndedCallback(); | 151 // |
| 152 // When called from the media thread, |time_progressing| should reflect the | |
| 153 // value of |time_progressing_|. When called from Render() on the sink | |
| 154 // callback thread, the inverse of |render_first_frame_and_stop_| should be | |
| 155 // used as a proxy for |time_progressing_|. | |
| 156 // | |
| 157 // Returns algorithm_->EffectiveFramesQueued(). | |
| 158 size_t MaybeFireEndedCallback(bool time_progressing); | |
| 152 | 159 |
| 153 // Helper method for converting a single media timestamp to wall clock time. | 160 // Helper method for converting a single media timestamp to wall clock time. |
| 154 base::TimeTicks ConvertMediaTimestamp(base::TimeDelta media_timestamp); | 161 base::TimeTicks ConvertMediaTimestamp(base::TimeDelta media_timestamp); |
| 155 | 162 |
| 156 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 163 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 157 | 164 |
| 158 // Enables the use of VideoRendererAlgorithm and VideoRendererSink for frame | 165 // Enables the use of VideoRendererAlgorithm and VideoRendererSink for frame |
| 159 // rendering instead of using a thread in a sleep-loop. Set via the command | 166 // rendering instead of using a thread in a sleep-loop. Set via the command |
| 160 // line flag kEnableNewVideoRenderer or via test methods. | 167 // line flag kEnableNewVideoRenderer or via test methods. |
| 161 bool use_new_video_renderering_path_; | 168 bool use_new_video_renderering_path_; |
| 162 | 169 |
| 163 // Sink which calls into VideoRendererImpl via Render() for video frames. Do | 170 // Sink which calls into VideoRendererImpl via Render() for video frames. Do |
| 164 // not call any methods on the sink while |lock_| is held or the two threads | 171 // not call any methods on the sink while |lock_| is held or the two threads |
| 165 // might deadlock. Do not call Start() or Stop() on the sink directly, use | 172 // might deadlock. Do not call Start() or Stop() on the sink directly, use |
| 166 // StartSink() and StopSink() to ensure background rendering is started. | 173 // StartSink() and StopSink() to ensure background rendering is started. |
| 167 VideoRendererSink* const sink_; | 174 VideoRendererSink* const sink_; |
| 168 bool sink_started_; | 175 bool sink_started_; |
|
xhwang
2015/07/21 21:01:38
Add a comment that these two can only be accessed
DaleCurtis
2015/07/22 00:44:44
Done.
| |
| 169 | 176 |
| 170 // Used for accessing data members. | 177 // Used for accessing data members. |
| 171 base::Lock lock_; | 178 base::Lock lock_; |
|
xhwang
2015/07/21 21:01:38
Now it's unfortunate that it's pretty hard to know
DaleCurtis
2015/07/22 00:44:44
Yeah, I'll reflow this in the deletion CL.
| |
| 172 | 179 |
| 173 // Provides video frames to VideoRendererImpl. | 180 // Provides video frames to VideoRendererImpl. |
| 174 scoped_ptr<VideoFrameStream> video_frame_stream_; | 181 scoped_ptr<VideoFrameStream> video_frame_stream_; |
| 175 | 182 |
| 176 // Pool of GpuMemoryBuffers and resources used to create hardware frames. | 183 // Pool of GpuMemoryBuffers and resources used to create hardware frames. |
| 177 scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; | 184 scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; |
| 178 | 185 |
| 179 // Flag indicating low-delay mode. | 186 // Flag indicating low-delay mode. |
| 180 bool low_delay_; | 187 bool low_delay_; |
| 181 | 188 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 | 271 |
| 265 // Algorithm for selecting which frame to render; manages frames and all | 272 // Algorithm for selecting which frame to render; manages frames and all |
| 266 // timing related information. | 273 // timing related information. |
| 267 scoped_ptr<VideoRendererAlgorithm> algorithm_; | 274 scoped_ptr<VideoRendererAlgorithm> algorithm_; |
| 268 | 275 |
| 269 // Indicates that Render() was called with |background_rendering| set to true, | 276 // Indicates that Render() was called with |background_rendering| set to true, |
| 270 // so we've entered a background rendering mode where dropped frames are not | 277 // so we've entered a background rendering mode where dropped frames are not |
| 271 // counted. Must be accessed under |lock_| once |sink_| is started. | 278 // counted. Must be accessed under |lock_| once |sink_| is started. |
| 272 bool was_background_rendering_; | 279 bool was_background_rendering_; |
| 273 | 280 |
| 274 // Indicates whether or not media time is currently progressing or not. | 281 // Indicates whether or not media time is currently progressing or not. Must |
| 282 // only be accessed on the media thread. | |
|
xhwang
2015/07/21 21:01:38
This file doesn't know about the media thread. Rep
DaleCurtis
2015/07/22 00:44:44
Done.
| |
| 275 bool time_progressing_; | 283 bool time_progressing_; |
| 276 | 284 |
| 277 // Indicates that Render() should only render the first frame and then request | 285 // Indicates that Render() should only render the first frame and then request |
| 278 // that the sink be stopped. |posted_maybe_stop_after_first_paint_| is used | 286 // that the sink be stopped. |posted_maybe_stop_after_first_paint_| is used |
| 279 // to avoid repeated task posts. | 287 // to avoid repeated task posts. |
| 280 bool render_first_frame_and_stop_; | 288 bool render_first_frame_and_stop_; |
| 281 bool posted_maybe_stop_after_first_paint_; | 289 bool posted_maybe_stop_after_first_paint_; |
| 282 | 290 |
| 283 // NOTE: Weak pointers must be invalidated before all other member variables. | 291 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 284 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; | 292 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; |
| 285 | 293 |
| 286 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); | 294 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); |
| 287 }; | 295 }; |
| 288 | 296 |
| 289 } // namespace media | 297 } // namespace media |
| 290 | 298 |
| 291 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ | 299 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ |
| OLD | NEW |