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

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: More rsesek@ comments. 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
« no previous file with comments | « media/video/capture/mac/avfoundation_glue.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
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) {
54 NSString** stringPointer = (NSString**)dlsym(AvFoundationLibraryHandle(),
Robert Sesek 2013/10/18 18:18:15 You should use reinterpret_cast<> since C-style ca
mcasas 2013/10/19 20:37:08 Done.
55 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
« no previous file with comments | « 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