Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: media/renderers/video_renderer_impl.h

Issue 1863373002: Fix underflow and av/sync issues in low delay and stall presence. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar tests. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const PipelineStatusCB& error_cb, 72 const PipelineStatusCB& error_cb,
73 const TimeSource::WallClockTimeCB& wall_clock_time_cb, 73 const TimeSource::WallClockTimeCB& wall_clock_time_cb,
74 const base::Closure& waiting_for_decryption_key_cb) override; 74 const base::Closure& waiting_for_decryption_key_cb) override;
75 void Flush(const base::Closure& callback) override; 75 void Flush(const base::Closure& callback) override;
76 void StartPlayingFrom(base::TimeDelta timestamp) override; 76 void StartPlayingFrom(base::TimeDelta timestamp) override;
77 void OnTimeStateChanged(bool time_progressing) override; 77 void OnTimeStateChanged(bool time_progressing) override;
78 78
79 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock); 79 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock);
80 void SetGpuMemoryBufferVideoForTesting( 80 void SetGpuMemoryBufferVideoForTesting(
81 scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool); 81 scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool);
82 size_t frames_queued_for_testing() const {
83 return algorithm_->frames_queued();
84 }
82 85
83 // VideoRendererSink::RenderCallback implementation. 86 // VideoRendererSink::RenderCallback implementation.
84 scoped_refptr<VideoFrame> Render(base::TimeTicks deadline_min, 87 scoped_refptr<VideoFrame> Render(base::TimeTicks deadline_min,
85 base::TimeTicks deadline_max, 88 base::TimeTicks deadline_max,
86 bool background_rendering) override; 89 bool background_rendering) override;
87 void OnFrameDropped() override; 90 void OnFrameDropped() override;
88 91
89 private: 92 private:
90 // Callback for |video_frame_stream_| initialization. 93 // Callback for |video_frame_stream_| initialization.
91 void OnVideoFrameStreamInitialized(bool success); 94 void OnVideoFrameStreamInitialized(bool success);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 151
149 // Helper method for converting a single media timestamp to wall clock time. 152 // Helper method for converting a single media timestamp to wall clock time.
150 base::TimeTicks ConvertMediaTimestamp(base::TimeDelta media_timestamp); 153 base::TimeTicks ConvertMediaTimestamp(base::TimeDelta media_timestamp);
151 154
152 base::TimeTicks GetCurrentMediaTimeAsWallClockTime(); 155 base::TimeTicks GetCurrentMediaTimeAsWallClockTime();
153 156
154 // Helper method for checking if a frame timestamp plus the frame's expected 157 // Helper method for checking if a frame timestamp plus the frame's expected
155 // duration is before |start_timestamp_|. 158 // duration is before |start_timestamp_|.
156 bool IsBeforeStartTime(base::TimeDelta timestamp); 159 bool IsBeforeStartTime(base::TimeDelta timestamp);
157 160
161 // Attempts to remove frames which are no longer effective for rendering when
162 // |buffering_state_| == BUFFERING_HAVE_NOTHING or |was_background_rendering_|
163 // is true. If the current media time as provided by |wall_clock_time_cb_| is
164 // null, no frame expiration will be done.
165 //
166 // When background rendering the method will expire all frames before the
167 // current wall clock time since it's expected that there will be long delays
168 // between each Render() call in this state.
169 //
170 // When in the underflow state the method will first attempt to remove expired
171 // frames before the current media time plus duration. If |sink_started_| is
172 // true, nothing more can be done. However, if false, and there are still no
173 // effective frames in the queue, the entire frame queue will be released to
174 // avoid any stalling.
175 void RemoveFramesForUnderflowOrBackgroundRendering();
176
158 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 177 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
159 178
160 // Sink which calls into VideoRendererImpl via Render() for video frames. Do 179 // Sink which calls into VideoRendererImpl via Render() for video frames. Do
161 // not call any methods on the sink while |lock_| is held or the two threads 180 // not call any methods on the sink while |lock_| is held or the two threads
162 // might deadlock. Do not call Start() or Stop() on the sink directly, use 181 // might deadlock. Do not call Start() or Stop() on the sink directly, use
163 // StartSink() and StopSink() to ensure background rendering is started. Only 182 // StartSink() and StopSink() to ensure background rendering is started. Only
164 // access these values on |task_runner_|. 183 // access these values on |task_runner_|.
165 VideoRendererSink* const sink_; 184 VideoRendererSink* const sink_;
166 bool sink_started_; 185 bool sink_started_;
167 186
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 288
270 // NOTE: Weak pointers must be invalidated before all other member variables. 289 // NOTE: Weak pointers must be invalidated before all other member variables.
271 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 290 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
272 291
273 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 292 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
274 }; 293 };
275 294
276 } // namespace media 295 } // namespace media
277 296
278 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 297 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | media/renderers/video_renderer_impl.cc » ('j') | media/renderers/video_renderer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698