Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: media/video/capture/win/video_capture_device_win.cc

Issue 262383003: Add Intel Perceptual Computing SDK based depth video capture for Windows Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/video/capture/win/video_capture_device_pxc_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "media/video/capture/win/video_capture_device_win.h" 5 #include "media/video/capture/win/video_capture_device_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/win/metro.h" 13 #include "base/win/metro.h"
14 #include "base/win/scoped_co_mem.h" 14 #include "base/win/scoped_co_mem.h"
15 #include "base/win/scoped_variant.h" 15 #include "base/win/scoped_variant.h"
16 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
17 #include "media/base/media_switches.h" 17 #include "media/base/media_switches.h"
18 #include "media/video/capture/win/video_capture_device_mf_win.h" 18 #include "media/video/capture/win/video_capture_device_mf_win.h"
19 #include "media/video/capture/win/video_capture_device_pxc_win.h"
20
19 21
20 using base::win::ScopedCoMem; 22 using base::win::ScopedCoMem;
21 using base::win::ScopedComPtr; 23 using base::win::ScopedComPtr;
22 using base::win::ScopedVariant; 24 using base::win::ScopedVariant;
23 25
24 namespace media { 26 namespace media {
25 namespace { 27 namespace {
26 28
27 // Finds and creates a DirectShow Video Capture filter matching the device_name. 29 // Finds and creates a DirectShow Video Capture filter matching the device_name.
28 HRESULT GetDeviceFilter(const VideoCaptureDevice::Name& device_name, 30 HRESULT GetDeviceFilter(const VideoCaptureDevice::Name& device_name,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // DirectShow for any other versions, unless forced via flag. Media Foundation 215 // DirectShow for any other versions, unless forced via flag. Media Foundation
214 // can also be forced if appropriate flag is set and we are in Windows 7 or 216 // can also be forced if appropriate flag is set and we are in Windows 7 or
215 // 8 in non-Metro mode. 217 // 8 in non-Metro mode.
216 if ((base::win::IsMetroProcess() && 218 if ((base::win::IsMetroProcess() &&
217 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) || 219 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) ||
218 (base::win::GetVersion() >= base::win::VERSION_WIN7 && 220 (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
219 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture))) { 221 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture))) {
220 VideoCaptureDeviceMFWin::GetDeviceNames(device_names); 222 VideoCaptureDeviceMFWin::GetDeviceNames(device_names);
221 } else { 223 } else {
222 VideoCaptureDeviceWin::GetDeviceNames(device_names); 224 VideoCaptureDeviceWin::GetDeviceNames(device_names);
225 if (cmd_line->HasSwitch(switches::kEnableDepthCamera)) {
226 if (VideoCaptureDevicePXCWin::PlatformSupported()) {
227 VideoCaptureDevicePXCWin::AppendDeviceNames(device_names);
228 }
229 }
223 } 230 }
224 } 231 }
225 232
226 // static 233 // static
227 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device, 234 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
228 VideoCaptureFormats* formats) { 235 VideoCaptureFormats* formats) {
229 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 236 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
230 // Use Media Foundation for Metro processes (after and including Win8) and 237 // Use Media Foundation for Metro processes (after and including Win8) and
231 // DirectShow for any other versions, unless forced via flag. Media Foundation 238 // DirectShow for any other versions, unless forced via flag. Media Foundation
232 // can also be forced if appropriate flag is set and we are in Windows 7 or 239 // can also be forced if appropriate flag is set and we are in Windows 7 or
233 // 8 in non-Metro mode. 240 // 8 in non-Metro mode.
234 if ((base::win::IsMetroProcess() && 241 if ((base::win::IsMetroProcess() &&
235 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) || 242 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) ||
236 (base::win::GetVersion() >= base::win::VERSION_WIN7 && 243 (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
237 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture))) { 244 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture))) {
238 VideoCaptureDeviceMFWin::GetDeviceSupportedFormats(device, formats); 245 VideoCaptureDeviceMFWin::GetDeviceSupportedFormats(device, formats);
239 } else { 246 } else {
247 if (cmd_line->HasSwitch(switches::kEnableDepthCamera)) {
248 if (VideoCaptureDevicePXCWin::IsDepthDevice(device)) {
249 VideoCaptureDevicePXCWin::GetDeviceSupportedFormats(device, formats);
250 return;
251 }
252 }
240 VideoCaptureDeviceWin::GetDeviceSupportedFormats(device, formats); 253 VideoCaptureDeviceWin::GetDeviceSupportedFormats(device, formats);
241 } 254 }
242 } 255 }
243 256
244 // static 257 // static
245 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { 258 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
259 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
246 VideoCaptureDevice* ret = NULL; 260 VideoCaptureDevice* ret = NULL;
247 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) { 261 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) {
248 DCHECK(VideoCaptureDeviceMFWin::PlatformSupported()); 262 DCHECK(VideoCaptureDeviceMFWin::PlatformSupported());
249 scoped_ptr<VideoCaptureDeviceMFWin> device( 263 scoped_ptr<VideoCaptureDeviceMFWin> device(
250 new VideoCaptureDeviceMFWin(device_name)); 264 new VideoCaptureDeviceMFWin(device_name));
251 DVLOG(1) << " MediaFoundation Device: " << device_name.name(); 265 DVLOG(1) << " MediaFoundation Device: " << device_name.name();
252 if (device->Init()) 266 if (device->Init())
253 ret = device.release(); 267 ret = device.release();
254 } else if (device_name.capture_api_type() == Name::DIRECT_SHOW) { 268 } else if (device_name.capture_api_type() == Name::DIRECT_SHOW) {
255 scoped_ptr<VideoCaptureDeviceWin> device( 269 scoped_ptr<VideoCaptureDeviceWin> device(
256 new VideoCaptureDeviceWin(device_name)); 270 new VideoCaptureDeviceWin(device_name));
257 DVLOG(1) << " DirectShow Device: " << device_name.name(); 271 DVLOG(1) << " DirectShow Device: " << device_name.name();
258 if (device->Init()) 272 if (device->Init())
259 ret = device.release(); 273 ret = device.release();
260 } else{ 274 } else if (cmd_line->HasSwitch(switches::kEnableDepthCamera) &&
275 device_name.capture_api_type() == Name::PXC_CAPTURE) {
276 DCHECK(VideoCaptureDevicePXCWin::PlatformSupported());
277 scoped_ptr<VideoCaptureDevicePXCWin> device(
278 new VideoCaptureDevicePXCWin(device_name));
279 DVLOG(1) << " PxcCapture Device: " << device_name.name();
280 if (device->Init())
281 ret = device.release();
282 } else {
261 NOTREACHED() << " Couldn't recognize VideoCaptureDevice type"; 283 NOTREACHED() << " Couldn't recognize VideoCaptureDevice type";
262 } 284 }
263 285
264 return ret; 286 return ret;
265 } 287 }
266 288
267 // static 289 // static
268 void VideoCaptureDeviceWin::GetDeviceNames(Names* device_names) { 290 void VideoCaptureDeviceWin::GetDeviceNames(Names* device_names) {
269 DCHECK(device_names); 291 DCHECK(device_names);
270 292
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 return !capabilities_.empty(); 771 return !capabilities_.empty();
750 } 772 }
751 773
752 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { 774 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) {
753 DCHECK(CalledOnValidThread()); 775 DCHECK(CalledOnValidThread());
754 DVLOG(1) << reason; 776 DVLOG(1) << reason;
755 state_ = kError; 777 state_ = kError;
756 client_->OnError(reason); 778 client_->OnError(reason);
757 } 779 }
758 } // namespace media 780 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/win/video_capture_device_pxc_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698