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

Side by Side 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, 5 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
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/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (mt != NULL) { 141 if (mt != NULL) {
142 FreeMediaType(mt); 142 FreeMediaType(mt);
143 CoTaskMemFree(mt); 143 CoTaskMemFree(mt);
144 } 144 }
145 } 145 }
146 146
147 } // namespace 147 } // namespace
148 148
149 // static 149 // static
150 void VideoCaptureDevice::GetDeviceNames(Names* device_names) { 150 void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
151 Names::iterator it;
152
151 if (VideoCaptureDeviceMFWin::PlatformSupported()) { 153 if (VideoCaptureDeviceMFWin::PlatformSupported()) {
152 VideoCaptureDeviceMFWin::GetDeviceNames(device_names); 154 VideoCaptureDeviceMFWin::GetDeviceNames(device_names);
153 } else { 155 it = device_names->begin();
154 VideoCaptureDeviceWin::GetDeviceNames(device_names); 156 for (; it != device_names->end(); ++it)
157 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
155 } 158 }
159 // Retrieve the devices with DirectShow (DS) interface. They might (partially)
160 // overlap with the MediaFoundation (MF), so the list has to be consolidated.
161 Names temp_names;
162 VideoCaptureDeviceWin::GetDeviceNames(&temp_names);
163 it = temp_names.begin();
164 for (; it != temp_names.end(); ++it)
165 it->capture_api_type(Name::DIRECT_SHOW);
166
167 // Merge the DS devices into the MF device list, and next remove
168 // the duplicates, giving priority to the MF "versions".
169 device_names->merge(temp_names);
170 device_names->unique();
156 } 171 }
157 172
158 // static 173 // static
159 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { 174 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
160 VideoCaptureDevice* ret = NULL; 175 VideoCaptureDevice* ret = NULL;
161 if (VideoCaptureDeviceMFWin::PlatformSupported()) { 176 if ((device_name.capture_api_type() == Name::MEDIA_FOUNDATION) &&
177 VideoCaptureDeviceMFWin::PlatformSupported()) {
162 scoped_ptr<VideoCaptureDeviceMFWin> device( 178 scoped_ptr<VideoCaptureDeviceMFWin> device(
163 new VideoCaptureDeviceMFWin(device_name)); 179 new VideoCaptureDeviceMFWin(device_name));
180 DLOG(INFO) << " MediaFoundation Device: " << device_name.name();
164 if (device->Init()) 181 if (device->Init())
165 ret = device.release(); 182 ret = device.release();
166 } else { 183 } else if (device_name.capture_api_type() == Name::DIRECT_SHOW) {
167 scoped_ptr<VideoCaptureDeviceWin> device( 184 scoped_ptr<VideoCaptureDeviceWin> device(
168 new VideoCaptureDeviceWin(device_name)); 185 new VideoCaptureDeviceWin(device_name));
186 DLOG(INFO) << " DirectShow Device: " << device_name.name();
169 if (device->Init()) 187 if (device->Init())
170 ret = device.release(); 188 ret = device.release();
189 } else{
190 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.
171 } 191 }
172 192
173 return ret; 193 return ret;
174 } 194 }
175 195
176 // static 196 // static
177 void VideoCaptureDeviceWin::GetDeviceNames(Names* device_names) { 197 void VideoCaptureDeviceWin::GetDeviceNames(Names* device_names) {
178 DCHECK(device_names); 198 DCHECK(device_names);
179 199
180 ScopedComPtr<ICreateDevEnum> dev_enum; 200 ScopedComPtr<ICreateDevEnum> dev_enum;
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 capability.color = VideoCaptureCapability::kI420; 588 capability.color = VideoCaptureCapability::kI420;
569 } else if (media_type->subtype == MEDIASUBTYPE_IYUV) { 589 } else if (media_type->subtype == MEDIASUBTYPE_IYUV) {
570 // This is identical to kI420. 590 // This is identical to kI420.
571 capability.color = VideoCaptureCapability::kI420; 591 capability.color = VideoCaptureCapability::kI420;
572 } else if (media_type->subtype == MEDIASUBTYPE_RGB24) { 592 } else if (media_type->subtype == MEDIASUBTYPE_RGB24) {
573 capability.color = VideoCaptureCapability::kRGB24; 593 capability.color = VideoCaptureCapability::kRGB24;
574 } else if (media_type->subtype == MEDIASUBTYPE_YUY2) { 594 } else if (media_type->subtype == MEDIASUBTYPE_YUY2) {
575 capability.color = VideoCaptureCapability::kYUY2; 595 capability.color = VideoCaptureCapability::kYUY2;
576 } else if (media_type->subtype == MEDIASUBTYPE_MJPG) { 596 } else if (media_type->subtype == MEDIASUBTYPE_MJPG) {
577 capability.color = VideoCaptureCapability::kMJPEG; 597 capability.color = VideoCaptureCapability::kMJPEG;
598 } else if (media_type->subtype == MEDIASUBTYPE_UYVY) {
599 capability.color = VideoCaptureCapability::kUYVY;
600 } else if (media_type->subtype == MEDIASUBTYPE_ARGB32) {
601 capability.color = VideoCaptureCapability::kARGB;
578 } else { 602 } else {
579 WCHAR guid_str[128]; 603 WCHAR guid_str[128];
580 StringFromGUID2(media_type->subtype, guid_str, arraysize(guid_str)); 604 StringFromGUID2(media_type->subtype, guid_str, arraysize(guid_str));
581 DVLOG(2) << "Device support unknown media type " << guid_str; 605 DVLOG(2) << "Device supports (also) an unknown media type " << guid_str;
582 continue; 606 continue;
583 } 607 }
584 capabilities_.Add(capability); 608 capabilities_.Add(capability);
585 } 609 }
586 DeleteMediaType(media_type); 610 DeleteMediaType(media_type);
587 media_type = NULL; 611 media_type = NULL;
588 } 612 }
589 613
590 return !capabilities_.empty(); 614 return !capabilities_.empty();
591 } 615 }
592 616
593 void VideoCaptureDeviceWin::SetErrorState(const char* reason) { 617 void VideoCaptureDeviceWin::SetErrorState(const char* reason) {
594 DCHECK(CalledOnValidThread()); 618 DCHECK(CalledOnValidThread());
595 DVLOG(1) << reason; 619 DVLOG(1) << reason;
596 state_ = kError; 620 state_ = kError;
597 observer_->OnError(); 621 observer_->OnError();
598 } 622 }
599
600 } // namespace media 623 } // namespace media
OLDNEW
« 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