summaryrefslogtreecommitdiff
path: root/media/devices/macdevicemanagermm.mm
diff options
context:
space:
mode:
Diffstat (limited to 'media/devices/macdevicemanagermm.mm')
-rw-r--r--media/devices/macdevicemanagermm.mm53
1 files changed, 53 insertions, 0 deletions
diff --git a/media/devices/macdevicemanagermm.mm b/media/devices/macdevicemanagermm.mm
index 3091ec4..cfcf5a4 100644
--- a/media/devices/macdevicemanagermm.mm
+++ b/media/devices/macdevicemanagermm.mm
@@ -33,6 +33,11 @@
#include "talk/media/devices/devicemanager.h"
#import <assert.h>
+#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+ #import <AVFoundation/AVFoundation.h>
+#endif
+#endif
#import <QTKit/QTKit.h>
#include "webrtc/base/logging.h"
@@ -136,4 +141,52 @@ bool GetQTKitVideoDevices(std::vector<Device>* devices) {
return true;
}
+bool GetAVFoundationVideoDevices(std::vector<Device>* devices) {
+#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >=1070
+ if (![AVCaptureDevice class]) {
+ // Fallback to using QTKit if AVFoundation is not available
+ return GetQTKitVideoDevices(devices);
+ }
+#if !__has_feature(objc_arc)
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+#else
+ @autoreleasepool
+#endif
+ {
+ NSArray* capture_devices = [AVCaptureDevice devices];
+ LOG(LS_INFO) << [capture_devices count] << " capture device(s) found:";
+ for (AVCaptureDevice* capture_device in capture_devices) {
+ if ([capture_device hasMediaType:AVMediaTypeVideo] ||
+ [capture_device hasMediaType:AVMediaTypeMuxed]) {
+ static NSString* const kFormat = @"localizedName: \"%@\", "
+ @"modelID: \"%@\", uniqueID \"%@\", isConnected: %d, "
+ @"isInUseByAnotherApplication: %d";
+ NSString* info = [NSString
+ stringWithFormat:kFormat,
+ [capture_device localizedName],
+ [capture_device modelID],
+ [capture_device uniqueID],
+ [capture_device isConnected],
+ [capture_device isInUseByAnotherApplication]];
+ LOG(LS_INFO) << [info UTF8String];
+
+ std::string name([[capture_device localizedName] UTF8String]);
+ devices->push_back(
+ Device(name, [[capture_device uniqueID] UTF8String]));
+ }
+ }
+ }
+#if !__has_feature(objc_arc)
+ [pool drain];
+#endif
+ return true;
+#else // __MAC_OS_X_VERSION_MAX_ALLOWED >=1070
+ return GetQTKitVideoDevices(devices);
+#endif // __MAC_OS_X_VERSION_MAX_ALLOWED >=1070
+#else // __MAC_OS_X_VERSION_MAX_ALLOWED
+ return GetQTKitVideoDevices(devices);
+#endif // __MAC_OS_X_VERSION_MAX_ALLOWED
+}
+
} // namespace cricket