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

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

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/media/capture/desktop_capture_device.h" 5 #include "content/browser/media/capture/desktop_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/timer/timer.h" 20 #include "base/timer/timer.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" 22 #include "content/browser/media/capture/desktop_capture_device_uma_types.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/desktop_media_id.h" 24 #include "content/public/browser/desktop_media_id.h"
25 #include "device/capture/content/capture_resolution_chooser.h"
25 #include "device/power_save_blocker/power_save_blocker.h" 26 #include "device/power_save_blocker/power_save_blocker.h"
26 #include "media/base/video_util.h" 27 #include "media/base/video_util.h"
27 #include "media/capture/content/capture_resolution_chooser.h"
28 #include "third_party/libyuv/include/libyuv/scale_argb.h" 28 #include "third_party/libyuv/include/libyuv/scale_argb.h"
29 #include "third_party/webrtc/modules/desktop_capture/cropping_window_capturer.h" 29 #include "third_party/webrtc/modules/desktop_capture/cropping_window_capturer.h"
30 #include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer .h" 30 #include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer .h"
31 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" 31 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
32 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 32 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
33 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 33 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
34 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" 34 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
35 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" 35 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
36 36
37 namespace content { 37 namespace content {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // on the task_runner_ thread. 100 // on the task_runner_ thread.
101 std::unique_ptr<Client> client_; 101 std::unique_ptr<Client> client_;
102 102
103 // Requested video capture frame rate. 103 // Requested video capture frame rate.
104 float requested_frame_rate_; 104 float requested_frame_rate_;
105 105
106 // Size of frame most recently captured from the source. 106 // Size of frame most recently captured from the source.
107 webrtc::DesktopSize previous_frame_size_; 107 webrtc::DesktopSize previous_frame_size_;
108 108
109 // Determines the size of frames to deliver to the |client_|. 109 // Determines the size of frames to deliver to the |client_|.
110 std::unique_ptr<media::CaptureResolutionChooser> resolution_chooser_; 110 std::unique_ptr<device::CaptureResolutionChooser> resolution_chooser_;
111 111
112 // DesktopFrame into which captured frames are down-scaled and/or letterboxed, 112 // DesktopFrame into which captured frames are down-scaled and/or letterboxed,
113 // depending upon the caller's requested capture capabilities. If frames can 113 // depending upon the caller's requested capture capabilities. If frames can
114 // be returned to the caller directly then this is NULL. 114 // be returned to the caller directly then this is NULL.
115 std::unique_ptr<webrtc::DesktopFrame> output_frame_; 115 std::unique_ptr<webrtc::DesktopFrame> output_frame_;
116 116
117 // Timer used to capture the frame. 117 // Timer used to capture the frame.
118 base::OneShotTimer capture_timer_; 118 base::OneShotTimer capture_timer_;
119 119
120 // True when waiting for |desktop_capturer_| to capture current frame. 120 // True when waiting for |desktop_capturer_| to capture current frame.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 std::unique_ptr<Client> client) { 162 std::unique_ptr<Client> client) {
163 DCHECK(task_runner_->BelongsToCurrentThread()); 163 DCHECK(task_runner_->BelongsToCurrentThread());
164 DCHECK_GT(params.requested_format.frame_size.GetArea(), 0); 164 DCHECK_GT(params.requested_format.frame_size.GetArea(), 0);
165 DCHECK_GT(params.requested_format.frame_rate, 0); 165 DCHECK_GT(params.requested_format.frame_rate, 0);
166 DCHECK(desktop_capturer_); 166 DCHECK(desktop_capturer_);
167 DCHECK(client); 167 DCHECK(client);
168 DCHECK(!client_); 168 DCHECK(!client_);
169 169
170 client_ = std::move(client); 170 client_ = std::move(client);
171 requested_frame_rate_ = params.requested_format.frame_rate; 171 requested_frame_rate_ = params.requested_format.frame_rate;
172 resolution_chooser_.reset(new media::CaptureResolutionChooser( 172 resolution_chooser_.reset(new device::CaptureResolutionChooser(
173 params.requested_format.frame_size, 173 params.requested_format.frame_size,
174 params.resolution_change_policy)); 174 params.resolution_change_policy));
175 175
176 power_save_blocker_.reset(new device::PowerSaveBlocker( 176 power_save_blocker_.reset(new device::PowerSaveBlocker(
177 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, 177 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
178 device::PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running", 178 device::PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running",
179 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), 179 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
180 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); 180 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
181 181
182 desktop_capturer_->Start(this); 182 desktop_capturer_->Start(this);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 capture_in_progress_ = true; 351 capture_in_progress_ = true;
352 desktop_capturer_->Capture(webrtc::DesktopRegion()); 352 desktop_capturer_->Capture(webrtc::DesktopRegion());
353 353
354 // Currently only synchronous implementations of DesktopCapturer are 354 // Currently only synchronous implementations of DesktopCapturer are
355 // supported. 355 // supported.
356 DCHECK(!capture_in_progress_); 356 DCHECK(!capture_in_progress_);
357 } 357 }
358 358
359 // static 359 // static
360 std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create( 360 std::unique_ptr<device::VideoCaptureDevice> DesktopCaptureDevice::Create(
361 const DesktopMediaID& source) { 361 const DesktopMediaID& source) {
362 webrtc::DesktopCaptureOptions options = 362 webrtc::DesktopCaptureOptions options =
363 webrtc::DesktopCaptureOptions::CreateDefault(); 363 webrtc::DesktopCaptureOptions::CreateDefault();
364 // Leave desktop effects enabled during WebRTC captures. 364 // Leave desktop effects enabled during WebRTC captures.
365 options.set_disable_effects(false); 365 options.set_disable_effects(false);
366 366
367 #if defined(OS_WIN) 367 #if defined(OS_WIN)
368 options.set_allow_use_magnification_api(true); 368 options.set_allow_use_magnification_api(true);
369 #endif 369 #endif
370 370
(...skipping 23 matching lines...) Expand all
394 webrtc::MouseCursorMonitor::CreateForWindow(options, 394 webrtc::MouseCursorMonitor::CreateForWindow(options,
395 source.id))); 395 source.id)));
396 IncrementDesktopCaptureCounter(WINDOW_CAPTURER_CREATED); 396 IncrementDesktopCaptureCounter(WINDOW_CAPTURER_CREATED);
397 } 397 }
398 break; 398 break;
399 } 399 }
400 400
401 default: { NOTREACHED(); } 401 default: { NOTREACHED(); }
402 } 402 }
403 403
404 std::unique_ptr<media::VideoCaptureDevice> result; 404 std::unique_ptr<device::VideoCaptureDevice> result;
405 if (capturer) 405 if (capturer)
406 result.reset(new DesktopCaptureDevice(std::move(capturer), source.type)); 406 result.reset(new DesktopCaptureDevice(std::move(capturer), source.type));
407 407
408 return result; 408 return result;
409 } 409 }
410 410
411 DesktopCaptureDevice::~DesktopCaptureDevice() { 411 DesktopCaptureDevice::~DesktopCaptureDevice() {
412 DCHECK(!core_); 412 DCHECK(!core_);
413 } 413 }
414 414
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 #else 450 #else
451 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; 451 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT;
452 #endif 452 #endif
453 453
454 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); 454 thread_.StartWithOptions(base::Thread::Options(thread_type, 0));
455 455
456 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); 456 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type));
457 } 457 }
458 458
459 } // namespace content 459 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/capture/desktop_capture_device.h ('k') | content/browser/media/capture/desktop_capture_device_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698