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

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: Rebased FakeVCD. Reconnected VCManager unittest for all platforms. 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 capture_devices = [VideoCaptureDeviceQTKit deviceNames]; 75 capture_devices = [VideoCaptureDeviceQTKit deviceNames];
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(
86 VideoCaptureCapabilities* formats) { 86 const Name& device,
87 VideoCaptureFormats* formats) {
87 NOTIMPLEMENTED(); 88 NOTIMPLEMENTED();
88 } 89 }
89 90
90 const std::string VideoCaptureDevice::Name::GetModel() const { 91 const std::string VideoCaptureDevice::Name::GetModel() const {
91 // Both PID and VID are 4 characters. 92 // Both PID and VID are 4 characters.
92 if (unique_id_.size() < 2 * kVidPidSize) { 93 if (unique_id_.size() < 2 * kVidPidSize) {
93 return ""; 94 return "";
94 } 95 }
95 96
96 // The last characters of device id is a concatenation of VID and then PID. 97 // 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]; 197 [capture_device_ setFrameReceiver:nil];
197 client_.reset(); 198 client_.reset();
198 state_ = kIdle; 199 state_ = kIdle;
199 tried_to_square_pixels_ = false; 200 tried_to_square_pixels_ = false;
200 } 201 }
201 202
202 bool VideoCaptureDeviceMac::Init() { 203 bool VideoCaptureDeviceMac::Init() {
203 DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current()); 204 DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
204 DCHECK_EQ(state_, kNotInitialized); 205 DCHECK_EQ(state_, kNotInitialized);
205 206
207 // TODO(mcasas): The following check might not be necessary; if the device has
208 // disappeared after enumeration and before coming here, opening would just
209 // fail but not necessarily produce a crash.
206 Names device_names; 210 Names device_names;
207 GetDeviceNames(&device_names); 211 GetDeviceNames(&device_names);
208 Name* found = device_names.FindById(device_name_.id()); 212 Names::iterator it = device_names.begin();
209 if (!found) 213 for (; it != device_names.end(); ++it) {
214 if (it->id() == device_name_.id())
215 break;
216 }
217 if (it == device_names.end())
210 return false; 218 return false;
211 219
212 if (AVFoundationGlue::IsAVFoundationSupported()) { 220 if (AVFoundationGlue::IsAVFoundationSupported()) {
213 capture_device_ = 221 capture_device_ =
214 [[VideoCaptureDeviceAVFoundation alloc] initWithFrameReceiver:this]; 222 [[VideoCaptureDeviceAVFoundation alloc] initWithFrameReceiver:this];
215 } else { 223 } else {
216 capture_device_ = 224 capture_device_ =
217 [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this]; 225 [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this];
218 } 226 }
219 227
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() 331 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height()
324 width:capture_format_.frame_size.width() 332 width:capture_format_.frame_size.width()
325 frameRate:capture_format_.frame_rate]) { 333 frameRate:capture_format_.frame_rate]) {
326 ReceiveError("Could not configure capture device."); 334 ReceiveError("Could not configure capture device.");
327 return false; 335 return false;
328 } 336 }
329 return true; 337 return true;
330 } 338 }
331 339
332 } // namespace media 340 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698