| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 }; | 101 }; |
| 102 | 102 |
| 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. |
| 112 static CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 111 static bool is_av_foundation_supported = base::mac::IsOSLionOrLater() && | 113 static bool is_av_foundation_supported = base::mac::IsOSLionOrLater() && |
| 112 (CommandLine::ForCurrentProcess()->HasSwitch( | 114 ((command_line->HasSwitch(switches::kEnableAVFoundation) && |
| 113 switches::kEnableAVFoundation) || | 115 !command_line->HasSwitch(switches::kForceQTKit)) || |
| 114 base::FieldTrialList::FindFullName("AVFoundationMacVideoCapture") | 116 base::FieldTrialList::FindFullName("AVFoundationMacVideoCapture") |
| 115 == "Enabled") && [AVFoundationBundle() load]; | 117 == "Enabled") && [AVFoundationBundle() load]; |
| 116 return is_av_foundation_supported; | 118 return is_av_foundation_supported; |
| 117 } | 119 } |
| 118 | 120 |
| 119 NSBundle const* AVFoundationGlue::AVFoundationBundle() { | 121 NSBundle const* AVFoundationGlue::AVFoundationBundle() { |
| 120 return g_avfoundation_handle.Get().bundle(); | 122 return g_avfoundation_handle.Get().bundle(); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void* AVFoundationGlue::AVFoundationLibraryHandle() { | 125 void* AVFoundationGlue::AVFoundationLibraryHandle() { |
| 124 return g_avfoundation_handle.Get().library_handle(); | 126 return g_avfoundation_handle.Get().library_handle(); |
| 125 } | 127 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 @implementation AVCaptureDeviceInputGlue | 199 @implementation AVCaptureDeviceInputGlue |
| 198 | 200 |
| 199 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device | 201 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device |
| 200 error:(NSError**)outError { | 202 error:(NSError**)outError { |
| 201 return [[AVFoundationGlue::AVFoundationBundle() | 203 return [[AVFoundationGlue::AVFoundationBundle() |
| 202 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device | 204 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device |
| 203 error:outError]; | 205 error:outError]; |
| 204 } | 206 } |
| 205 | 207 |
| 206 @end // @implementation AVCaptureDeviceInputGlue | 208 @end // @implementation AVCaptureDeviceInputGlue |
| OLD | NEW |