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

Side by Side Diff: media/video/capture/mac/avfoundation_glue.mm

Issue 128373002: Added code for AVFoundation Finch Experiment enabling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asvitkine@ comments Created 6 years, 11 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 | « no previous file | 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "media/video/capture/mac/avfoundation_glue.h" 5 #import "media/video/capture/mac/avfoundation_glue.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #include "base/metrics/field_trial.h"
12 #include "media/base/media_switches.h" 13 #include "media/base/media_switches.h"
13 14
14 namespace { 15 namespace {
15 16
16 // This class is used to retrieve AVFoundation NSBundle and library handle. It 17 // This class is used to retrieve AVFoundation NSBundle and library handle. It
17 // must be used as a LazyInstance so that it is initialised once and in a 18 // must be used as a LazyInstance so that it is initialised once and in a
18 // thread-safe way. Normally no work is done in constructors: LazyInstance is 19 // thread-safe way. Normally no work is done in constructors: LazyInstance is
19 // an exception. 20 // an exception.
20 class AVFoundationInternal { 21 class AVFoundationInternal {
21 public: 22 public:
(...skipping 27 matching lines...) Expand all
49 static NSString* ReadNSStringPtr(const char* symbol) { 50 static NSString* ReadNSStringPtr(const char* symbol) {
50 NSString** string_pointer = reinterpret_cast<NSString**>( 51 NSString** string_pointer = reinterpret_cast<NSString**>(
51 dlsym(AVFoundationGlue::AVFoundationLibraryHandle(), symbol)); 52 dlsym(AVFoundationGlue::AVFoundationLibraryHandle(), symbol));
52 DCHECK(string_pointer) << dlerror(); 53 DCHECK(string_pointer) << dlerror();
53 return *string_pointer; 54 return *string_pointer;
54 } 55 }
55 56
56 } // namespace media 57 } // namespace media
57 58
58 bool AVFoundationGlue::IsAVFoundationSupported() { 59 bool AVFoundationGlue::IsAVFoundationSupported() {
60 if (!base::mac::IsOSLionOrLater())
61 return false;
62 const std::string group_name =
63 base::FieldTrialList::FindFullName("AVFoundationMacVideoCapture");
59 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 64 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
60 return cmd_line->HasSwitch(switches::kEnableAVFoundation) && 65 return (cmd_line->HasSwitch(switches::kEnableAVFoundation) ||
61 base::mac::IsOSLionOrLater() && [AVFoundationBundle() load]; 66 group_name == "Enabled") && [AVFoundationBundle() load];
62 } 67 }
63 68
64 NSBundle const* AVFoundationGlue::AVFoundationBundle() { 69 NSBundle const* AVFoundationGlue::AVFoundationBundle() {
65 return g_avfoundation_handle.Get().bundle(); 70 return g_avfoundation_handle.Get().bundle();
66 } 71 }
67 72
68 void* AVFoundationGlue::AVFoundationLibraryHandle() { 73 void* AVFoundationGlue::AVFoundationLibraryHandle() {
69 return g_avfoundation_handle.Get().library_handle(); 74 return g_avfoundation_handle.Get().library_handle();
70 } 75 }
71 76
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 @implementation AVCaptureDeviceInputGlue 157 @implementation AVCaptureDeviceInputGlue
153 158
154 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device 159 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device
155 error:(NSError**)outError { 160 error:(NSError**)outError {
156 return [[AVFoundationGlue::AVFoundationBundle() 161 return [[AVFoundationGlue::AVFoundationBundle()
157 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device 162 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device
158 error:outError]; 163 error:outError];
159 } 164 }
160 165
161 @end // @implementation AVCaptureDeviceInputGlue 166 @end // @implementation AVCaptureDeviceInputGlue
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698