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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 sent_frame_info_(false), | 125 sent_frame_info_(false), |
126 tried_to_square_pixels_(false), | 126 tried_to_square_pixels_(false), |
127 task_runner_(base::MessageLoopProxy::current()), | 127 task_runner_(base::MessageLoopProxy::current()), |
128 state_(kNotInitialized), | 128 state_(kNotInitialized), |
129 weak_factory_(this), | 129 weak_factory_(this), |
130 weak_this_(weak_factory_.GetWeakPtr()), | |
131 capture_device_(nil) { | 130 capture_device_(nil) { |
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 | 312 |
314 client_->OnIncomingCapturedData(video_frame, | 313 client_->OnIncomingCapturedData(video_frame, |
315 video_frame_length, | 314 video_frame_length, |
316 capture_format_, | 315 capture_format_, |
317 0, | 316 0, |
318 base::TimeTicks::Now()); | 317 base::TimeTicks::Now()); |
319 } | 318 } |
320 | 319 |
321 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { | 320 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { |
322 task_runner_->PostTask(FROM_HERE, | 321 task_runner_->PostTask(FROM_HERE, |
323 base::Bind(&VideoCaptureDeviceMac::SetErrorState, weak_this_, | 322 base::Bind(&VideoCaptureDeviceMac::SetErrorState, |
324 reason)); | 323 weak_factory_.AsWeakPtr(), |
Ami GONE FROM CHROMIUM
2014/03/10 22:02:08
s/As/Get/??
DaleCurtis
2014/03/10 23:47:46
Done.
| |
324 reason)); | |
325 } | 325 } |
326 | 326 |
327 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { | 327 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { |
328 DCHECK(task_runner_->BelongsToCurrentThread()); | 328 DCHECK(task_runner_->BelongsToCurrentThread()); |
329 DLOG(ERROR) << reason; | 329 DLOG(ERROR) << reason; |
330 state_ = kError; | 330 state_ = kError; |
331 client_->OnError(reason); | 331 client_->OnError(reason); |
332 } | 332 } |
333 | 333 |
334 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { | 334 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { |
335 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 335 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
336 width:capture_format_.frame_size.width() | 336 width:capture_format_.frame_size.width() |
337 frameRate:capture_format_.frame_rate]) { | 337 frameRate:capture_format_.frame_rate]) { |
338 ReceiveError("Could not configure capture device."); | 338 ReceiveError("Could not configure capture device."); |
339 return false; | 339 return false; |
340 } | 340 } |
341 return true; | 341 return true; |
342 } | 342 } |
343 | 343 |
344 } // namespace media | 344 } // namespace media |
OLD | NEW |