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 crbug.com/458397 is fixed. | |
mcasas
2015/02/13 16:53:09
Nit: Add http:// in front of crbug.com. Also below
erikchen
2015/02/13 21:53:44
Done.
| |
49 tracked_objects::ScopedTracker tracking_profile( | |
50 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
51 "458397 media::EnumerateDevicesUsingQTKit")); | |
52 | |
47 scoped_ptr<VideoCaptureDevice::Names> device_names( | 53 scoped_ptr<VideoCaptureDevice::Names> device_names( |
48 new VideoCaptureDevice::Names()); | 54 new VideoCaptureDevice::Names()); |
49 NSMutableDictionary* capture_devices = | 55 NSMutableDictionary* capture_devices = |
50 [[[NSMutableDictionary alloc] init] autorelease]; | 56 [[[NSMutableDictionary alloc] init] autorelease]; |
51 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; | 57 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; |
52 for (NSString* key in capture_devices) { | 58 for (NSString* key in capture_devices) { |
53 VideoCaptureDevice::Name name( | 59 VideoCaptureDevice::Name name( |
54 [[[capture_devices valueForKey:key] deviceName] UTF8String], | 60 [[[capture_devices valueForKey:key] deviceName] UTF8String], |
55 [key UTF8String], VideoCaptureDevice::Name::QTKIT); | 61 [key UTF8String], VideoCaptureDevice::Name::QTKIT); |
56 if (IsDeviceBlacklisted(name)) | 62 if (IsDeviceBlacklisted(name)) |
57 name.set_is_blacklisted(true); | 63 name.set_is_blacklisted(true); |
58 device_names->push_back(name); | 64 device_names->push_back(name); |
59 } | 65 } |
60 return device_names.Pass(); | 66 return device_names.Pass(); |
61 } | 67 } |
62 | 68 |
63 static void RunDevicesEnumeratedCallback( | 69 static void RunDevicesEnumeratedCallback( |
64 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& | 70 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& |
65 callback, | 71 callback, |
66 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { | 72 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { |
73 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458397 is fixed. | |
74 tracked_objects::ScopedTracker tracking_profile( | |
75 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
76 "458397 media::RunDevicesEnumeratedCallback")); | |
67 callback.Run(device_names.Pass()); | 77 callback.Run(device_names.Pass()); |
68 } | 78 } |
69 | 79 |
70 // static | 80 // static |
71 bool VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() { | 81 bool VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() { |
72 return AVFoundationGlue::IsAVFoundationSupported(); | 82 return AVFoundationGlue::IsAVFoundationSupported(); |
73 } | 83 } |
74 | 84 |
75 VideoCaptureDeviceFactoryMac::VideoCaptureDeviceFactoryMac( | 85 VideoCaptureDeviceFactoryMac::VideoCaptureDeviceFactoryMac( |
76 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 86 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
(...skipping 18 matching lines...) Expand all Loading... | |
95 if (!device->Init(device_name.capture_api_type())) { | 105 if (!device->Init(device_name.capture_api_type())) { |
96 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; | 106 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; |
97 capture_device.reset(); | 107 capture_device.reset(); |
98 } | 108 } |
99 } | 109 } |
100 return scoped_ptr<VideoCaptureDevice>(capture_device.Pass()); | 110 return scoped_ptr<VideoCaptureDevice>(capture_device.Pass()); |
101 } | 111 } |
102 | 112 |
103 void VideoCaptureDeviceFactoryMac::GetDeviceNames( | 113 void VideoCaptureDeviceFactoryMac::GetDeviceNames( |
104 VideoCaptureDevice::Names* device_names) { | 114 VideoCaptureDevice::Names* device_names) { |
105 DCHECK(thread_checker_.CalledOnValidThread()); | 115 DCHECK(thread_checker_.CalledOnValidThread()); |
mcasas
2015/02/13 16:53:09
Shouldn't you check for jankiness here as well?
Vi
erikchen
2015/02/13 21:53:44
The particular source of jank that I'm tracking do
| |
106 // Loop through all available devices and add to |device_names|. | 116 // Loop through all available devices and add to |device_names|. |
107 NSDictionary* capture_devices; | 117 NSDictionary* capture_devices; |
108 if (AVFoundationGlue::IsAVFoundationSupported()) { | 118 if (AVFoundationGlue::IsAVFoundationSupported()) { |
109 DVLOG(1) << "Enumerating video capture devices using AVFoundation"; | 119 DVLOG(1) << "Enumerating video capture devices using AVFoundation"; |
110 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames]; | 120 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames]; |
111 // Enumerate all devices found by AVFoundation, translate the info for each | 121 // Enumerate all devices found by AVFoundation, translate the info for each |
112 // to class Name and add it to |device_names|. | 122 // to class Name and add it to |device_names|. |
113 for (NSString* key in capture_devices) { | 123 for (NSString* key in capture_devices) { |
114 int transport_type = [[capture_devices valueForKey:key] transportType]; | 124 int transport_type = [[capture_devices valueForKey:key] transportType]; |
115 // Transport types are defined for Audio devices and reused for video. | 125 // Transport types are defined for Audio devices and reused for video. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 } | 198 } |
189 | 199 |
190 // static | 200 // static |
191 VideoCaptureDeviceFactory* | 201 VideoCaptureDeviceFactory* |
192 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 202 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
193 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 203 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
194 return new VideoCaptureDeviceFactoryMac(ui_task_runner); | 204 return new VideoCaptureDeviceFactoryMac(ui_task_runner); |
195 } | 205 } |
196 | 206 |
197 } // namespace media | 207 } // namespace media |
OLD | NEW |