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

Side by Side Diff: media/blink/video_frame_compositor.h

Issue 1083383005: Connect the new video rendering path to the compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vra
Patch Set: Update LoginCustomFlags histogram. 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/video_renderer_sink.h ('k') | media/blink/video_frame_compositor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BLINK_VIDEO_FRAME_COMPOSITOR_H_ 5 #ifndef MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_
6 #define MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ 6 #define MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/time/tick_clock.h"
12 #include "cc/layers/video_frame_provider.h" 13 #include "cc/layers/video_frame_provider.h"
13 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
14 #include "media/base/video_renderer_sink.h" 15 #include "media/base/video_renderer_sink.h"
15 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
16 17
17 namespace media { 18 namespace media {
18 class VideoFrame; 19 class VideoFrame;
19 20
20 // VideoFrameCompositor acts as a bridge between the media and cc layers for 21 // VideoFrameCompositor acts as a bridge between the media and cc layers for
21 // rendering video frames. I.e. a media::VideoRenderer will talk to this class 22 // rendering video frames. I.e. a media::VideoRenderer will talk to this class
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 scoped_refptr<VideoFrame> GetCurrentFrame() override; 85 scoped_refptr<VideoFrame> GetCurrentFrame() override;
85 void PutCurrentFrame() override; 86 void PutCurrentFrame() override;
86 87
87 // VideoRendererSink implementation. These methods must be called from the 88 // VideoRendererSink implementation. These methods must be called from the
88 // same thread (typically the media thread). 89 // same thread (typically the media thread).
89 void Start(RenderCallback* callback) override; 90 void Start(RenderCallback* callback) override;
90 void Stop() override; 91 void Stop() override;
91 void PaintFrameUsingOldRenderingPath( 92 void PaintFrameUsingOldRenderingPath(
92 const scoped_refptr<VideoFrame>& frame) override; 93 const scoped_refptr<VideoFrame>& frame) override;
93 94
95 void set_tick_clock_for_testing(scoped_ptr<base::TickClock> tick_clock) {
96 tick_clock_ = tick_clock.Pass();
97 }
98
99 base::TimeDelta get_stale_frame_threshold_for_testing() const {
100 return stale_frame_threshold_;
101 }
102
103 void clear_current_frame_for_testing() { current_frame_ = nullptr; }
104
94 private: 105 private:
95 // Called on the compositor thread to start or stop rendering if rendering was 106 // Called on the compositor thread in response to Start() or Stop() calls;
96 // previously started or stopped before we had a |callback_|. 107 // must be used to change |rendering_| state.
97 void OnRendererStateUpdate(); 108 void OnRendererStateUpdate(bool new_state);
109
110 // Handles setting of |current_frame_| and fires |natural_size_changed_cb_|
111 // and |opacity_changed_cb_| when the frame properties changes. Will also
112 // call DidReceiveFrame() on |client_| if |notify_client_of_new_frames| is
113 // true and a new frame is encountered.
114 bool ProcessNewFrame(const scoped_refptr<VideoFrame>& frame,
115 bool notify_client_of_new_frames);
98 116
99 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 117 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
118 scoped_ptr<base::TickClock> tick_clock_;
100 119
101 // These callbacks are executed on the compositor thread. 120 // These callbacks are executed on the compositor thread.
102 base::Callback<void(gfx::Size)> natural_size_changed_cb_; 121 const base::Callback<void(gfx::Size)> natural_size_changed_cb_;
103 base::Callback<void(bool)> opacity_changed_cb_; 122 const base::Callback<void(bool)> opacity_changed_cb_;
123
124 base::TimeDelta stale_frame_threshold_;
104 125
105 // These values are only set and read on the compositor thread. 126 // These values are only set and read on the compositor thread.
106 cc::VideoFrameProvider::Client* client_; 127 cc::VideoFrameProvider::Client* client_;
107 scoped_refptr<VideoFrame> current_frame_; 128 scoped_refptr<VideoFrame> current_frame_;
129 bool rendering_;
130 bool rendered_last_frame_;
108 131
109 // These values are updated and read from the media and compositor threads. 132 // These values are updated and read from the media and compositor threads.
110 base::Lock lock_; 133 base::Lock lock_;
111 bool rendering_;
112 VideoRendererSink::RenderCallback* callback_; 134 VideoRendererSink::RenderCallback* callback_;
113 135
136 // These values are set on the compositor thread under lock and may be read
137 // from the media thread under lock.
138 base::TimeTicks last_frame_update_time_;
139 base::TimeDelta last_interval_;
140
114 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); 141 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor);
115 }; 142 };
116 143
117 } // namespace media 144 } // namespace media
118 145
119 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ 146 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « media/base/video_renderer_sink.h ('k') | media/blink/video_frame_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698