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

Side by Side Diff: media/base/null_video_sink.h

Issue 1116473002: Introduce NullVideoSink for test classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 7 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
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/null_video_sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // be called back to back by repeated post tasks. Optionally, if specified,
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_render_callbacks(base::TimeTicks pause_util) {
xhwang 2015/04/29 03:49:13 Here and below: based on the style guide: 1. Only
DaleCurtis 2015/04/29 04:26:48 Disagree especially on the middle one, for_testing
xhwang 2015/04/29 05:20:19 I missed this text. Thanks for pointing that out!
43 pause_end_time_ = pause_util;
44 }
45
46 void set_tick_clock_for_testing(base::TickClock* tick_clock) {
47 tick_clock_ = tick_clock;
48 }
49
50 // Sets |stop_cb_|, which will be fired when Stop() is called.
51 void set_stop_callback(const base::Closure& stop_cb) {
52 stop_cb_ = stop_cb;
53 }
54
55 private:
56 // Task that periodically calls Render() to consume video data.
57 void CallRender();
58
59 const bool clockless_;
60 const base::TimeDelta interval_;
61 const NewFrameCB new_frame_cb_;
62 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
63
64 bool started_;
65 RenderCallback* callback_;
66
67 // Manages cancellation of periodic Render() callback task.
68 base::CancelableClosure cancelable_worker_;
69
70 // Used to determine when a new frame is received.
71 scoped_refptr<VideoFrame> last_frame_;
72
73 // Used to determine the interval given to RenderCallback::Render() as well as
74 // to maintain stable periodicity of callbacks.
75 base::TimeTicks current_render_time_;
76
77 // Used to suspend Render() callbacks to |callback_| for some time.
78 base::TimeTicks pause_end_time_;
79
80 // Allow for an injectable tick clock for testing.
81 base::DefaultTickClock default_tick_clock_;
82 base::TimeTicks last_now_;
83
84 // If specified, used instead of |default_tick_clock_|.
85 base::TickClock* tick_clock_;
86
87 // If set, called when Stop() is called.
88 base::Closure stop_cb_;
89
90 DISALLOW_COPY_AND_ASSIGN(NullVideoSink);
91 };
92
93 } // namespace media
94
95 #endif // MEDIA_AUDIO_NULL_VIDEO_SINK_H_
OLDNEW
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/null_video_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698