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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 {&AVMediaTypeMuxed_, "AVMediaTypeMuxed"}, | 42 {&AVMediaTypeMuxed_, "AVMediaTypeMuxed"}, |
43 {&AVCaptureSessionRuntimeErrorNotification_, | 43 {&AVCaptureSessionRuntimeErrorNotification_, |
44 "AVCaptureSessionRuntimeErrorNotification"}, | 44 "AVCaptureSessionRuntimeErrorNotification"}, |
45 {&AVCaptureSessionDidStopRunningNotification_, | 45 {&AVCaptureSessionDidStopRunningNotification_, |
46 "AVCaptureSessionDidStopRunningNotification"}, | 46 "AVCaptureSessionDidStopRunningNotification"}, |
47 {&AVCaptureSessionErrorKey_, "AVCaptureSessionErrorKey"}, | 47 {&AVCaptureSessionErrorKey_, "AVCaptureSessionErrorKey"}, |
48 {&AVCaptureSessionPreset320x240_, "AVCaptureSessionPreset320x240"}, | 48 {&AVCaptureSessionPreset320x240_, "AVCaptureSessionPreset320x240"}, |
49 {&AVCaptureSessionPreset640x480_, "AVCaptureSessionPreset640x480"}, | 49 {&AVCaptureSessionPreset640x480_, "AVCaptureSessionPreset640x480"}, |
50 {&AVCaptureSessionPreset1280x720_, "AVCaptureSessionPreset1280x720"}, | 50 {&AVCaptureSessionPreset1280x720_, "AVCaptureSessionPreset1280x720"}, |
51 {&AVVideoScalingModeKey_, "AVVideoScalingModeKey"}, | 51 {&AVVideoScalingModeKey_, "AVVideoScalingModeKey"}, |
52 {&AVVideoScalingModeResizeAspect_, "AVVideoScalingModeResizeAspect"}, | 52 {&AVVideoScalingModeResizeAspectFill_, |
| 53 "AVVideoScalingModeResizeAspectFill"}, |
53 }; | 54 }; |
54 for (size_t i = 0; i < arraysize(av_strings); ++i) { | 55 for (size_t i = 0; i < arraysize(av_strings); ++i) { |
55 *av_strings[i].loaded_string = *reinterpret_cast<NSString**>( | 56 *av_strings[i].loaded_string = *reinterpret_cast<NSString**>( |
56 dlsym(library_handle_, av_strings[i].symbol)); | 57 dlsym(library_handle_, av_strings[i].symbol)); |
57 DCHECK(*av_strings[i].loaded_string) << dlerror(); | 58 DCHECK(*av_strings[i].loaded_string) << dlerror(); |
58 } | 59 } |
59 } | 60 } |
60 | 61 |
61 NSBundle* bundle() const { return bundle_; } | 62 NSBundle* bundle() const { return bundle_; } |
62 void* library_handle() const { return library_handle_; } | 63 void* library_handle() const { return library_handle_; } |
(...skipping 19 matching lines...) Expand all Loading... |
82 NSString* AVCaptureSessionPreset320x240() const { | 83 NSString* AVCaptureSessionPreset320x240() const { |
83 return AVCaptureSessionPreset320x240_; | 84 return AVCaptureSessionPreset320x240_; |
84 } | 85 } |
85 NSString* AVCaptureSessionPreset640x480() const { | 86 NSString* AVCaptureSessionPreset640x480() const { |
86 return AVCaptureSessionPreset640x480_; | 87 return AVCaptureSessionPreset640x480_; |
87 } | 88 } |
88 NSString* AVCaptureSessionPreset1280x720() const { | 89 NSString* AVCaptureSessionPreset1280x720() const { |
89 return AVCaptureSessionPreset1280x720_; | 90 return AVCaptureSessionPreset1280x720_; |
90 } | 91 } |
91 NSString* AVVideoScalingModeKey() const { return AVVideoScalingModeKey_; } | 92 NSString* AVVideoScalingModeKey() const { return AVVideoScalingModeKey_; } |
92 NSString* AVVideoScalingModeResizeAspect() const { | 93 NSString* AVVideoScalingModeResizeAspectFill() const { |
93 return AVVideoScalingModeResizeAspect_; | 94 return AVVideoScalingModeResizeAspectFill_; |
94 } | 95 } |
95 | 96 |
96 private: | 97 private: |
97 NSBundle* bundle_; | 98 NSBundle* bundle_; |
98 void* library_handle_; | 99 void* library_handle_; |
99 // The following members are replicas of the respectives in AVFoundation. | 100 // The following members are replicas of the respectives in AVFoundation. |
100 NSString* AVCaptureDeviceWasConnectedNotification_; | 101 NSString* AVCaptureDeviceWasConnectedNotification_; |
101 NSString* AVCaptureDeviceWasDisconnectedNotification_; | 102 NSString* AVCaptureDeviceWasDisconnectedNotification_; |
102 NSString* AVMediaTypeVideo_; | 103 NSString* AVMediaTypeVideo_; |
103 NSString* AVMediaTypeAudio_; | 104 NSString* AVMediaTypeAudio_; |
104 NSString* AVMediaTypeMuxed_; | 105 NSString* AVMediaTypeMuxed_; |
105 NSString* AVCaptureSessionRuntimeErrorNotification_; | 106 NSString* AVCaptureSessionRuntimeErrorNotification_; |
106 NSString* AVCaptureSessionDidStopRunningNotification_; | 107 NSString* AVCaptureSessionDidStopRunningNotification_; |
107 NSString* AVCaptureSessionErrorKey_; | 108 NSString* AVCaptureSessionErrorKey_; |
108 NSString* AVCaptureSessionPreset320x240_; | 109 NSString* AVCaptureSessionPreset320x240_; |
109 NSString* AVCaptureSessionPreset640x480_; | 110 NSString* AVCaptureSessionPreset640x480_; |
110 NSString* AVCaptureSessionPreset1280x720_; | 111 NSString* AVCaptureSessionPreset1280x720_; |
111 NSString* AVVideoScalingModeKey_; | 112 NSString* AVVideoScalingModeKey_; |
112 NSString* AVVideoScalingModeResizeAspect_; | 113 NSString* AVVideoScalingModeResizeAspectFill_; |
113 | 114 |
114 DISALLOW_COPY_AND_ASSIGN(AVFoundationInternal); | 115 DISALLOW_COPY_AND_ASSIGN(AVFoundationInternal); |
115 }; | 116 }; |
116 | 117 |
117 } // namespace | 118 } // namespace |
118 | 119 |
119 static base::LazyInstance<AVFoundationInternal> g_avfoundation_handle = | 120 static base::LazyInstance<AVFoundationInternal> g_avfoundation_handle = |
120 LAZY_INSTANCE_INITIALIZER; | 121 LAZY_INSTANCE_INITIALIZER; |
121 | 122 |
122 bool AVFoundationGlue::IsAVFoundationSupported() { | 123 bool AVFoundationGlue::IsAVFoundationSupported() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 182 } |
182 | 183 |
183 NSString* AVFoundationGlue::AVCaptureSessionPreset1280x720() { | 184 NSString* AVFoundationGlue::AVCaptureSessionPreset1280x720() { |
184 return g_avfoundation_handle.Get().AVCaptureSessionPreset1280x720(); | 185 return g_avfoundation_handle.Get().AVCaptureSessionPreset1280x720(); |
185 } | 186 } |
186 | 187 |
187 NSString* AVFoundationGlue::AVVideoScalingModeKey() { | 188 NSString* AVFoundationGlue::AVVideoScalingModeKey() { |
188 return g_avfoundation_handle.Get().AVVideoScalingModeKey(); | 189 return g_avfoundation_handle.Get().AVVideoScalingModeKey(); |
189 } | 190 } |
190 | 191 |
191 NSString* AVFoundationGlue::AVVideoScalingModeResizeAspect() { | 192 NSString* AVFoundationGlue::AVVideoScalingModeResizeAspectFill() { |
192 return g_avfoundation_handle.Get().AVVideoScalingModeResizeAspect(); | 193 return g_avfoundation_handle.Get().AVVideoScalingModeResizeAspectFill(); |
193 } | 194 } |
194 | 195 |
195 Class AVFoundationGlue::AVCaptureSessionClass() { | 196 Class AVFoundationGlue::AVCaptureSessionClass() { |
196 return [AVFoundationBundle() classNamed:@"AVCaptureSession"]; | 197 return [AVFoundationBundle() classNamed:@"AVCaptureSession"]; |
197 } | 198 } |
198 | 199 |
199 Class AVFoundationGlue::AVCaptureVideoDataOutputClass() { | 200 Class AVFoundationGlue::AVCaptureVideoDataOutputClass() { |
200 return [AVFoundationBundle() classNamed:@"AVCaptureVideoDataOutput"]; | 201 return [AVFoundationBundle() classNamed:@"AVCaptureVideoDataOutput"]; |
201 } | 202 } |
202 | 203 |
(...skipping 20 matching lines...) Expand all Loading... |
223 @implementation AVCaptureDeviceInputGlue | 224 @implementation AVCaptureDeviceInputGlue |
224 | 225 |
225 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device | 226 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device |
226 error:(NSError**)outError { | 227 error:(NSError**)outError { |
227 return [[AVFoundationGlue::AVFoundationBundle() | 228 return [[AVFoundationGlue::AVFoundationBundle() |
228 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device | 229 classNamed:@"AVCaptureDeviceInput"] deviceInputWithDevice:device |
229 error:outError]; | 230 error:outError]; |
230 } | 231 } |
231 | 232 |
232 @end // @implementation AVCaptureDeviceInputGlue | 233 @end // @implementation AVCaptureDeviceInputGlue |
OLD | NEW |