| 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/screen_capture_device_core.h" | 5 #include "media/capture/screen_capture_device_core.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void DeleteCaptureMachine( | 19 void DeleteCaptureMachine( |
| 20 scoped_ptr<VideoCaptureMachine> capture_machine) { | 20 scoped_ptr<VideoCaptureMachine> capture_machine) { |
| 21 capture_machine.reset(); | 21 capture_machine.reset(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 VideoCaptureMachine::VideoCaptureMachine() {} |
| 27 |
| 28 VideoCaptureMachine::~VideoCaptureMachine() {} |
| 29 |
| 30 bool VideoCaptureMachine::IsAutoThrottlingEnabled() const { |
| 31 return false; |
| 32 } |
| 33 |
| 26 void ScreenCaptureDeviceCore::AllocateAndStart( | 34 void ScreenCaptureDeviceCore::AllocateAndStart( |
| 27 const VideoCaptureParams& params, | 35 const VideoCaptureParams& params, |
| 28 scoped_ptr<VideoCaptureDevice::Client> client) { | 36 scoped_ptr<VideoCaptureDevice::Client> client) { |
| 29 DCHECK(thread_checker_.CalledOnValidThread()); | 37 DCHECK(thread_checker_.CalledOnValidThread()); |
| 30 | 38 |
| 31 if (state_ != kIdle) { | 39 if (state_ != kIdle) { |
| 32 DVLOG(1) << "Allocate() invoked when not in state Idle."; | 40 DVLOG(1) << "Allocate() invoked when not in state Idle."; |
| 33 return; | 41 return; |
| 34 } | 42 } |
| 35 | 43 |
| 36 if (!(params.requested_format.pixel_format == PIXEL_FORMAT_I420 && | 44 if (!(params.requested_format.pixel_format == PIXEL_FORMAT_I420 && |
| 37 params.requested_format.pixel_storage == PIXEL_STORAGE_CPU) && | 45 params.requested_format.pixel_storage == PIXEL_STORAGE_CPU) && |
| 38 !(params.requested_format.pixel_format == PIXEL_FORMAT_ARGB && | 46 !(params.requested_format.pixel_format == PIXEL_FORMAT_ARGB && |
| 39 params.requested_format.pixel_storage == PIXEL_STORAGE_TEXTURE)) { | 47 params.requested_format.pixel_storage == PIXEL_STORAGE_TEXTURE)) { |
| 40 const std::string error_msg = base::StringPrintf( | 48 const std::string error_msg = base::StringPrintf( |
| 41 "unsupported format: %s", | 49 "unsupported format: %s", |
| 42 VideoCaptureFormat::ToString(params.requested_format).c_str()); | 50 VideoCaptureFormat::ToString(params.requested_format).c_str()); |
| 43 DVLOG(1) << error_msg; | 51 DVLOG(1) << error_msg; |
| 44 client->OnError(error_msg); | 52 client->OnError(error_msg); |
| 45 return; | 53 return; |
| 46 } | 54 } |
| 47 | 55 |
| 48 oracle_proxy_ = new ThreadSafeCaptureOracle(client.Pass(), params); | 56 oracle_proxy_ = new ThreadSafeCaptureOracle( |
| 57 client.Pass(), params, capture_machine_->IsAutoThrottlingEnabled()); |
| 49 | 58 |
| 50 capture_machine_->Start( | 59 capture_machine_->Start( |
| 51 oracle_proxy_, | 60 oracle_proxy_, |
| 52 params, | 61 params, |
| 53 base::Bind(&ScreenCaptureDeviceCore::CaptureStarted, AsWeakPtr())); | 62 base::Bind(&ScreenCaptureDeviceCore::CaptureStarted, AsWeakPtr())); |
| 54 | 63 |
| 55 TransitionStateTo(kCapturing); | 64 TransitionStateTo(kCapturing); |
| 56 } | 65 } |
| 57 | 66 |
| 58 void ScreenCaptureDeviceCore::StopAndDeAllocate() { | 67 void ScreenCaptureDeviceCore::StopAndDeAllocate() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return; | 125 return; |
| 117 | 126 |
| 118 if (oracle_proxy_.get()) | 127 if (oracle_proxy_.get()) |
| 119 oracle_proxy_->ReportError(reason); | 128 oracle_proxy_->ReportError(reason); |
| 120 | 129 |
| 121 StopAndDeAllocate(); | 130 StopAndDeAllocate(); |
| 122 TransitionStateTo(kError); | 131 TransitionStateTo(kError); |
| 123 } | 132 } |
| 124 | 133 |
| 125 } // namespace media | 134 } // namespace media |
| OLD | NEW |