Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_AUDIO_NULL_VIDEO_SINK_H_ | |
| 6 #define MEDIA_AUDIO_NULL_VIDEO_SINK_H_ | |
| 7 | |
| 8 #include "base/cancelable_callback.h" | |
| 9 #include "base/md5.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/time/default_tick_clock.h" | |
| 12 #include "base/time/tick_clock.h" | |
| 13 #include "media/base/video_renderer_sink.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class SingleThreadTaskRunner; | |
| 17 } | |
| 18 | |
| 19 namespace media { | |
| 20 | |
| 21 class MEDIA_EXPORT NullVideoSink : NON_EXPORTED_BASE(public VideoRendererSink) { | |
| 22 public: | |
| 23 using NewFrameCB = base::Callback<void(const scoped_refptr<VideoFrame>&)>; | |
| 24 | |
| 25 // Periodically calls |callback| every |interval| on |task_runner| once the | |
| 26 // sink has been started. If |clockless| is true, the RenderCallback will | |
| 27 // called back to back by repeated post tasks. Optionally, if specified, | |
|
xhwang
2015/04/28 23:12:06
s/called/be called/
DaleCurtis
2015/04/29 00:54:07
Done.
| |
| 28 // |new_frame_cb| will be called for each new frame received. | |
| 29 NullVideoSink(bool clockless, | |
| 30 base::TimeDelta interval, | |
| 31 const NewFrameCB& new_frame_cb, | |
| 32 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | |
| 33 ~NullVideoSink() override; | |
| 34 | |
| 35 // VideoRendererSink implementation. | |
| 36 void Start(RenderCallback* callback) override; | |
| 37 void Stop() override; | |
| 38 void PaintFrameUsingOldRenderingPath( | |
| 39 const scoped_refptr<VideoFrame>& frame) override; | |
| 40 | |
| 41 // Allows tests to simulate suspension of Render() callbacks. | |
| 42 void pause_callbacks(base::TimeTicks pause_util) { | |
|
xhwang
2015/04/28 23:12:06
s/pause_callbacks/PauseRenderCallbacks/?
DaleCurtis
2015/04/29 00:54:07
Done.
| |
| 43 pause_end_time_ = pause_util; | |
| 44 } | |
| 45 | |
| 46 void set_tick_clock_for_testing(base::TickClock* tick_clock) { | |
|
xhwang
2015/04/28 23:12:06
Use SetTickClockForTesting() since this is not str
xhwang
2015/04/28 23:12:06
Put comments here since this is the public interfa
DaleCurtis
2015/04/29 00:54:07
That doesn't apply to this case, the reason being
| |
| 47 tick_clock_ = tick_clock; | |
| 48 } | |
| 49 | |
| 50 void set_stop_callback(const base::Closure& stop_cb) { | |
|
xhwang
2015/04/28 23:12:06
set_stop_cb? Also add comment. It's not clear unle
DaleCurtis
2015/04/29 00:54:07
I prefer it spelled out for a method name. Added a
| |
| 51 stop_cb_ = stop_cb; | |
| 52 } | |
| 53 | |
| 54 private: | |
| 55 // Task that periodically calls Render() to consume audio data. | |
|
xhwang
2015/04/28 23:12:06
s/audio/video
DaleCurtis
2015/04/29 00:54:07
Done.
| |
| 56 void CallRender(); | |
| 57 | |
| 58 const bool clockless_; | |
| 59 const base::TimeDelta interval_; | |
| 60 const NewFrameCB new_frame_cb_; | |
| 61 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 62 | |
| 63 bool started_; | |
| 64 RenderCallback* callback_; | |
| 65 | |
| 66 // Manages cancelation of periodic Render() callback task. | |
| 67 base::CancelableClosure cancelable_worker_; | |
| 68 | |
| 69 // Used to determine when a new frame is received. | |
| 70 scoped_refptr<VideoFrame> last_frame_; | |
| 71 | |
| 72 // Used to determine the interval given to RenderCallback::Render() as well as | |
| 73 // to maintain stable periodicity of callbacks. | |
| 74 base::TimeTicks current_render_time_; | |
| 75 | |
| 76 // Used to suspend Render() callbacks to |callback_| for some time. | |
| 77 base::TimeTicks pause_end_time_; | |
| 78 | |
| 79 // If specified, used instead of base::TimeTicks::Now(). | |
|
xhwang
2015/04/28 23:12:06
This comment only applies to |tick_clock_|, right?
DaleCurtis
2015/04/29 00:54:07
Done.
| |
| 80 base::DefaultTickClock default_tick_clock_; | |
| 81 base::TickClock* tick_clock_; | |
| 82 base::TimeTicks last_now_; | |
| 83 | |
| 84 // If set, called when Stop() is called. | |
| 85 base::Closure stop_cb_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(NullVideoSink); | |
| 88 }; | |
| 89 | |
| 90 } // namespace media | |
| 91 | |
| 92 #endif // MEDIA_AUDIO_NULL_VIDEO_SINK_H_ | |
| OLD | NEW |