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

Side by Side Diff: content/browser/media/capture/web_contents_video_capture_device.cc

Issue 2490153003: [Mojo Video Capture] Replace const scoped_refptr<T>& with scoped_refptr<T> and use std::move (Closed)
Patch Set: fix bots Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implementation notes: This needs to work on a variety of hardware 5 // Implementation notes: This needs to work on a variety of hardware
6 // configurations where the speed of the CPU and GPU greatly affect overall 6 // configurations where the speed of the CPU and GPU greatly affect overall
7 // performance. Spanning several threads, the process of capturing has been 7 // performance. Spanning several threads, the process of capturing has been
8 // split up into four conceptual stages: 8 // split up into four conceptual stages:
9 // 9 //
10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's 10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const gfx::Rect& damage_rect, 129 const gfx::Rect& damage_rect,
130 base::TimeTicks present_time, 130 base::TimeTicks present_time,
131 scoped_refptr<media::VideoFrame>* storage, 131 scoped_refptr<media::VideoFrame>* storage,
132 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback* 132 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback*
133 deliver_frame_cb) override; 133 deliver_frame_cb) override;
134 134
135 static void DidCaptureFrame( 135 static void DidCaptureFrame(
136 base::WeakPtr<FrameSubscriber> frame_subscriber_, 136 base::WeakPtr<FrameSubscriber> frame_subscriber_,
137 const media::ThreadSafeCaptureOracle::CaptureFrameCallback& 137 const media::ThreadSafeCaptureOracle::CaptureFrameCallback&
138 capture_frame_cb, 138 capture_frame_cb,
139 const scoped_refptr<media::VideoFrame>& frame, 139 scoped_refptr<media::VideoFrame> frame,
140 base::TimeTicks timestamp, 140 base::TimeTicks timestamp,
141 const gfx::Rect& region_in_frame, 141 const gfx::Rect& region_in_frame,
142 bool success); 142 bool success);
143 143
144 bool IsUserInteractingWithContent(); 144 bool IsUserInteractingWithContent();
145 145
146 private: 146 private:
147 const media::VideoCaptureOracle::Event event_type_; 147 const media::VideoCaptureOracle::Event event_type_;
148 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_; 148 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_;
149 // We need a weak pointer since FrameSubscriber is owned externally and 149 // We need a weak pointer since FrameSubscriber is owned externally and
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 *deliver_frame_cb = 351 *deliver_frame_cb =
352 base::Bind(&FrameSubscriber::DidCaptureFrame, 352 base::Bind(&FrameSubscriber::DidCaptureFrame,
353 weak_ptr_factory_.GetWeakPtr(), capture_frame_cb, *storage); 353 weak_ptr_factory_.GetWeakPtr(), capture_frame_cb, *storage);
354 return oracle_decision; 354 return oracle_decision;
355 } 355 }
356 356
357 void FrameSubscriber::DidCaptureFrame( 357 void FrameSubscriber::DidCaptureFrame(
358 base::WeakPtr<FrameSubscriber> frame_subscriber_, 358 base::WeakPtr<FrameSubscriber> frame_subscriber_,
359 const media::ThreadSafeCaptureOracle::CaptureFrameCallback& 359 const media::ThreadSafeCaptureOracle::CaptureFrameCallback&
360 capture_frame_cb, 360 capture_frame_cb,
361 const scoped_refptr<media::VideoFrame>& frame, 361 scoped_refptr<media::VideoFrame> frame,
362 base::TimeTicks timestamp, 362 base::TimeTicks timestamp,
363 const gfx::Rect& region_in_frame, 363 const gfx::Rect& region_in_frame,
364 bool success) { 364 bool success) {
365 // We can get a callback in the shutdown sequence for the browser main loop 365 // We can get a callback in the shutdown sequence for the browser main loop
366 // and this can result in a DCHECK failure. Avoid this by doing DCHECK only 366 // and this can result in a DCHECK failure. Avoid this by doing DCHECK only
367 // on success. 367 // on success.
368 if (success) { 368 if (success) {
369 DCHECK_CURRENTLY_ON(BrowserThread::UI); 369 DCHECK_CURRENTLY_ON(BrowserThread::UI);
370 // TODO(isheriff): Unclear if taking a snapshot of cursor here affects user 370 // TODO(isheriff): Unclear if taking a snapshot of cursor here affects user
371 // experience in any particular scenarios. Doing it prior to capture may 371 // experience in any particular scenarios. Doing it prior to capture may
372 // require evaluating region_in_frame in this file. 372 // require evaluating region_in_frame in this file.
373 if (frame_subscriber_ && frame_subscriber_->cursor_renderer_) { 373 if (frame_subscriber_ && frame_subscriber_->cursor_renderer_) {
374 CursorRenderer* cursor_renderer = 374 CursorRenderer* cursor_renderer =
375 frame_subscriber_->cursor_renderer_.get(); 375 frame_subscriber_->cursor_renderer_.get();
376 if (cursor_renderer->SnapshotCursorState(region_in_frame)) 376 if (cursor_renderer->SnapshotCursorState(region_in_frame))
377 cursor_renderer->RenderOnVideoFrame(frame); 377 cursor_renderer->RenderOnVideoFrame(frame);
378 frame->metadata()->SetBoolean( 378 frame->metadata()->SetBoolean(
379 media::VideoFrameMetadata::INTERACTIVE_CONTENT, 379 media::VideoFrameMetadata::INTERACTIVE_CONTENT,
380 frame_subscriber_->IsUserInteractingWithContent()); 380 frame_subscriber_->IsUserInteractingWithContent());
381 } 381 }
382 } 382 }
383 capture_frame_cb.Run(frame, timestamp, success); 383 capture_frame_cb.Run(std::move(frame), timestamp, success);
384 } 384 }
385 385
386 bool FrameSubscriber::IsUserInteractingWithContent() { 386 bool FrameSubscriber::IsUserInteractingWithContent() {
387 bool interactive_mode = false; 387 bool interactive_mode = false;
388 bool ui_activity = false; 388 bool ui_activity = false;
389 if (window_activity_tracker_) { 389 if (window_activity_tracker_) {
390 ui_activity = window_activity_tracker_->IsUiInteractionActive(); 390 ui_activity = window_activity_tracker_->IsUiInteractionActive();
391 } 391 }
392 if (cursor_renderer_) { 392 if (cursor_renderer_) {
393 bool animation_active = 393 bool animation_active =
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 951
952 void WebContentsVideoCaptureDevice::Resume() { 952 void WebContentsVideoCaptureDevice::Resume() {
953 core_->Resume(); 953 core_->Resume();
954 } 954 }
955 955
956 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { 956 void WebContentsVideoCaptureDevice::StopAndDeAllocate() {
957 core_->StopAndDeAllocate(); 957 core_->StopAndDeAllocate();
958 } 958 }
959 959
960 } // namespace content 960 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698