| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/video/capture/mac/video_capture_device_mac.h" | 5 #include "media/video/capture/mac/video_capture_device_mac.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/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 capture_device = NULL; | 118 capture_device = NULL; |
| 119 } | 119 } |
| 120 return capture_device; | 120 return capture_device; |
| 121 } | 121 } |
| 122 | 122 |
| 123 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) | 123 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) |
| 124 : device_name_(device_name), | 124 : device_name_(device_name), |
| 125 tried_to_square_pixels_(false), | 125 tried_to_square_pixels_(false), |
| 126 task_runner_(base::MessageLoopProxy::current()), | 126 task_runner_(base::MessageLoopProxy::current()), |
| 127 state_(kNotInitialized), | 127 state_(kNotInitialized), |
| 128 weak_factory_(this), | 128 capture_device_(nil), |
| 129 weak_this_(weak_factory_.GetWeakPtr()), | 129 weak_factory_(this) { |
| 130 capture_device_(nil) { | |
| 131 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported(); | 130 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { | 133 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { |
| 135 DCHECK(task_runner_->BelongsToCurrentThread()); | 134 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 136 [capture_device_ release]; | 135 [capture_device_ release]; |
| 137 } | 136 } |
| 138 | 137 |
| 139 void VideoCaptureDeviceMac::AllocateAndStart( | 138 void VideoCaptureDeviceMac::AllocateAndStart( |
| 140 const VideoCaptureParams& params, | 139 const VideoCaptureParams& params, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 305 |
| 307 client_->OnIncomingCapturedData(video_frame, | 306 client_->OnIncomingCapturedData(video_frame, |
| 308 video_frame_length, | 307 video_frame_length, |
| 309 capture_format_, | 308 capture_format_, |
| 310 0, | 309 0, |
| 311 base::TimeTicks::Now()); | 310 base::TimeTicks::Now()); |
| 312 } | 311 } |
| 313 | 312 |
| 314 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { | 313 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { |
| 315 task_runner_->PostTask(FROM_HERE, | 314 task_runner_->PostTask(FROM_HERE, |
| 316 base::Bind(&VideoCaptureDeviceMac::SetErrorState, weak_this_, | 315 base::Bind(&VideoCaptureDeviceMac::SetErrorState, |
| 317 reason)); | 316 weak_factory_.GetWeakPtr(), |
| 317 reason)); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { | 320 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { |
| 321 DCHECK(task_runner_->BelongsToCurrentThread()); | 321 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 322 DLOG(ERROR) << reason; | 322 DLOG(ERROR) << reason; |
| 323 state_ = kError; | 323 state_ = kError; |
| 324 client_->OnError(reason); | 324 client_->OnError(reason); |
| 325 } | 325 } |
| 326 | 326 |
| 327 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { | 327 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { |
| 328 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 328 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 329 width:capture_format_.frame_size.width() | 329 width:capture_format_.frame_size.width() |
| 330 frameRate:capture_format_.frame_rate]) { | 330 frameRate:capture_format_.frame_rate]) { |
| 331 ReceiveError("Could not configure capture device."); | 331 ReceiveError("Could not configure capture device."); |
| 332 return false; | 332 return false; |
| 333 } | 333 } |
| 334 return true; | 334 return true; |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace media | 337 } // namespace media |
| OLD | NEW |