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

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: rsesek@ last round of nits taken in. 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 2013 The Chromium Authors. All rights reserved.
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 <dlfcn.h>
8
9 #include "base/mac/mac_util.h"
10
11 BOOL AVFoundationGlue::IsAVFoundationSupported() {
12 return (base::mac::IsOSLionOrLater() && [AVFoundationBundle() load]);
13 }
14
15 NSBundle const* AVFoundationGlue::AVFoundationBundle() {
16 static NSBundle* bundle = [NSBundle
17 bundleWithPath:@"/System/Library/Frameworks/AVFoundation.framework"];
18 return bundle;
19 }
20
21 void* AVFoundationGlue::AVFoundationLibraryHandle() {
22 const char* library_path =
23 [[AVFoundationBundle() executablePath] fileSystemRepresentation];
24 if (library_path == NULL) {
25 DCHECK(false);
26 return NULL;
27 }
28 static void* library_handle = dlopen(library_path, RTLD_LAZY | RTLD_LOCAL);
DaleCurtis 2013/10/22 19:17:56 Presumably rsesek@ and mmentovai@ decided against
mcasas 2013/10/23 12:52:08 base::NativeLibrary uses CFBundle and we are using
29 DCHECK(library_handle) << dlerror();
30 return library_handle;
31 }
32
33 NSString* AVFoundationGlue::AVCaptureDeviceWasConnectedNotification() {
34 return ReadNSStringPtr("AVCaptureDeviceWasConnectedNotification");
35 }
36
37 NSString* AVFoundationGlue::AVCaptureDeviceWasDisconnectedNotification() {
38 return ReadNSStringPtr("AVCaptureDeviceWasDisconnectedNotification");
39 }
40
41 NSString* AVFoundationGlue::AVMediaTypeVideo() {
42 return ReadNSStringPtr("AVMediaTypeVideo");
43 }
44
45 NSString* AVFoundationGlue::AVMediaTypeAudio() {
46 return ReadNSStringPtr("AVMediaTypeAudio");
47 }
48
49 NSString* AVFoundationGlue::AVMediaTypeMuxed() {
50 return ReadNSStringPtr("AVMediaTypeMuxed");
51 }
52
53 NSString* AVFoundationGlue::ReadNSStringPtr(char const* const symbol) {
DaleCurtis 2013/10/22 19:17:56 "const char* symbol" is normally how this is writt
mcasas 2013/10/23 12:52:08 "const char* symbol" would be a mutable-pointer po
54 NSString** stringPointer = reinterpret_cast<NSString**>(
DaleCurtis 2013/10/22 19:17:56 string_pointer ?
mcasas 2013/10/23 12:52:08 Absolutely. Done.
55 dlsym(AVFoundationLibraryHandle(), symbol));
56 DCHECK(stringPointer) << dlerror();
57 return *stringPointer;
58 }
59
60 @implementation AVCaptureDeviceGlue
61
62 + (NSArray*)devices {
63 Class avcClass =
64 [AVFoundationGlue::AVFoundationBundle() classNamed:@"AVCaptureDevice"];
65 SEL selectorDevices = NSSelectorFromString(@"devices");
66 if ([avcClass respondsToSelector:selectorDevices]) {
67 return [avcClass performSelector:selectorDevices];
68 }
69 return nil;
70 }
71
72 + (BOOL)hasMediaType:(NSString*)mediaType
73 forCaptureDevice:(CrAVCaptureDevice*)device {
74 SEL selectorHasMediaType = NSSelectorFromString(@"hasMediaType:");
75 if ([device respondsToSelector:selectorHasMediaType]) {
76 return [device hasMediaType:mediaType];
77 }
78 return NO;
79 }
80
81 + (NSString*)uniqueID:(CrAVCaptureDevice*)device {
82 SEL selectorUniqueID = NSSelectorFromString(@"uniqueID");
83 if ([device respondsToSelector:selectorUniqueID]) {
84 return [device uniqueID];
85 }
86 return nil;
87 }
88
89 @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