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

Unified Diff: media/video/capture/win/video_capture_device_win.cc

Issue 17402002: Reconnect support for DirectShow video capture devices in parallel to MediaFoundation ones. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected silly mistake in function call Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/video/capture/win/video_capture_device_win.cc
diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc
index 2066066771728801fa36276be04f7925a2974cb2..76704fe1f586a8ce5d0fa3c5703b341ad9094fd2 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -148,26 +148,46 @@ void DeleteMediaType(AM_MEDIA_TYPE* mt) {
// static
void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
+ Names::iterator it;
+
if (VideoCaptureDeviceMFWin::PlatformSupported()) {
VideoCaptureDeviceMFWin::GetDeviceNames(device_names);
- } else {
- VideoCaptureDeviceWin::GetDeviceNames(device_names);
+ it = device_names->begin();
+ for (; it != device_names->end(); ++it)
+ it->capture_api_type(Name::MEDIA_FOUNDATION);
tommi (sloooow) - chröme 2013/07/03 12:06:51 do this instead inside VideoCaptureDeviceMFWin::Ge
mcasas 2013/07/03 12:41:10 I agree. Wasn't sure on that one, if it was best t
}
+ // Retrieve the devices with DirectShow (DS) interface. They might (partially)
+ // overlap with the MediaFoundation (MF), so the list has to be consolidated.
+ Names temp_names;
+ VideoCaptureDeviceWin::GetDeviceNames(&temp_names);
+ it = temp_names.begin();
+ for (; it != temp_names.end(); ++it)
+ it->capture_api_type(Name::DIRECT_SHOW);
+
+ // Merge the DS devices into the MF device list, and next remove
+ // the duplicates, giving priority to the MF "versions".
+ device_names->merge(temp_names);
+ device_names->unique();
}
// static
VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
VideoCaptureDevice* ret = NULL;
- if (VideoCaptureDeviceMFWin::PlatformSupported()) {
+ if ((device_name.capture_api_type() == Name::MEDIA_FOUNDATION) &&
+ VideoCaptureDeviceMFWin::PlatformSupported()) {
scoped_ptr<VideoCaptureDeviceMFWin> device(
new VideoCaptureDeviceMFWin(device_name));
+ DLOG(INFO) << " MediaFoundation Device: " << device_name.name();
if (device->Init())
ret = device.release();
- } else {
+ } else if (device_name.capture_api_type() == Name::DIRECT_SHOW) {
scoped_ptr<VideoCaptureDeviceWin> device(
new VideoCaptureDeviceWin(device_name));
+ DLOG(INFO) << " DirectShow Device: " << device_name.name();
if (device->Init())
ret = device.release();
+ } else{
+ DLOG(ERROR) << " Couldn't recognize VideoCaptureDevice type";
tommi (sloooow) - chröme 2013/07/03 12:06:51 NOTREACHED()?
mcasas 2013/07/03 12:41:10 Done.
}
return ret;
@@ -575,10 +595,14 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() {
capability.color = VideoCaptureCapability::kYUY2;
} else if (media_type->subtype == MEDIASUBTYPE_MJPG) {
capability.color = VideoCaptureCapability::kMJPEG;
+ } else if (media_type->subtype == MEDIASUBTYPE_UYVY) {
+ capability.color = VideoCaptureCapability::kUYVY;
+ } else if (media_type->subtype == MEDIASUBTYPE_ARGB32) {
+ capability.color = VideoCaptureCapability::kARGB;
} else {
WCHAR guid_str[128];
StringFromGUID2(media_type->subtype, guid_str, arraysize(guid_str));
- DVLOG(2) << "Device support unknown media type " << guid_str;
+ DVLOG(2) << "Device supports (also) an unknown media type " << guid_str;
continue;
}
capabilities_.Add(capability);
@@ -596,5 +620,4 @@ void VideoCaptureDeviceWin::SetErrorState(const char* reason) {
state_ = kError;
observer_->OnError();
}
-
} // namespace media
« media/video/capture/video_capture_device.h ('K') | « media/video/capture/video_capture_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698