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

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

Issue 2631633003: [Video] Only start tracking foreground time if the video was resumed. (Closed)
Patch Set: Split the histogram into paused and disabled track Created 3 years, 11 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 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 <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/optional.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "base/time/tick_clock.h" 16 #include "base/time/tick_clock.h"
16 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
17 #include "cc/layers/video_frame_provider.h" 18 #include "cc/layers/video_frame_provider.h"
18 #include "media/base/video_renderer_sink.h" 19 #include "media/base/video_renderer_sink.h"
19 #include "media/blink/media_blink_export.h" 20 #include "media/blink/media_blink_export.h"
20 #include "ui/gfx/geometry/size.h" 21 #include "ui/gfx/geometry/size.h"
21 22
22 namespace base { 23 namespace base {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // does not receive a |client_|. In this case, frame acquisition is driven by 97 // does not receive a |client_|. In this case, frame acquisition is driven by
97 // the frequency of canvas or WebGL paints requested via JavaScript. 98 // the frequency of canvas or WebGL paints requested via JavaScript.
98 scoped_refptr<VideoFrame> GetCurrentFrameAndUpdateIfStale(); 99 scoped_refptr<VideoFrame> GetCurrentFrameAndUpdateIfStale();
99 100
100 // Returns the timestamp of the current (possibly stale) frame, or 101 // Returns the timestamp of the current (possibly stale) frame, or
101 // base::TimeDelta() if there is no current frame. This method may be called 102 // base::TimeDelta() if there is no current frame. This method may be called
102 // from the media thread as long as the VFC is stopped. (Assuming that 103 // from the media thread as long as the VFC is stopped. (Assuming that
103 // PaintSingleFrame() is not also called while stopped.) 104 // PaintSingleFrame() is not also called while stopped.)
104 base::TimeDelta GetCurrentFrameTimestamp() const; 105 base::TimeDelta GetCurrentFrameTimestamp() const;
105 106
106 // Called when the media player is brought to the foreground. 107 // Enumerates the ways background video could be optimized.
108 enum class BackgroundVideoOptimization { Paused, DisabledTrack };
109
110 // Called when the media player is brought to the foreground and was or could
111 // be optimized when in the background.
107 // Used to record the time it takes to process the first frame after that. 112 // Used to record the time it takes to process the first frame after that.
108 // Must be called on the compositor thread. 113 // Must be called on the compositor thread.
109 void SetForegroundTime(base::TimeTicks when); 114 void SetForegroundTime(base::TimeTicks when,
115 BackgroundVideoOptimization optimization);
110 116
111 void set_tick_clock_for_testing(std::unique_ptr<base::TickClock> tick_clock) { 117 void set_tick_clock_for_testing(std::unique_ptr<base::TickClock> tick_clock) {
112 tick_clock_ = std::move(tick_clock); 118 tick_clock_ = std::move(tick_clock);
113 } 119 }
114 120
115 void clear_current_frame_for_testing() { current_frame_ = nullptr; } 121 void clear_current_frame_for_testing() { current_frame_ = nullptr; }
116 122
117 // Enables or disables background rendering. If |enabled|, |timeout| is the 123 // Enables or disables background rendering. If |enabled|, |timeout| is the
118 // amount of time to wait after the last Render() call before starting the 124 // amount of time to wait after the last Render() call before starting the
119 // background rendering mode. Note, this can not disable the background 125 // background rendering mode. Note, this can not disable the background
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 162
157 // These values are only set and read on the compositor thread. 163 // These values are only set and read on the compositor thread.
158 cc::VideoFrameProvider::Client* client_; 164 cc::VideoFrameProvider::Client* client_;
159 bool rendering_; 165 bool rendering_;
160 bool rendered_last_frame_; 166 bool rendered_last_frame_;
161 bool is_background_rendering_; 167 bool is_background_rendering_;
162 bool new_background_frame_; 168 bool new_background_frame_;
163 base::TimeDelta last_interval_; 169 base::TimeDelta last_interval_;
164 base::TimeTicks last_background_render_; 170 base::TimeTicks last_background_render_;
165 base::TimeTicks foreground_time_; 171 base::TimeTicks foreground_time_;
172 base::Optional<BackgroundVideoOptimization> background_video_optimization_;
166 173
167 // These values are set on the compositor thread, but also read on the media 174 // These values are set on the compositor thread, but also read on the media
168 // thread when the VFC is stopped. 175 // thread when the VFC is stopped.
169 scoped_refptr<VideoFrame> current_frame_; 176 scoped_refptr<VideoFrame> current_frame_;
170 177
171 // These values are updated and read from the media and compositor threads. 178 // These values are updated and read from the media and compositor threads.
172 base::Lock callback_lock_; 179 base::Lock callback_lock_;
173 VideoRendererSink::RenderCallback* callback_; 180 VideoRendererSink::RenderCallback* callback_;
174 181
175 // AutoOpenCloseEvent for begin/end events. 182 // AutoOpenCloseEvent for begin/end events.
176 std::unique_ptr<base::trace_event::AutoOpenCloseEvent> auto_open_close_; 183 std::unique_ptr<base::trace_event::AutoOpenCloseEvent> auto_open_close_;
177 184
178 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); 185 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor);
179 }; 186 };
180 187
181 } // namespace media 188 } // namespace media
182 189
183 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ 190 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « no previous file | media/blink/video_frame_compositor.cc » ('j') | media/blink/video_frame_compositor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698