| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/capture/content/screen_capture_device_core.h" | 5 #include "media/capture/content/screen_capture_device_core.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 12 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 14 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 15 | 17 |
| 16 namespace media { | 18 namespace media { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 47 params.requested_format.pixel_storage != PIXEL_STORAGE_CPU) { | 49 params.requested_format.pixel_storage != PIXEL_STORAGE_CPU) { |
| 48 client->OnError( | 50 client->OnError( |
| 49 FROM_HERE, | 51 FROM_HERE, |
| 50 base::StringPrintf( | 52 base::StringPrintf( |
| 51 "unsupported format: %s", | 53 "unsupported format: %s", |
| 52 VideoCaptureFormat::ToString(params.requested_format).c_str())); | 54 VideoCaptureFormat::ToString(params.requested_format).c_str())); |
| 53 return; | 55 return; |
| 54 } | 56 } |
| 55 | 57 |
| 56 oracle_proxy_ = new ThreadSafeCaptureOracle( | 58 oracle_proxy_ = new ThreadSafeCaptureOracle( |
| 57 client.Pass(), params, capture_machine_->IsAutoThrottlingEnabled()); | 59 std::move(client), params, capture_machine_->IsAutoThrottlingEnabled()); |
| 58 | 60 |
| 59 capture_machine_->Start( | 61 capture_machine_->Start( |
| 60 oracle_proxy_, params, | 62 oracle_proxy_, params, |
| 61 base::Bind(&ScreenCaptureDeviceCore::CaptureStarted, AsWeakPtr())); | 63 base::Bind(&ScreenCaptureDeviceCore::CaptureStarted, AsWeakPtr())); |
| 62 | 64 |
| 63 TransitionStateTo(kCapturing); | 65 TransitionStateTo(kCapturing); |
| 64 } | 66 } |
| 65 | 67 |
| 66 void ScreenCaptureDeviceCore::StopAndDeAllocate() { | 68 void ScreenCaptureDeviceCore::StopAndDeAllocate() { |
| 67 DCHECK(thread_checker_.CalledOnValidThread()); | 69 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 } | 80 } |
| 79 | 81 |
| 80 void ScreenCaptureDeviceCore::CaptureStarted(bool success) { | 82 void ScreenCaptureDeviceCore::CaptureStarted(bool success) { |
| 81 DCHECK(thread_checker_.CalledOnValidThread()); | 83 DCHECK(thread_checker_.CalledOnValidThread()); |
| 82 if (!success) | 84 if (!success) |
| 83 Error(FROM_HERE, "Failed to start capture machine."); | 85 Error(FROM_HERE, "Failed to start capture machine."); |
| 84 } | 86 } |
| 85 | 87 |
| 86 ScreenCaptureDeviceCore::ScreenCaptureDeviceCore( | 88 ScreenCaptureDeviceCore::ScreenCaptureDeviceCore( |
| 87 scoped_ptr<VideoCaptureMachine> capture_machine) | 89 scoped_ptr<VideoCaptureMachine> capture_machine) |
| 88 : state_(kIdle), capture_machine_(capture_machine.Pass()) { | 90 : state_(kIdle), capture_machine_(std::move(capture_machine)) { |
| 89 DCHECK(capture_machine_.get()); | 91 DCHECK(capture_machine_.get()); |
| 90 } | 92 } |
| 91 | 93 |
| 92 ScreenCaptureDeviceCore::~ScreenCaptureDeviceCore() { | 94 ScreenCaptureDeviceCore::~ScreenCaptureDeviceCore() { |
| 93 DCHECK(thread_checker_.CalledOnValidThread()); | 95 DCHECK(thread_checker_.CalledOnValidThread()); |
| 94 DCHECK_NE(state_, kCapturing); | 96 DCHECK_NE(state_, kCapturing); |
| 95 if (capture_machine_) { | 97 if (capture_machine_) { |
| 96 capture_machine_->Stop( | 98 capture_machine_->Stop( |
| 97 base::Bind(&DeleteCaptureMachine, base::Passed(&capture_machine_))); | 99 base::Bind(&DeleteCaptureMachine, base::Passed(&capture_machine_))); |
| 98 } | 100 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 121 return; | 123 return; |
| 122 | 124 |
| 123 if (oracle_proxy_.get()) | 125 if (oracle_proxy_.get()) |
| 124 oracle_proxy_->ReportError(from_here, reason); | 126 oracle_proxy_->ReportError(from_here, reason); |
| 125 | 127 |
| 126 StopAndDeAllocate(); | 128 StopAndDeAllocate(); |
| 127 TransitionStateTo(kError); | 129 TransitionStateTo(kError); |
| 128 } | 130 } |
| 129 | 131 |
| 130 } // namespace media | 132 } // namespace media |
| OLD | NEW |