OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 /* | 11 /* |
12 * video_capture_mac.cc | 12 * video_capture_mac.cc |
13 * | 13 * |
14 */ | 14 */ |
15 | 15 |
16 #include <QuickTime/QuickTime.h> | 16 #include <QuickTime/QuickTime.h> |
17 | 17 |
| 18 #include "webrtc/base/refcount.h" |
| 19 #include "webrtc/base/scoped_ref_ptr.h" |
18 #include "webrtc/modules/video_capture/device_info_impl.h" | 20 #include "webrtc/modules/video_capture/device_info_impl.h" |
19 #include "webrtc/modules/video_capture/video_capture_config.h" | 21 #include "webrtc/modules/video_capture/video_capture_config.h" |
20 #include "webrtc/modules/video_capture/video_capture_impl.h" | 22 #include "webrtc/modules/video_capture/video_capture_impl.h" |
21 #include "webrtc/system_wrappers/include/ref_count.h" | |
22 #include "webrtc/system_wrappers/include/trace.h" | 23 #include "webrtc/system_wrappers/include/trace.h" |
23 | 24 |
24 // 10.4 support must be decided runtime. We will just decide which framework to | 25 // 10.4 support must be decided runtime. We will just decide which framework to |
25 // use at compile time "work" classes. One for QTKit, one for QuickTime | 26 // use at compile time "work" classes. One for QTKit, one for QuickTime |
26 #if __MAC_OS_X_VERSION_MIN_REQUIRED == __MAC_10_4 // QuickTime version | 27 #if __MAC_OS_X_VERSION_MIN_REQUIRED == __MAC_10_4 // QuickTime version |
27 #include <QuickTime/video_capture_quick_time.h> | 28 #include <QuickTime/video_capture_quick_time.h> |
28 #include <QuickTime/video_capture_quick_time_info.h> | 29 #include <QuickTime/video_capture_quick_time_info.h> |
29 #else | 30 #else |
30 #include "webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit.h" | 31 #include "webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit.h" |
31 #include "webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_info.h" | 32 #include "webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_info.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 /* | 103 /* |
103 * Returns version of the module and its components | 104 * Returns version of the module and its components |
104 * | 105 * |
105 * version - buffer to which the version will be written | 106 * version - buffer to which the version will be written |
106 * remainingBufferInBytes - remaining number of int8_t in the version | 107 * remainingBufferInBytes - remaining number of int8_t in the version |
107 * buffer | 108 * buffer |
108 * position - position of the next empty int8_t in the | 109 * position - position of the next empty int8_t in the |
109 * version buffer | 110 * version buffer |
110 */ | 111 */ |
111 | 112 |
112 VideoCaptureModule* VideoCaptureImpl::Create( | 113 rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create( |
113 const int32_t id, const char* deviceUniqueIdUTF8) | 114 const int32_t id, |
114 { | 115 const char* deviceUniqueIdUTF8) { |
115 | 116 if (!CheckOSVersion()) { |
116 if (webrtc::videocapturemodule::CheckOSVersion() == false) | |
117 { | |
118 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, id, | 117 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, id, |
119 "OS version is too old. Could not create video capture " | 118 "OS version is too old. Could not create video capture " |
120 "module. Returning NULL"); | 119 "module. Returning NULL"); |
121 return NULL; | 120 return nullptr; |
122 } | 121 } |
123 | 122 |
124 #if __MAC_OS_X_VERSION_MIN_REQUIRED == __MAC_10_4 // QuickTime version | 123 #if __MAC_OS_X_VERSION_MIN_REQUIRED == __MAC_10_4 // QuickTime version |
125 if (webrtc::videocapturemodule::CheckQTVersion() == false) | 124 if (!CheckQTVersion()) |
126 { | 125 { |
127 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, id, | 126 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, id, |
128 "QuickTime version is too old. Could not create video " | 127 "QuickTime version is too old. Could not create video " |
129 "capture module. Returning NULL"); | 128 "capture module. Returning NULL"); |
130 return NULL; | 129 return nullptr; |
131 } | 130 } |
132 | 131 |
133 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, | 132 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, |
134 "%s line %d. QTKit is not supported on this machine. Using " | 133 "%s line %d. QTKit is not supported on this machine. Using " |
135 "QuickTime framework to capture video", | 134 "QuickTime framework to capture video", |
136 __FILE__, __LINE__); | 135 __FILE__, __LINE__); |
137 | 136 |
138 RefCountImpl<videocapturemodule::VideoCaptureMacQuickTime>* | 137 rtc::scoped_refptr<VideoCaptureMacQuickTime> newCaptureModule( |
139 newCaptureModule = | 138 new rtc::RefCountedObject<VideoCaptureMacQuickTime>(id)); |
140 new RefCountImpl<videocapturemodule::VideoCaptureMacQuickTime>(id); | |
141 | |
142 if (!newCaptureModule) | |
143 { | |
144 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, id, | |
145 "could not Create for unique device %s, !newCaptureModule", | |
146 deviceUniqueIdUTF8); | |
147 return NULL; | |
148 } | |
149 | 139 |
150 if (newCaptureModule->Init(id, deviceUniqueIdUTF8) != 0) | 140 if (newCaptureModule->Init(id, deviceUniqueIdUTF8) != 0) |
151 { | 141 { |
152 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, id, | 142 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, id, |
153 "could not Create for unique device %s, " | 143 "could not Create for unique device %s, " |
154 "newCaptureModule->Init()!=0", | 144 "newCaptureModule->Init()!=0", |
155 deviceUniqueIdUTF8); | 145 deviceUniqueIdUTF8); |
156 delete newCaptureModule; | 146 return nullptr; |
157 return NULL; | |
158 } | 147 } |
159 | 148 |
160 // Successfully created VideoCaptureMacQuicktime. Return it | 149 // Successfully created VideoCaptureMacQuicktime. Return it |
161 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, | 150 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, |
162 "Module created for unique device %s. Will use QuickTime " | 151 "Module created for unique device %s. Will use QuickTime " |
163 "framework to capture", | 152 "framework to capture", |
164 deviceUniqueIdUTF8); | 153 deviceUniqueIdUTF8); |
165 return newCaptureModule; | 154 return newCaptureModule; |
166 | 155 |
167 #else // QTKit version | 156 #else // QTKit version |
168 | 157 |
169 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, | 158 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, |
170 "Using QTKit framework to capture video", id); | 159 "Using QTKit framework to capture video", id); |
171 | 160 |
172 RefCountImpl<videocapturemodule::VideoCaptureMacQTKit>* newCaptureModule = | 161 rtc::scoped_refptr<VideoCaptureMacQTKit> newCaptureModule( |
173 new RefCountImpl<videocapturemodule::VideoCaptureMacQTKit>(id); | 162 new rtc::RefCountedObject<VideoCaptureMacQTKit>(id)); |
174 | 163 |
175 if(!newCaptureModule) | |
176 { | |
177 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, id, | |
178 "could not Create for unique device %s, !newCaptureModule", | |
179 deviceUniqueIdUTF8); | |
180 return NULL; | |
181 } | |
182 if(newCaptureModule->Init(id, deviceUniqueIdUTF8) != 0) | 164 if(newCaptureModule->Init(id, deviceUniqueIdUTF8) != 0) |
183 { | 165 { |
184 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, id, | 166 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, id, |
185 "could not Create for unique device %s, " | 167 "could not Create for unique device %s, " |
186 "newCaptureModule->Init()!=0", deviceUniqueIdUTF8); | 168 "newCaptureModule->Init()!=0", deviceUniqueIdUTF8); |
187 delete newCaptureModule; | 169 return nullptr; |
188 return NULL; | |
189 } | 170 } |
190 | 171 |
191 // Successfully created VideoCaptureMacQuicktime. Return it | 172 // Successfully created VideoCaptureMacQuicktime. Return it |
192 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, | 173 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, id, |
193 "Module created for unique device %s, will use QTKit " | 174 "Module created for unique device %s, will use QTKit " |
194 "framework",deviceUniqueIdUTF8); | 175 "framework",deviceUniqueIdUTF8); |
195 return newCaptureModule; | 176 return newCaptureModule; |
196 #endif | 177 #endif |
197 } | 178 } |
198 | 179 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 243 |
263 } | 244 } |
264 | 245 |
265 /************************************************************************** | 246 /************************************************************************** |
266 * | 247 * |
267 * End Create/Destroy VideoCaptureModule | 248 * End Create/Destroy VideoCaptureModule |
268 * | 249 * |
269 ***************************************************************************/ | 250 ***************************************************************************/ |
270 } // namespace videocapturemodule | 251 } // namespace videocapturemodule |
271 } // namespace webrtc | 252 } // namespace webrtc |
OLD | NEW |