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

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 PauseRenderCallbacks(base::TimeTicks pause_until);
43
44 void set_tick_clock_for_testing(base::TickClock* tick_clock) {
45 tick_clock_ = tick_clock;
46 }
47
48 // Sets |stop_cb_|, which will be fired when Stop() is called.
49 void set_stop_cb(const base::Closure& stop_cb) {
50 stop_cb_ = stop_cb;
51 }
52
53 private:
54 // Task that periodically calls Render() to consume video data.
55 void CallRender();
56
57 const bool clockless_;
58 const base::TimeDelta interval_;
59 const NewFrameCB new_frame_cb_;
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
61
62 bool started_;
63 RenderCallback* callback_;
64
65 // Manages cancellation of periodic Render() callback task.
66 base::CancelableClosure cancelable_worker_;
67
68 // Used to determine when a new frame is received.
69 scoped_refptr<VideoFrame> last_frame_;
70
71 // Used to determine the interval given to RenderCallback::Render() as well as
72 // to maintain stable periodicity of callbacks.
73 base::TimeTicks current_render_time_;
74
75 // Used to suspend Render() callbacks to |callback_| for some time.
76 base::TimeTicks pause_end_time_;
77
78 // Allow for an injectable tick clock for testing.
79 base::DefaultTickClock default_tick_clock_;
80 base::TimeTicks last_now_;
81
82 // If specified, used instead of |default_tick_clock_|.
83 base::TickClock* tick_clock_;
84
85 // If set, called when Stop() is called.
86 base::Closure stop_cb_;
87
88 DISALLOW_COPY_AND_ASSIGN(NullVideoSink);
89 };
90
91 } // namespace media
92
93 #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