OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_factory_mac.h" | 5 #include "media/video/capture/mac/video_capture_device_factory_mac.h" |
6 | 6 |
7 #import <IOKit/audio/IOAudioTypes.h> | 7 #import <IOKit/audio/IOAudioTypes.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/profiler/scoped_tracker.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
13 #import "media/base/mac/avfoundation_glue.h" | 14 #import "media/base/mac/avfoundation_glue.h" |
14 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | 15 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
15 #include "media/video/capture/mac/video_capture_device_mac.h" | 16 #include "media/video/capture/mac/video_capture_device_mac.h" |
16 #import "media/video/capture/mac/video_capture_device_decklink_mac.h" | 17 #import "media/video/capture/mac/video_capture_device_decklink_mac.h" |
17 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" | 18 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
18 | 19 |
19 namespace media { | 20 namespace media { |
20 | 21 |
(...skipping 16 matching lines...) Expand all Loading... |
37 is_device_blacklisted = EndsWith(name.id(), | 38 is_device_blacklisted = EndsWith(name.id(), |
38 kBlacklistedCameras[i].unique_id_signature, false); | 39 kBlacklistedCameras[i].unique_id_signature, false); |
39 } | 40 } |
40 DVLOG_IF(2, is_device_blacklisted) << "Blacklisted camera: " << | 41 DVLOG_IF(2, is_device_blacklisted) << "Blacklisted camera: " << |
41 name.name() << ", id: " << name.id(); | 42 name.name() << ", id: " << name.id(); |
42 return is_device_blacklisted; | 43 return is_device_blacklisted; |
43 } | 44 } |
44 | 45 |
45 static scoped_ptr<media::VideoCaptureDevice::Names> | 46 static scoped_ptr<media::VideoCaptureDevice::Names> |
46 EnumerateDevicesUsingQTKit() { | 47 EnumerateDevicesUsingQTKit() { |
| 48 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/458397 is |
| 49 // fixed. |
| 50 tracked_objects::ScopedTracker tracking_profile( |
| 51 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 52 "458397 media::EnumerateDevicesUsingQTKit")); |
| 53 |
47 scoped_ptr<VideoCaptureDevice::Names> device_names( | 54 scoped_ptr<VideoCaptureDevice::Names> device_names( |
48 new VideoCaptureDevice::Names()); | 55 new VideoCaptureDevice::Names()); |
49 NSMutableDictionary* capture_devices = | 56 NSMutableDictionary* capture_devices = |
50 [[[NSMutableDictionary alloc] init] autorelease]; | 57 [[[NSMutableDictionary alloc] init] autorelease]; |
51 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; | 58 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; |
52 for (NSString* key in capture_devices) { | 59 for (NSString* key in capture_devices) { |
53 VideoCaptureDevice::Name name( | 60 VideoCaptureDevice::Name name( |
54 [[[capture_devices valueForKey:key] deviceName] UTF8String], | 61 [[[capture_devices valueForKey:key] deviceName] UTF8String], |
55 [key UTF8String], VideoCaptureDevice::Name::QTKIT); | 62 [key UTF8String], VideoCaptureDevice::Name::QTKIT); |
56 if (IsDeviceBlacklisted(name)) | 63 if (IsDeviceBlacklisted(name)) |
57 name.set_is_blacklisted(true); | 64 name.set_is_blacklisted(true); |
58 device_names->push_back(name); | 65 device_names->push_back(name); |
59 } | 66 } |
60 return device_names.Pass(); | 67 return device_names.Pass(); |
61 } | 68 } |
62 | 69 |
63 static void RunDevicesEnumeratedCallback( | 70 static void RunDevicesEnumeratedCallback( |
64 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& | 71 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& |
65 callback, | 72 callback, |
66 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { | 73 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { |
| 74 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/458397 is |
| 75 // fixed. |
| 76 tracked_objects::ScopedTracker tracking_profile( |
| 77 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 78 "458397 media::RunDevicesEnumeratedCallback")); |
67 callback.Run(device_names.Pass()); | 79 callback.Run(device_names.Pass()); |
68 } | 80 } |
69 | 81 |
70 // static | 82 // static |
71 bool VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() { | 83 bool VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() { |
72 return AVFoundationGlue::IsAVFoundationSupported(); | 84 return AVFoundationGlue::IsAVFoundationSupported(); |
73 } | 85 } |
74 | 86 |
75 VideoCaptureDeviceFactoryMac::VideoCaptureDeviceFactoryMac( | 87 VideoCaptureDeviceFactoryMac::VideoCaptureDeviceFactoryMac( |
76 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 88 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
(...skipping 18 matching lines...) Expand all Loading... |
95 if (!device->Init(device_name.capture_api_type())) { | 107 if (!device->Init(device_name.capture_api_type())) { |
96 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; | 108 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; |
97 capture_device.reset(); | 109 capture_device.reset(); |
98 } | 110 } |
99 } | 111 } |
100 return scoped_ptr<VideoCaptureDevice>(capture_device.Pass()); | 112 return scoped_ptr<VideoCaptureDevice>(capture_device.Pass()); |
101 } | 113 } |
102 | 114 |
103 void VideoCaptureDeviceFactoryMac::GetDeviceNames( | 115 void VideoCaptureDeviceFactoryMac::GetDeviceNames( |
104 VideoCaptureDevice::Names* device_names) { | 116 VideoCaptureDevice::Names* device_names) { |
| 117 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/458397 is |
| 118 // fixed. |
| 119 tracked_objects::ScopedTracker tracking_profile( |
| 120 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 121 "458397 VideoCaptureDeviceFactoryMac::GetDeviceNames")); |
105 DCHECK(thread_checker_.CalledOnValidThread()); | 122 DCHECK(thread_checker_.CalledOnValidThread()); |
106 // Loop through all available devices and add to |device_names|. | 123 // Loop through all available devices and add to |device_names|. |
107 NSDictionary* capture_devices; | 124 NSDictionary* capture_devices; |
108 if (AVFoundationGlue::IsAVFoundationSupported()) { | 125 if (AVFoundationGlue::IsAVFoundationSupported()) { |
109 DVLOG(1) << "Enumerating video capture devices using AVFoundation"; | 126 DVLOG(1) << "Enumerating video capture devices using AVFoundation"; |
110 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames]; | 127 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames]; |
111 // Enumerate all devices found by AVFoundation, translate the info for each | 128 // Enumerate all devices found by AVFoundation, translate the info for each |
112 // to class Name and add it to |device_names|. | 129 // to class Name and add it to |device_names|. |
113 for (NSString* key in capture_devices) { | 130 for (NSString* key in capture_devices) { |
114 int transport_type = [[capture_devices valueForKey:key] transportType]; | 131 int transport_type = [[capture_devices valueForKey:key] transportType]; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 205 } |
189 | 206 |
190 // static | 207 // static |
191 VideoCaptureDeviceFactory* | 208 VideoCaptureDeviceFactory* |
192 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 209 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
193 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 210 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
194 return new VideoCaptureDeviceFactoryMac(ui_task_runner); | 211 return new VideoCaptureDeviceFactoryMac(ui_task_runner); |
195 } | 212 } |
196 | 213 |
197 } // namespace media | 214 } // namespace media |
OLD | NEW |