| 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> |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // True when waiting for |desktop_capturer_| to capture current frame. | 119 // True when waiting for |desktop_capturer_| to capture current frame. |
| 120 bool capture_in_progress_; | 120 bool capture_in_progress_; |
| 121 | 121 |
| 122 // True if the first capture call has returned. Used to log the first capture | 122 // True if the first capture call has returned. Used to log the first capture |
| 123 // result. | 123 // result. |
| 124 bool first_capture_returned_; | 124 bool first_capture_returned_; |
| 125 | 125 |
| 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. |
| 130 base::TimeTicks first_ref_time_; |
| 131 |
| 129 std::unique_ptr<webrtc::BasicDesktopFrame> black_frame_; | 132 std::unique_ptr<webrtc::BasicDesktopFrame> black_frame_; |
| 130 | 133 |
| 131 // 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 |
| 132 // screen from sleeping for the drive-by web. | 135 // screen from sleeping for the drive-by web. |
| 133 std::unique_ptr<PowerSaveBlocker> power_save_blocker_; | 136 std::unique_ptr<PowerSaveBlocker> power_save_blocker_; |
| 134 | 137 |
| 135 DISALLOW_COPY_AND_ASSIGN(Core); | 138 DISALLOW_COPY_AND_ASSIGN(Core); |
| 136 }; | 139 }; |
| 137 | 140 |
| 138 DesktopCaptureDevice::Core::Core( | 141 DesktopCaptureDevice::Core::Core( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 *frame, | 304 *frame, |
| 302 webrtc::DesktopVector(), | 305 webrtc::DesktopVector(), |
| 303 webrtc::DesktopRect::MakeSize(frame->size())); | 306 webrtc::DesktopRect::MakeSize(frame->size())); |
| 304 output_data = output_frame_->data(); | 307 output_data = output_frame_->data(); |
| 305 } else { | 308 } else { |
| 306 // If the captured frame matches the output size, we can return the pixel | 309 // If the captured frame matches the output size, we can return the pixel |
| 307 // data directly. | 310 // data directly. |
| 308 output_data = frame->data(); | 311 output_data = frame->data(); |
| 309 } | 312 } |
| 310 | 313 |
| 314 base::TimeTicks now = base::TimeTicks::Now(); |
| 315 if (first_ref_time_.is_null()) |
| 316 first_ref_time_ = now; |
| 311 client_->OnIncomingCapturedData( | 317 client_->OnIncomingCapturedData( |
| 312 output_data, output_bytes, | 318 output_data, output_bytes, |
| 313 media::VideoCaptureFormat( | 319 media::VideoCaptureFormat( |
| 314 gfx::Size(output_size.width(), output_size.height()), | 320 gfx::Size(output_size.width(), output_size.height()), |
| 315 requested_frame_rate_, media::PIXEL_FORMAT_ARGB), | 321 requested_frame_rate_, media::PIXEL_FORMAT_ARGB), |
| 316 0, base::TimeTicks::Now()); | 322 0, now, now - first_ref_time_); |
| 317 } | 323 } |
| 318 | 324 |
| 319 void DesktopCaptureDevice::Core::OnCaptureTimer() { | 325 void DesktopCaptureDevice::Core::OnCaptureTimer() { |
| 320 DCHECK(task_runner_->BelongsToCurrentThread()); | 326 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 321 | 327 |
| 322 if (!client_) | 328 if (!client_) |
| 323 return; | 329 return; |
| 324 | 330 |
| 325 CaptureFrameAndScheduleNext(); | 331 CaptureFrameAndScheduleNext(); |
| 326 } | 332 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 #else | 455 #else |
| 450 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 456 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; |
| 451 #endif | 457 #endif |
| 452 | 458 |
| 453 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 459 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); |
| 454 | 460 |
| 455 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); | 461 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); |
| 456 } | 462 } |
| 457 | 463 |
| 458 } // namespace content | 464 } // namespace content |
| OLD | NEW |