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/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 [capture_device_ setFrameReceiver:nil]; | 201 [capture_device_ setFrameReceiver:nil]; |
202 client_.reset(); | 202 client_.reset(); |
203 state_ = kIdle; | 203 state_ = kIdle; |
204 tried_to_square_pixels_ = false; | 204 tried_to_square_pixels_ = false; |
205 } | 205 } |
206 | 206 |
207 bool VideoCaptureDeviceMac::Init() { | 207 bool VideoCaptureDeviceMac::Init() { |
208 DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current()); | 208 DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current()); |
209 DCHECK_EQ(state_, kNotInitialized); | 209 DCHECK_EQ(state_, kNotInitialized); |
210 | 210 |
| 211 // TODO(mcasas): The following check might not be necessary; if the device has |
| 212 // disappeared after enumeration and before coming here, opening would just |
| 213 // fail but not necessarily produce a crash. |
211 Names device_names; | 214 Names device_names; |
212 GetDeviceNames(&device_names); | 215 GetDeviceNames(&device_names); |
213 Name* found = device_names.FindById(device_name_.id()); | 216 Names::iterator it = device_names.begin(); |
214 if (!found) | 217 for (; it != device_names.end(); ++it) { |
| 218 if (it->id() == device_name_.id()) |
| 219 break; |
| 220 } |
| 221 if (it == device_names.end()) |
215 return false; | 222 return false; |
216 | 223 |
217 capture_device_ = | 224 capture_device_ = |
218 [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this]; | 225 [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this]; |
219 if (!capture_device_) | 226 if (!capture_device_) |
220 return false; | 227 return false; |
221 | 228 |
222 state_ = kIdle; | 229 state_ = kIdle; |
223 return true; | 230 return true; |
224 } | 231 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 if (![capture_device_ setCaptureHeight:current_settings_.height | 330 if (![capture_device_ setCaptureHeight:current_settings_.height |
324 width:current_settings_.width | 331 width:current_settings_.width |
325 frameRate:current_settings_.frame_rate]) { | 332 frameRate:current_settings_.frame_rate]) { |
326 ReceiveError("Could not configure capture device."); | 333 ReceiveError("Could not configure capture device."); |
327 return false; | 334 return false; |
328 } | 335 } |
329 return true; | 336 return true; |
330 } | 337 } |
331 | 338 |
332 } // namespace media | 339 } // namespace media |
OLD | NEW |