Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 } // namespace | 103 } // namespace |
| 104 | 104 |
| 105 static base::LazyInstance<AVFoundationInternal> g_avfoundation_handle = | 105 static base::LazyInstance<AVFoundationInternal> g_avfoundation_handle = |
| 106 LAZY_INSTANCE_INITIALIZER; | 106 LAZY_INSTANCE_INITIALIZER; |
| 107 | 107 |
| 108 bool AVFoundationGlue::IsAVFoundationSupported() { | 108 bool AVFoundationGlue::IsAVFoundationSupported() { |
| 109 // DeviceMonitorMac will initialize this static bool from the main UI thread | 109 // DeviceMonitorMac will initialize this static bool from the main UI thread |
| 110 // once, during Chrome startup so this construction is thread safe. | 110 // once, during Chrome startup so this construction is thread safe. |
| 111 // Use AVFoundation if possible, enabled, and QTKit is not explicitly forced. | 111 // Use AVFoundation if possible, enabled, and QTKit is not explicitly forced. |
| 112 static CommandLine* command_line = CommandLine::ForCurrentProcess(); | 112 static CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 113 static bool is_av_foundation_supported = base::mac::IsOSLionOrLater() && | 113 |
| 114 ((command_line->HasSwitch(switches::kEnableAVFoundation) && | 114 // AVFoundation is only available on OS Lion and above. |
| 115 !command_line->HasSwitch(switches::kForceQTKit)) || | 115 if (!base::mac::IsOSLionOrLater()) |
|
DaleCurtis
2014/07/23 20:54:38
I think you want to merge these into the static in
vrk (LEFT CHROMIUM)
2014/07/25 00:01:15
Ah, thanks for the catch! Didn't pay attention to
| |
| 116 base::FieldTrialList::FindFullName("AVFoundationMacVideoCapture") | 116 return false; |
| 117 == "Enabled") && [AVFoundationBundle() load]; | 117 |
| 118 return is_av_foundation_supported; | 118 // The force-qtkit flag takes precedence over enable-avfoundation. |
| 119 if (command_line->HasSwitch(switches::kForceQTKit)) | |
| 120 return false; | |
| 121 | |
| 122 // Next in precedence is the Enable AVFoundation flag. | |
| 123 // TODO(mcasas,vrk): There should be 3 states of AVFoundation: user forced on, | |
| 124 // user forced off (i.e. force QTKit), and default (respect field trial). | |
| 125 // crbug.com/396764 | |
| 126 static bool avfoundation_requested = | |
| 127 command_line->HasSwitch(switches::kEnableAVFoundation) || | |
| 128 (base::FieldTrialList::FindFullName("AVFoundationMacVideoCapture") | |
| 129 == "Enabled"); | |
| 130 return avfoundation_requested && [AVFoundationBundle() load]; | |
| 119 } | 131 } |
| 120 | 132 |
| 121 NSBundle const* AVFoundationGlue::AVFoundationBundle() { | 133 NSBundle const* AVFoundationGlue::AVFoundationBundle() { |
| 122 return g_avfoundation_handle.Get().bundle(); | 134 return g_avfoundation_handle.Get().bundle(); |
| 123 } | 135 } |
| 124 | 136 |
| 125 void* AVFoundationGlue::AVFoundationLibraryHandle() { | 137 void* AVFoundationGlue::AVFoundationLibraryHandle() { |
| 126 return g_avfoundation_handle.Get().library_handle(); | 138 return g_avfoundation_handle.Get().library_handle(); |
| 127 } | 139 } |
| 128 | 140 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 @implementation AVCaptureDeviceInputGlue | 211 @implementation AVCaptureDeviceInputGlue |
| 200 | 212 |
| 201 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device | 213 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device |
| 202 error:(NSError**)outError { | 214 error:(NSError**)outError { |
| 203 return [[AVFoundationGlue::AVFoundationBundle() | 215 return [[AVFoundationGlue::AVFoundationBundle() |
| 204 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device | 216 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device |
| 205 error:outError]; | 217 error:outError]; |
| 206 } | 218 } |
| 207 | 219 |
| 208 @end // @implementation AVCaptureDeviceInputGlue | 220 @end // @implementation AVCaptureDeviceInputGlue |
| OLD | NEW |