| 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/base/mac/avfoundation_glue.h" | 5 #import "media/base/mac/avfoundation_glue.h" |
| 6 | 6 |
| 7 #import <AVFoundation/AVFoundation.h> | 7 #import <AVFoundation/AVFoundation.h> |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 delete static_cast<AVFoundationInternal*>(value); | 115 delete static_cast<AVFoundationInternal*>(value); |
| 116 } | 116 } |
| 117 | 117 |
| 118 AVFoundationInternal* GetAVFoundationInternal() { | 118 AVFoundationInternal* GetAVFoundationInternal() { |
| 119 return static_cast<AVFoundationInternal*>(g_avfoundation_handle.Get()); | 119 return static_cast<AVFoundationInternal*>(g_avfoundation_handle.Get()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // This contains the logic of checking whether AVFoundation is supported. | 122 // This contains the logic of checking whether AVFoundation is supported. |
| 123 // It's called only once and the results are cached in a static bool. | 123 // It's called only once and the results are cached in a static bool. |
| 124 bool LoadAVFoundationInternal() { | 124 bool LoadAVFoundationInternal() { |
| 125 // AVFoundation is only available on OS Lion and above. | |
| 126 if (!base::mac::IsOSLionOrLater()) { | |
| 127 LogCaptureApi(CAPTURE_API_QTKIT_DUE_TO_OS_PREVIOUS_TO_LION); | |
| 128 return false; | |
| 129 } | |
| 130 | |
| 131 const base::CommandLine* command_line = | |
| 132 base::CommandLine::ForCurrentProcess(); | |
| 133 // The force-qtkit flag takes precedence over enable-avfoundation. | |
| 134 if (command_line->HasSwitch(switches::kForceQTKit)) { | |
| 135 LogCaptureApi(CAPTURE_API_QTKIT_FORCED_BY_FLAG); | |
| 136 return false; | |
| 137 } | |
| 138 | |
| 139 if (!command_line->HasSwitch(switches::kEnableAVFoundation)) { | |
| 140 LogCaptureApi(CAPTURE_API_QTKIT_DUE_TO_NO_FLAG); | |
| 141 return false; | |
| 142 } | |
| 143 g_avfoundation_handle.Initialize(TlsCleanup); | 125 g_avfoundation_handle.Initialize(TlsCleanup); |
| 144 g_avfoundation_handle.Set(new AVFoundationInternal()); | 126 g_avfoundation_handle.Set(new AVFoundationInternal()); |
| 145 const bool ret = [AVFoundationGlue::AVFoundationBundle() load]; | 127 const bool ret = [AVFoundationGlue::AVFoundationBundle() load]; |
| 146 LogCaptureApi(ret ? CAPTURE_API_AVFOUNDATION_LOADED_OK | 128 LogCaptureApi(ret ? CAPTURE_API_AVFOUNDATION_LOADED_OK |
| 147 : CAPTURE_API_QTKIT_DUE_TO_AVFOUNDATION_LOAD_ERROR); | 129 : CAPTURE_API_QTKIT_DUE_TO_AVFOUNDATION_LOAD_ERROR); |
| 148 | 130 |
| 149 return ret; | 131 return ret; |
| 150 } | 132 } |
| 151 | 133 |
| 152 enum { | 134 enum { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 @implementation AVCaptureDeviceInputGlue | 230 @implementation AVCaptureDeviceInputGlue |
| 249 | 231 |
| 250 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device | 232 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device |
| 251 error:(NSError**)outError { | 233 error:(NSError**)outError { |
| 252 return [[AVFoundationGlue::AVFoundationBundle() | 234 return [[AVFoundationGlue::AVFoundationBundle() |
| 253 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device | 235 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device |
| 254 error:outError]; | 236 error:outError]; |
| 255 } | 237 } |
| 256 | 238 |
| 257 @end // @implementation AVCaptureDeviceInputGlue | 239 @end // @implementation AVCaptureDeviceInputGlue |
| OLD | NEW |