Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: media/video/capture/mac/video_capture_device_mac.mm

Issue 91343002: Added supported formats caching to VideoCaptureManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mad formatting corrected in certain files. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 for (NSString* key in capture_devices) { 77 for (NSString* key in capture_devices) {
78 Name name([[capture_devices valueForKey:key] UTF8String], 78 Name name([[capture_devices valueForKey:key] UTF8String],
79 [key UTF8String]); 79 [key UTF8String]);
80 device_names->push_back(name); 80 device_names->push_back(name);
81 } 81 }
82 } 82 }
83 83
84 // static 84 // static
85 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device, 85 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
86 VideoCaptureCapabilities* formats) { 86 VideoCaptureFormats* formats) {
87 NOTIMPLEMENTED(); 87 NOTIMPLEMENTED();
88 } 88 }
89 89
90 const std::string VideoCaptureDevice::Name::GetModel() const { 90 const std::string VideoCaptureDevice::Name::GetModel() const {
91 // Both PID and VID are 4 characters. 91 // Both PID and VID are 4 characters.
92 if (unique_id_.size() < 2 * kVidPidSize) { 92 if (unique_id_.size() < 2 * kVidPidSize) {
93 return ""; 93 return "";
94 } 94 }
95 95
96 // The last characters of device id is a concatenation of VID and then PID. 96 // The last characters of device id is a concatenation of VID and then PID.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 [capture_device_ setFrameReceiver:nil]; 196 [capture_device_ setFrameReceiver:nil];
197 client_.reset(); 197 client_.reset();
198 state_ = kIdle; 198 state_ = kIdle;
199 tried_to_square_pixels_ = false; 199 tried_to_square_pixels_ = false;
200 } 200 }
201 201
202 bool VideoCaptureDeviceMac::Init() { 202 bool VideoCaptureDeviceMac::Init() {
203 DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current()); 203 DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
204 DCHECK_EQ(state_, kNotInitialized); 204 DCHECK_EQ(state_, kNotInitialized);
205 205
206 // TODO(mcasas): The following check might not be necessary; if the device has
207 // disappeared after enumeration and before coming here, opening would just
208 // fail but not necessarily produce a crash.
206 Names device_names; 209 Names device_names;
207 GetDeviceNames(&device_names); 210 GetDeviceNames(&device_names);
208 Name* found = device_names.FindById(device_name_.id()); 211 Names::iterator it = device_names.begin();
209 if (!found) 212 for (; it != device_names.end(); ++it) {
213 if (it->id() == device_name_.id())
214 break;
215 }
216 if (it == device_names.end())
210 return false; 217 return false;
211 218
212 if (AVFoundationGlue::IsAVFoundationSupported()) { 219 if (AVFoundationGlue::IsAVFoundationSupported()) {
213 capture_device_ = 220 capture_device_ =
214 [[VideoCaptureDeviceAVFoundation alloc] initWithFrameReceiver:this]; 221 [[VideoCaptureDeviceAVFoundation alloc] initWithFrameReceiver:this];
215 } else { 222 } else {
216 capture_device_ = 223 capture_device_ =
217 [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this]; 224 [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this];
218 } 225 }
219 226
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() 330 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height()
324 width:capture_format_.frame_size.width() 331 width:capture_format_.frame_size.width()
325 frameRate:capture_format_.frame_rate]) { 332 frameRate:capture_format_.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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698