Chromium Code Reviews| 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..58bc614c5ed87a56a06218d3b1727fe7d98cda1c |
| --- /dev/null |
| +++ b/media/video/capture/mac/avfoundation_glue.mm |
| @@ -0,0 +1,76 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
|
Mark Mentovai
2013/10/01 18:53:23
no (c) necessary. You didn’t use it in your other
mcasas
2013/10/02 14:10:39
Done.
|
| +// 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 "base/mac/mac_util.h" |
| + |
| +@implementation AVFoundationGlue |
| + |
| ++ (BOOL)isAVFoundationSupported { |
| + return (base::mac::IsOSLionOrLater() && |
| + [[AVFoundationGlue avFoundationBundle] load]); |
| +} |
| + |
| ++ (NSBundle*)avFoundationBundle { |
| + static NSBundle* bundle = [NSBundle |
| + bundleWithPath:@"/System/Library/Frameworks/AVFoundation.framework"]; |
| + return bundle; |
| +} |
| + |
| ++ (NSString *const)avCaptureDeviceWasConnectedNotification{ |
| + return @"AVCaptureDeviceWasConnectedNotification"; |
|
Mark Mentovai
2013/10/01 18:53:23
OK, the right thing to do here is to do a dlsym to
mcasas
2013/10/02 14:10:39
Done.
I think (?) that the dlopen does not need
Mark Mentovai
2013/10/02 14:24:34
miguelao wrote:
|
| +} |
| + |
| ++ (NSString *const)avCaptureDeviceWasDisconnectedNotification{ |
| + return @"AVCaptureDeviceWasDisconnectedNotification"; |
| +} |
| + |
| ++ (NSString *const)avMediaTypeVideo{ |
| + return @"vide"; |
| +} |
| + |
| ++ (NSString *const)avMediaTypeAudio{ |
| + return @"soun"; |
| +} |
| + |
| ++ (NSString *const)avMediaTypeMuxed{ |
| + return @"muxx"; |
| +} |
| + |
| +@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 |
| + forId:(id)device{ |
|
Mark Mentovai
2013/10/01 18:53:23
Is there no better generic type than id?
If you’v
mcasas
2013/10/02 14:10:39
Much appreciated tip thanks!
Done.
|
| + BOOL returnValueHasMediaType = NO; |
| + SEL selectorHasMediaType = NSSelectorFromString(@"hasMediaType:"); |
| + // To retrieve the return value of a dynamically found method inside a class |
| + // that we don't know the interface, we have to get a |SEL| and invoke it. |
| + if ([device respondsToSelector:selectorHasMediaType]) { |
| + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: |
| + [[device class] instanceMethodSignatureForSelector:selectorHasMediaType]]; |
| + [invocation setSelector:selectorHasMediaType]; |
| + [invocation setTarget:device]; |
| + // First argument's index is 2 :S -- counterintuitive |
| + [invocation setArgument:&mediaType atIndex:2]; |
| + [invocation invoke]; |
| + [invocation getReturnValue:&returnValueHasMediaType]; |
| + } |
| + return returnValueHasMediaType; |
| +} |
| + |
| +@end // @implementation AVCaptureDevice |