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

Side by Side Diff: content/browser/renderer_host/media/desktop_capture_device_aura.cc

Issue 101843005: Convert video capture pipline to base::TimeTicks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 9890509b Rebase, Windows compile fixes Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/browser/renderer_host/media/desktop_capture_device_aura.h" 5 #include "content/browser/renderer_host/media/desktop_capture_device_aura.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "cc/output/copy_output_request.h" 9 #include "cc/output/copy_output_request.h"
10 #include "cc/output/copy_output_result.h" 10 #include "cc/output/copy_output_result.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Captures a frame. 121 // Captures a frame.
122 // |dirty| is false for timer polls and true for compositor updates. 122 // |dirty| is false for timer polls and true for compositor updates.
123 void Capture(bool dirty); 123 void Capture(bool dirty);
124 124
125 // Update capture size. Must be called on the UI thread. 125 // Update capture size. Must be called on the UI thread.
126 void UpdateCaptureSize(); 126 void UpdateCaptureSize();
127 127
128 // Response callback for cc::Layer::RequestCopyOfOutput(). 128 // Response callback for cc::Layer::RequestCopyOfOutput().
129 void DidCopyOutput( 129 void DidCopyOutput(
130 scoped_refptr<media::VideoFrame> video_frame, 130 scoped_refptr<media::VideoFrame> video_frame,
131 base::Time start_time, 131 base::TimeTicks start_time,
132 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, 132 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
133 scoped_ptr<cc::CopyOutputResult> result); 133 scoped_ptr<cc::CopyOutputResult> result);
134 134
135 // Helper function to update cursor state. 135 // Helper function to update cursor state.
136 // |region_in_frame| defines the desktop bound in the captured frame. 136 // |region_in_frame| defines the desktop bound in the captured frame.
137 // Returns the current cursor position in captured frame. 137 // Returns the current cursor position in captured frame.
138 gfx::Point UpdateCursorState(const gfx::Rect& region_in_frame); 138 gfx::Point UpdateCursorState(const gfx::Rect& region_in_frame);
139 139
140 // Clears cursor state. 140 // Clears cursor state.
141 void ClearCursorState(); 141 void ClearCursorState();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 void DesktopVideoCaptureMachine::Capture(bool dirty) { 248 void DesktopVideoCaptureMachine::Capture(bool dirty) {
249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
250 250
251 // Do not capture if the desktop layer is already destroyed. 251 // Do not capture if the desktop layer is already destroyed.
252 if (!desktop_layer_) 252 if (!desktop_layer_)
253 return; 253 return;
254 254
255 scoped_refptr<media::VideoFrame> frame; 255 scoped_refptr<media::VideoFrame> frame;
256 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb; 256 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb;
257 257
258 const base::Time start_time = base::Time::Now(); 258 const base::TimeTicks start_time = base::TimeTicks::Now();
259 const VideoCaptureOracle::Event event = 259 const VideoCaptureOracle::Event event =
260 dirty ? VideoCaptureOracle::kCompositorUpdate 260 dirty ? VideoCaptureOracle::kCompositorUpdate
261 : VideoCaptureOracle::kTimerPoll; 261 : VideoCaptureOracle::kTimerPoll;
262 if (oracle_proxy_->ObserveEventAndDecideCapture( 262 if (oracle_proxy_->ObserveEventAndDecideCapture(
263 event, start_time, &frame, &capture_frame_cb)) { 263 event, start_time, &frame, &capture_frame_cb)) {
264 scoped_ptr<cc::CopyOutputRequest> request = 264 scoped_ptr<cc::CopyOutputRequest> request =
265 cc::CopyOutputRequest::CreateRequest( 265 cc::CopyOutputRequest::CreateRequest(
266 base::Bind(&DesktopVideoCaptureMachine::DidCopyOutput, 266 base::Bind(&DesktopVideoCaptureMachine::DidCopyOutput,
267 AsWeakPtr(), frame, start_time, capture_frame_cb)); 267 AsWeakPtr(), frame, start_time, capture_frame_cb));
268 gfx::Rect window_rect = 268 gfx::Rect window_rect =
269 ui::ConvertRectToPixel(desktop_window_->layer(), 269 ui::ConvertRectToPixel(desktop_window_->layer(),
270 gfx::Rect(desktop_window_->bounds().width(), 270 gfx::Rect(desktop_window_->bounds().width(),
271 desktop_window_->bounds().height())); 271 desktop_window_->bounds().height()));
272 request->set_area(window_rect); 272 request->set_area(window_rect);
273 desktop_layer_->RequestCopyOfOutput(request.Pass()); 273 desktop_layer_->RequestCopyOfOutput(request.Pass());
274 } 274 }
275 } 275 }
276 276
277 void CopyOutputFinishedForVideo( 277 void CopyOutputFinishedForVideo(
278 base::Time start_time, 278 base::TimeTicks start_time,
279 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, 279 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
280 const scoped_refptr<media::VideoFrame>& target, 280 const scoped_refptr<media::VideoFrame>& target,
281 const SkBitmap& cursor_bitmap, 281 const SkBitmap& cursor_bitmap,
282 const gfx::Point& cursor_position, 282 const gfx::Point& cursor_position,
283 scoped_ptr<cc::SingleReleaseCallback> release_callback, 283 scoped_ptr<cc::SingleReleaseCallback> release_callback,
284 bool result) { 284 bool result) {
285 if (!cursor_bitmap.isNull()) 285 if (!cursor_bitmap.isNull())
286 RenderCursorOnVideoFrame(target, cursor_bitmap, cursor_position); 286 RenderCursorOnVideoFrame(target, cursor_bitmap, cursor_position);
287 release_callback->Run(0, false); 287 release_callback->Run(0, false);
288 capture_frame_cb.Run(start_time, result); 288 capture_frame_cb.Run(start_time, result);
289 } 289 }
290 290
291 void DesktopVideoCaptureMachine::DidCopyOutput( 291 void DesktopVideoCaptureMachine::DidCopyOutput(
292 scoped_refptr<media::VideoFrame> video_frame, 292 scoped_refptr<media::VideoFrame> video_frame,
293 base::Time start_time, 293 base::TimeTicks start_time,
294 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, 294 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
295 scoped_ptr<cc::CopyOutputResult> result) { 295 scoped_ptr<cc::CopyOutputResult> result) {
296 if (result->IsEmpty() || result->size().IsEmpty() || !desktop_layer_) 296 if (result->IsEmpty() || result->size().IsEmpty() || !desktop_layer_)
297 return; 297 return;
298 298
299 // Compute the dest size we want after the letterboxing resize. Make the 299 // Compute the dest size we want after the letterboxing resize. Make the
300 // coordinates and sizes even because we letterbox in YUV space 300 // coordinates and sizes even because we letterbox in YUV space
301 // (see CopyRGBToVideoFrame). They need to be even for the UV samples to 301 // (see CopyRGBToVideoFrame). They need to be even for the UV samples to
302 // line up correctly. 302 // line up correctly.
303 // The video frame's coded_size() and the result's size() are both physical 303 // The video frame's coded_size() and the result's size() are both physical
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 scoped_ptr<Client> client) { 434 scoped_ptr<Client> client) {
435 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); 435 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString();
436 impl_->AllocateAndStart(params, client.Pass()); 436 impl_->AllocateAndStart(params, client.Pass());
437 } 437 }
438 438
439 void DesktopCaptureDeviceAura::StopAndDeAllocate() { 439 void DesktopCaptureDeviceAura::StopAndDeAllocate() {
440 impl_->StopAndDeAllocate(); 440 impl_->StopAndDeAllocate();
441 } 441 }
442 442
443 } // namespace content 443 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698