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

Side by Side 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: OVerhauled following mark@ review. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // 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.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "media/video/capture/mac/avfoundation_glue.h"
6
7 #include "base/mac/mac_util.h"
8
9 @implementation AVFoundationGlue
10
11 + (BOOL)isAVFoundationSupported {
12 return (base::mac::IsOSLionOrLater() &&
13 [[AVFoundationGlue avFoundationBundle] load]);
14 }
15
16 + (NSBundle*)avFoundationBundle {
17 static NSBundle* bundle = [NSBundle
18 bundleWithPath:@"/System/Library/Frameworks/AVFoundation.framework"];
19 return bundle;
20 }
21
22 + (NSString *const)avCaptureDeviceWasConnectedNotification{
23 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:
24 }
25
26 + (NSString *const)avCaptureDeviceWasDisconnectedNotification{
27 return @"AVCaptureDeviceWasDisconnectedNotification";
28 }
29
30 + (NSString *const)avMediaTypeVideo{
31 return @"vide";
32 }
33
34 + (NSString *const)avMediaTypeAudio{
35 return @"soun";
36 }
37
38 + (NSString *const)avMediaTypeMuxed{
39 return @"muxx";
40 }
41
42 @end // @implementation AVFoundationGlue
43
44
45 @implementation AVCaptureDeviceGlue
46
47 + (NSArray*)devices {
48 Class avcClass = [[AVFoundationGlue avFoundationBundle]
49 classNamed:@"AVCaptureDevice"];
50 SEL selectorDevices = NSSelectorFromString(@"devices");
51 if ([avcClass respondsToSelector:selectorDevices]){
52 return [avcClass performSelector:selectorDevices];
53 }
54 return nil;
55 }
56
57 + (BOOL)hasMediaType:(NSString *)mediaType
58 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.
59 BOOL returnValueHasMediaType = NO;
60 SEL selectorHasMediaType = NSSelectorFromString(@"hasMediaType:");
61 // To retrieve the return value of a dynamically found method inside a class
62 // that we don't know the interface, we have to get a |SEL| and invoke it.
63 if ([device respondsToSelector:selectorHasMediaType]) {
64 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
65 [[device class] instanceMethodSignatureForSelector:selectorHasMediaType]];
66 [invocation setSelector:selectorHasMediaType];
67 [invocation setTarget:device];
68 // First argument's index is 2 :S -- counterintuitive
69 [invocation setArgument:&mediaType atIndex:2];
70 [invocation invoke];
71 [invocation getReturnValue:&returnValueHasMediaType];
72 }
73 return returnValueHasMediaType;
74 }
75
76 @end // @implementation AVCaptureDevice
OLDNEW
« media/video/capture/mac/avfoundation_glue.h ('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