From a42a3ade541af4bc49e4e43a78bd886e3b140948 Mon Sep 17 00:00:00 2001 From: "buildbot@webrtc.org" Date: Sat, 13 Sep 2014 01:09:18 +0000 Subject: [PATCH] (Auto)update libjingle 75390072-> 75428737 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7174 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/libjingle.gyp | 1 + talk/media/devices/macdevicemanager.cc | 4 +- talk/media/devices/macdevicemanagermm.mm | 53 ++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp index bb7b3b0131..70b0798f99 100755 --- a/talk/libjingle.gyp +++ b/talk/libjingle.gyp @@ -588,6 +588,7 @@ 'link_settings': { 'xcode_settings': { 'OTHER_LDFLAGS': [ + '-weak_framework AVFoundation', '-framework Cocoa', '-framework CoreAudio', '-framework CoreVideo', diff --git a/talk/media/devices/macdevicemanager.cc b/talk/media/devices/macdevicemanager.cc index 568ee53f6b..8f777b42da 100644 --- a/talk/media/devices/macdevicemanager.cc +++ b/talk/media/devices/macdevicemanager.cc @@ -71,7 +71,7 @@ static const UInt32 kAudioDeviceNameLength = 64; extern DeviceWatcherImpl* CreateDeviceWatcherCallback( DeviceManagerInterface* dm); extern void ReleaseDeviceWatcherCallback(DeviceWatcherImpl* impl); -extern bool GetQTKitVideoDevices(std::vector* out); +extern bool GetAVFoundationVideoDevices(std::vector* out); static bool GetAudioDeviceIDs(bool inputs, std::vector* out); static bool GetAudioDeviceName(AudioDeviceID id, bool input, std::string* out); @@ -84,7 +84,7 @@ MacDeviceManager::~MacDeviceManager() { bool MacDeviceManager::GetVideoCaptureDevices(std::vector* devices) { devices->clear(); - if (!GetQTKitVideoDevices(devices)) { + if (!GetAVFoundationVideoDevices(devices)) { return false; } return FilterDevices(devices, kFilteredVideoDevicesName); diff --git a/talk/media/devices/macdevicemanagermm.mm b/talk/media/devices/macdevicemanagermm.mm index 3091ec455f..cfcf5a48b3 100644 --- a/talk/media/devices/macdevicemanagermm.mm +++ b/talk/media/devices/macdevicemanagermm.mm @@ -33,6 +33,11 @@ #include "talk/media/devices/devicemanager.h" #import +#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + #import +#endif +#endif #import #include "webrtc/base/logging.h" @@ -136,4 +141,52 @@ bool GetQTKitVideoDevices(std::vector* devices) { return true; } +bool GetAVFoundationVideoDevices(std::vector* 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