| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 // AVFoundation is only available on OS Lion and above. | 114 // AVFoundation is only available on OS Lion and above. |
| 115 if (!base::mac::IsOSLionOrLater()) | 115 if (!base::mac::IsOSLionOrLater()) |
| 116 return false; | 116 return false; |
| 117 | 117 |
| 118 // The force-qtkit flag takes precedence over enable-avfoundation. | 118 // The force-qtkit flag takes precedence over enable-avfoundation. |
| 119 if (command_line->HasSwitch(switches::kForceQTKit)) | 119 if (command_line->HasSwitch(switches::kForceQTKit)) |
| 120 return false; | 120 return false; |
| 121 | 121 |
| 122 // Next in precedence is the enable-avfoundation flag. | 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 // TODO(vrk): Does this really need to be static? | 123 // TODO(vrk): Does this really need to be static? |
| 127 static bool should_enable_avfoundation = | 124 static bool should_enable_avfoundation = |
| 128 command_line->HasSwitch(switches::kEnableAVFoundation) || | 125 command_line->HasSwitch(switches::kEnableAVFoundation) || |
| 129 base::FieldTrialList::FindFullName("AVFoundationMacVideoCapture") | 126 base::FieldTrialList::FindFullName("AVFoundationMacVideoCapture") |
| 130 == "Enabled"; | 127 == "Enabled"; |
| 131 // Try to load AVFoundation. Save result in static bool to avoid loading | 128 // Try to load AVFoundation. Save result in static bool to avoid loading |
| 132 // AVFoundationBundle every call. | 129 // AVFoundationBundle every call. |
| 133 static bool loaded_successfully = [AVFoundationBundle() load]; | 130 static bool loaded_successfully = [AVFoundationBundle() load]; |
| 134 return should_enable_avfoundation && loaded_successfully; | 131 return should_enable_avfoundation && loaded_successfully; |
| 135 } | 132 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 @implementation AVCaptureDeviceInputGlue | 212 @implementation AVCaptureDeviceInputGlue |
| 216 | 213 |
| 217 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device | 214 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device |
| 218 error:(NSError**)outError { | 215 error:(NSError**)outError { |
| 219 return [[AVFoundationGlue::AVFoundationBundle() | 216 return [[AVFoundationGlue::AVFoundationBundle() |
| 220 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device | 217 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device |
| 221 error:outError]; | 218 error:outError]; |
| 222 } | 219 } |
| 223 | 220 |
| 224 @end // @implementation AVCaptureDeviceInputGlue | 221 @end // @implementation AVCaptureDeviceInputGlue |
| OLD | NEW |