| OLD | NEW | 
|---|
| 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/browser/power_save_blocker_factory.h" | 
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" | 
| 24 #include "content/public/browser/desktop_media_id.h" | 25 #include "content/public/browser/desktop_media_id.h" | 
| 25 #include "content/public/browser/power_save_blocker_factory.h" |  | 
| 26 #include "media/base/video_util.h" | 26 #include "media/base/video_util.h" | 
| 27 #include "media/capture/content/capture_resolution_chooser.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" | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 126   // The type of the capturer. | 126   // The type of the capturer. | 
| 127   DesktopMediaID::Type capturer_type_; | 127   DesktopMediaID::Type capturer_type_; | 
| 128 | 128 | 
| 129   // The system time when we receive the first frame. | 129   // The system time when we receive the first frame. | 
| 130   base::TimeTicks first_ref_time_; | 130   base::TimeTicks first_ref_time_; | 
| 131 | 131 | 
| 132   std::unique_ptr<webrtc::BasicDesktopFrame> black_frame_; | 132   std::unique_ptr<webrtc::BasicDesktopFrame> black_frame_; | 
| 133 | 133 | 
| 134   // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the | 134   // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the | 
| 135   // screen from sleeping for the drive-by web. | 135   // screen from sleeping for the drive-by web. | 
| 136   std::unique_ptr<PowerSaveBlocker> power_save_blocker_; | 136   std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; | 
| 137 | 137 | 
| 138   DISALLOW_COPY_AND_ASSIGN(Core); | 138   DISALLOW_COPY_AND_ASSIGN(Core); | 
| 139 }; | 139 }; | 
| 140 | 140 | 
| 141 DesktopCaptureDevice::Core::Core( | 141 DesktopCaptureDevice::Core::Core( | 
| 142     scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 142     scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 
| 143     std::unique_ptr<webrtc::DesktopCapturer> capturer, | 143     std::unique_ptr<webrtc::DesktopCapturer> capturer, | 
| 144     DesktopMediaID::Type type) | 144     DesktopMediaID::Type type) | 
| 145     : task_runner_(task_runner), | 145     : task_runner_(task_runner), | 
| 146       desktop_capturer_(std::move(capturer)), | 146       desktop_capturer_(std::move(capturer)), | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 167   DCHECK(!client_); | 167   DCHECK(!client_); | 
| 168 | 168 | 
| 169   client_ = std::move(client); | 169   client_ = std::move(client); | 
| 170   requested_frame_rate_ = params.requested_format.frame_rate; | 170   requested_frame_rate_ = params.requested_format.frame_rate; | 
| 171   resolution_chooser_.reset(new media::CaptureResolutionChooser( | 171   resolution_chooser_.reset(new media::CaptureResolutionChooser( | 
| 172       params.requested_format.frame_size, | 172       params.requested_format.frame_size, | 
| 173       params.resolution_change_policy)); | 173       params.resolution_change_policy)); | 
| 174 | 174 | 
| 175   power_save_blocker_.reset( | 175   power_save_blocker_.reset( | 
| 176       CreatePowerSaveBlocker( | 176       CreatePowerSaveBlocker( | 
| 177           PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 177           device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 
| 178           PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running") | 178           device::PowerSaveBlocker::kReasonOther, | 
|  | 179           "DesktopCaptureDevice is running") | 
| 179           .release()); | 180           .release()); | 
| 180 | 181 | 
| 181   desktop_capturer_->Start(this); | 182   desktop_capturer_->Start(this); | 
| 182 | 183 | 
| 183   CaptureFrameAndScheduleNext(); | 184   CaptureFrameAndScheduleNext(); | 
| 184 } | 185 } | 
| 185 | 186 | 
| 186 void DesktopCaptureDevice::Core::SetNotificationWindowId( | 187 void DesktopCaptureDevice::Core::SetNotificationWindowId( | 
| 187     gfx::NativeViewId window_id) { | 188     gfx::NativeViewId window_id) { | 
| 188   DCHECK(task_runner_->BelongsToCurrentThread()); | 189   DCHECK(task_runner_->BelongsToCurrentThread()); | 
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 455 #else | 456 #else | 
| 456   base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 457   base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 
| 457 #endif | 458 #endif | 
| 458 | 459 | 
| 459   thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 460   thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 
| 460 | 461 | 
| 461   core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); | 462   core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); | 
| 462 } | 463 } | 
| 463 | 464 | 
| 464 }  // namespace content | 465 }  // namespace content | 
| OLD | NEW | 
|---|