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

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: retry patch 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
« no previous file with comments | « media/video/capture/video_capture_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bd0446c9459717c4a358ad8e49bdf9b2b8bd7088..ebf5d391748afac0657f41db58d1bbf3a05fb7bd 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -149,28 +149,59 @@ namespace media {
// 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;
}
+ // 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 = device_names->begin();
+
+ // 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;
+ Names::iterator it;
tommi (sloooow) - chröme 2013/06/26 09:57:27 you shouldn't need to do any enumeration or search
mcasas 2013/07/02 12:28:11 Done.
+ Names device_names;
+
+ // We search for the device name in the list of devices that MF Api gives.
if (VideoCaptureDeviceMFWin::PlatformSupported()) {
- scoped_ptr<VideoCaptureDeviceMFWin> device(
- new VideoCaptureDeviceMFWin(device_name));
- if (device->Init())
- ret = device.release();
- } else {
- scoped_ptr<VideoCaptureDeviceWin> device(
- new VideoCaptureDeviceWin(device_name));
- if (device->Init())
- ret = device.release();
+ VideoCaptureDeviceMFWin::GetDeviceNames(&device_names);
+ it = device_names.begin();
+ for (; it != device_names.end(); ++it)
+ if (*it == device_name) {
+ DLOG(WARNING) << " MediaFoundation Device: " << device_name.device_name;
+ scoped_ptr<VideoCaptureDeviceMFWin> device(
+ new VideoCaptureDeviceMFWin(device_name));
+ if (device->Init())
+ ret = device.release();
+ return ret;
+ }
}
+ VideoCaptureDeviceWin::GetDeviceNames(&device_names);
+ it = device_names.begin();
+ for (; it != device_names.end(); ++it)
+ if (*it == device_name) {
+ DLOG(WARNING) << " DirectShow Device: " << device_name.device_name;
+ scoped_ptr<VideoCaptureDeviceWin> device(
+ new VideoCaptureDeviceWin(device_name));
+ if (device->Init())
+ ret = device.release();
+ return ret;
+ }
+ DLOG(ERROR) << "Couldn't recognize VideoCaptureDevice type!";
return ret;
}
@@ -575,6 +606,10 @@ 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));
@@ -596,5 +631,4 @@ void VideoCaptureDeviceWin::SetErrorState(const char* reason) {
state_ = kError;
observer_->OnError();
}
-
} // namespace media
« no previous file with comments | « 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