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

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

Issue 24615005: Added AVFoundation Glue and Device Monitoring for Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 7 years, 2 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
Index: media/video/capture/mac/avfoundation_glue.mm
diff --git a/media/video/capture/mac/avfoundation_glue.mm b/media/video/capture/mac/avfoundation_glue.mm
new file mode 100644
index 0000000000000000000000000000000000000000..9a61e8918e653de722f7beef4a6dab121e763374
--- /dev/null
+++ b/media/video/capture/mac/avfoundation_glue.mm
@@ -0,0 +1,94 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "media/video/capture/mac/avfoundation_glue.h"
+
+#include <dlfcn.h>
+
+#include "base/mac/mac_util.h"
+
+@implementation AVFoundationGlue
+
++ (BOOL)isAVFoundationSupported {
+ return (base::mac::IsOSLionOrLater() &&
+ [[AVFoundationGlue avFoundationBundle] load]);
+}
+
++ (NSBundle const*)avFoundationBundle {
+ static NSBundle* bundle = [NSBundle
+ bundleWithPath:@"/System/Library/Frameworks/AVFoundation.framework"];
+ return bundle;
+}
+
++ (void*)avFoundationLibraryHandle {
+ static void* library_handle = dlopen([[[AVFoundationGlue avFoundationBundle]
+ executablePath] fileSystemRepresentation], RTLD_LAZY | RTLD_LOCAL);
+ DCHECK(library_handle) << dlerror();
+ return library_handle;
+}
+
++ (NSString* const)avCaptureDeviceWasConnectedNotification{
+ return [AVFoundationGlue readNSStringPtr:
+ "AVCaptureDeviceWasConnectedNotification"
+ fromLibrary:[AVFoundationGlue
+ avFoundationLibraryHandle]];
+}
+
++ (NSString* const)avCaptureDeviceWasDisconnectedNotification{
+ return [AVFoundationGlue readNSStringPtr:
+ "AVCaptureDeviceWasDisconnectedNotification"
+ fromLibrary:[AVFoundationGlue
+ avFoundationLibraryHandle]];
+}
+
++ (NSString* const)avMediaTypeVideo{
+ return [AVFoundationGlue readNSStringPtr:"AVMediaTypeVideo"
+ fromLibrary:[AVFoundationGlue
+ avFoundationLibraryHandle]];
+}
+
++ (NSString* const)avMediaTypeAudio{
+ return [AVFoundationGlue readNSStringPtr:"AVMediaTypeAudio"
+ fromLibrary:[AVFoundationGlue
+ avFoundationLibraryHandle]];
+}
+
++ (NSString* const)avMediaTypeMuxed{
+ return [AVFoundationGlue readNSStringPtr:"AVMediaTypeMuxed"
+ fromLibrary:[AVFoundationGlue
+ avFoundationLibraryHandle]];
+}
+
++(NSString* const)readNSStringPtr:(char const* const)symbol
+ fromLibrary:(void* const)handle {
+ NSString** stringPointer = (NSString**) dlsym(handle, symbol);
+ DCHECK(stringPointer) << dlerror();
+ return *stringPointer;
+}
+
+@end // @implementation AVFoundationGlue
+
+
+@implementation AVCaptureDeviceGlue
+
++ (NSArray*)devices {
+ Class avcClass = [[AVFoundationGlue avFoundationBundle]
+ classNamed:@"AVCaptureDevice"];
+ SEL selectorDevices = NSSelectorFromString(@"devices");
+ if ([avcClass respondsToSelector:selectorDevices]){
+ return [avcClass performSelector:selectorDevices];
+ }
+ return nil;
+}
+
++ (BOOL)hasMediaType:(NSString*)mediaType
+ forCaptureDevice:(CrAVCaptureDevice const*)device {
+ SEL selectorHasMediaType = NSSelectorFromString(@"hasMediaType:");
+ if ([device respondsToSelector:selectorHasMediaType]) {
+ return [device hasMediaType:mediaType];
+ }
+ return NO;
+}
+
+@end // @implementation AVCaptureDevice
« content/browser/device_monitor_mac.mm ('K') | « media/video/capture/mac/avfoundation_glue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698