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

Unified Diff: media/video/capture/mac/video_capture_device_mac.mm

Issue 17846002: Refactor the VideoCaptureDevice::Name struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/capture/mac/video_capture_device_mac.h ('k') | media/video/capture/video_capture_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/mac/video_capture_device_mac.mm
diff --git a/media/video/capture/mac/video_capture_device_mac.mm b/media/video/capture/mac/video_capture_device_mac.mm
index f18eb540bcef59bda8191769f99506978516edc4..f6f594468db2215d1c835de16c493f3cb6ea5039 100644
--- a/media/video/capture/mac/video_capture_device_mac.mm
+++ b/media/video/capture/mac/video_capture_device_mac.mm
@@ -56,9 +56,8 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
NSDictionary* capture_devices = [VideoCaptureDeviceQTKit deviceNames];
for (NSString* key in capture_devices) {
- Name name;
- name.device_name = [[capture_devices valueForKey:key] UTF8String];
- name.unique_id = [key UTF8String];
+ Name name([[capture_devices valueForKey:key] UTF8String],
+ [key UTF8String]);
device_names->push_back(name);
}
}
@@ -98,7 +97,7 @@ void VideoCaptureDeviceMac::Allocate(int width, int height, int frame_rate,
observer_ = observer;
NSString* deviceId =
- [NSString stringWithUTF8String:device_name_.unique_id.c_str()];
+ [NSString stringWithUTF8String:device_name_.id().c_str()];
[capture_device_ setFrameReceiver:this];
@@ -167,20 +166,17 @@ bool VideoCaptureDeviceMac::Init() {
Names device_names;
GetDeviceNames(&device_names);
- for (Names::iterator it = device_names.begin();
- it != device_names.end();
- ++it) {
- if (device_name_.unique_id == it->unique_id) {
- capture_device_ =
- [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this];
- if (!capture_device_) {
- return false;
- }
- state_ = kIdle;
- return true;
- }
- }
- return false;
+ Name* found = device_names.FindById(device_name_.id());
+ if (!found)
+ return false;
+
+ capture_device_ =
+ [[VideoCaptureDeviceQTKit alloc] initWithFrameReceiver:this];
+ if (!capture_device_)
+ return false;
+
+ state_ = kIdle;
+ return true;
}
void VideoCaptureDeviceMac::ReceiveFrame(
« no previous file with comments | « media/video/capture/mac/video_capture_device_mac.h ('k') | media/video/capture/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698