| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "content/browser/media/capture/capture_resolution_chooser.h" | |
| 16 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" | 15 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" |
| 17 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/desktop_media_id.h" | 17 #include "content/public/browser/desktop_media_id.h" |
| 19 #include "content/public/browser/power_save_blocker.h" | 18 #include "content/public/browser/power_save_blocker.h" |
| 20 #include "media/base/video_util.h" | 19 #include "media/base/video_util.h" |
| 20 #include "media/capture/capture_resolution_chooser.h" |
| 21 #include "third_party/libyuv/include/libyuv/scale_argb.h" | 21 #include "third_party/libyuv/include/libyuv/scale_argb.h" |
| 22 #include "third_party/webrtc/modules/desktop_capture/cropping_window_capturer.h" | 22 #include "third_party/webrtc/modules/desktop_capture/cropping_window_capturer.h" |
| 23 #include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer
.h" | 23 #include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer
.h" |
| 24 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" | 24 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" |
| 25 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | 25 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 26 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 26 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 27 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" | 27 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" |
| 28 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 28 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // on the task_runner_ thread. | 93 // on the task_runner_ thread. |
| 94 scoped_ptr<Client> client_; | 94 scoped_ptr<Client> client_; |
| 95 | 95 |
| 96 // Requested video capture frame rate. | 96 // Requested video capture frame rate. |
| 97 float requested_frame_rate_; | 97 float requested_frame_rate_; |
| 98 | 98 |
| 99 // Size of frame most recently captured from the source. | 99 // Size of frame most recently captured from the source. |
| 100 webrtc::DesktopSize previous_frame_size_; | 100 webrtc::DesktopSize previous_frame_size_; |
| 101 | 101 |
| 102 // Determines the size of frames to deliver to the |client_|. | 102 // Determines the size of frames to deliver to the |client_|. |
| 103 scoped_ptr<CaptureResolutionChooser> resolution_chooser_; | 103 scoped_ptr<media::CaptureResolutionChooser> resolution_chooser_; |
| 104 | 104 |
| 105 // DesktopFrame into which captured frames are down-scaled and/or letterboxed, | 105 // DesktopFrame into which captured frames are down-scaled and/or letterboxed, |
| 106 // depending upon the caller's requested capture capabilities. If frames can | 106 // depending upon the caller's requested capture capabilities. If frames can |
| 107 // be returned to the caller directly then this is NULL. | 107 // be returned to the caller directly then this is NULL. |
| 108 scoped_ptr<webrtc::DesktopFrame> output_frame_; | 108 scoped_ptr<webrtc::DesktopFrame> output_frame_; |
| 109 | 109 |
| 110 // Timer used to capture the frame. | 110 // Timer used to capture the frame. |
| 111 base::OneShotTimer<Core> capture_timer_; | 111 base::OneShotTimer<Core> capture_timer_; |
| 112 | 112 |
| 113 // True when waiting for |desktop_capturer_| to capture current frame. | 113 // True when waiting for |desktop_capturer_| to capture current frame. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 scoped_ptr<Client> client) { | 153 scoped_ptr<Client> client) { |
| 154 DCHECK(task_runner_->BelongsToCurrentThread()); | 154 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 155 DCHECK_GT(params.requested_format.frame_size.GetArea(), 0); | 155 DCHECK_GT(params.requested_format.frame_size.GetArea(), 0); |
| 156 DCHECK_GT(params.requested_format.frame_rate, 0); | 156 DCHECK_GT(params.requested_format.frame_rate, 0); |
| 157 DCHECK(desktop_capturer_); | 157 DCHECK(desktop_capturer_); |
| 158 DCHECK(client.get()); | 158 DCHECK(client.get()); |
| 159 DCHECK(!client_.get()); | 159 DCHECK(!client_.get()); |
| 160 | 160 |
| 161 client_ = client.Pass(); | 161 client_ = client.Pass(); |
| 162 requested_frame_rate_ = params.requested_format.frame_rate; | 162 requested_frame_rate_ = params.requested_format.frame_rate; |
| 163 resolution_chooser_.reset(new CaptureResolutionChooser( | 163 resolution_chooser_.reset(new media::CaptureResolutionChooser( |
| 164 params.requested_format.frame_size, | 164 params.requested_format.frame_size, |
| 165 params.resolution_change_policy)); | 165 params.resolution_change_policy)); |
| 166 | 166 |
| 167 power_save_blocker_.reset( | 167 power_save_blocker_.reset( |
| 168 PowerSaveBlocker::Create( | 168 PowerSaveBlocker::Create( |
| 169 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 169 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 170 PowerSaveBlocker::kReasonOther, | 170 PowerSaveBlocker::kReasonOther, |
| 171 "DesktopCaptureDevice is running").release()); | 171 "DesktopCaptureDevice is running").release()); |
| 172 | 172 |
| 173 desktop_capturer_->Start(this); | 173 desktop_capturer_->Start(this); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 #else | 454 #else |
| 455 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 455 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; |
| 456 #endif | 456 #endif |
| 457 | 457 |
| 458 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 458 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); |
| 459 | 459 |
| 460 core_.reset(new Core(thread_.task_runner(), capturer.Pass(), type)); | 460 core_.reset(new Core(thread_.task_runner(), capturer.Pass(), type)); |
| 461 } | 461 } |
| 462 | 462 |
| 463 } // namespace content | 463 } // namespace content |
| OLD | NEW |