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

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

Issue 149443003: Add GetDeviceSupportedFormats to VideoCaptureDeviceMFWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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/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 "media/base/media_switches.h" 17 #include "media/base/media_switches.h"
17 #include "media/video/capture/win/video_capture_device_mf_win.h" 18 #include "media/video/capture/win/video_capture_device_mf_win.h"
18 19
19 using base::win::ScopedCoMem; 20 using base::win::ScopedCoMem;
20 using base::win::ScopedComPtr; 21 using base::win::ScopedComPtr;
21 using base::win::ScopedVariant; 22 using base::win::ScopedVariant;
22 23
23 namespace media { 24 namespace media {
24 namespace { 25 namespace {
25 26
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) { 161 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) {
161 VideoCaptureDeviceMFWin::GetDeviceNames(device_names); 162 VideoCaptureDeviceMFWin::GetDeviceNames(device_names);
162 } else { 163 } else {
163 VideoCaptureDeviceWin::GetDeviceNames(device_names); 164 VideoCaptureDeviceWin::GetDeviceNames(device_names);
164 } 165 }
165 } 166 }
166 167
167 // static 168 // static
168 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device, 169 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
169 VideoCaptureFormats* formats) { 170 VideoCaptureFormats* formats) {
170 NOTIMPLEMENTED(); 171 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
172 // Use Media Foundation for Metro processes (after and including Win8) and
173 // DirectShow for any other versions, unless forced via flag. Media Foundation
174 // can also be forced if appropriate flag is set and we are in Windows 7 or
175 // 8 in non-Metro mode.
176 if ((base::win::IsMetroProcess() &&
177 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) ||
178 (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
179 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture))) {
180 VideoCaptureDeviceMFWin::GetDeviceSupportedFormats(device, formats);
181 } else {
182 VideoCaptureDeviceWin::GetDeviceSupportedFormats(device, formats);
183 }
171 } 184 }
172 185
173 // static 186 // static
174 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { 187 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
175 VideoCaptureDevice* ret = NULL; 188 VideoCaptureDevice* ret = NULL;
176 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) { 189 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) {
177 DCHECK(VideoCaptureDeviceMFWin::PlatformSupported()); 190 DCHECK(VideoCaptureDeviceMFWin::PlatformSupported());
178 scoped_ptr<VideoCaptureDeviceMFWin> device( 191 scoped_ptr<VideoCaptureDeviceMFWin> device(
179 new VideoCaptureDeviceMFWin(device_name)); 192 new VideoCaptureDeviceMFWin(device_name));
180 DVLOG(1) << " MediaFoundation Device: " << device_name.name(); 193 DVLOG(1) << " MediaFoundation Device: " << device_name.name();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 id = base::SysWideToUTF8(V_BSTR(&name)); 269 id = base::SysWideToUTF8(V_BSTR(&name));
257 } 270 }
258 271
259 device_names->push_back(Name(device_name, id, Name::DIRECT_SHOW)); 272 device_names->push_back(Name(device_name, id, Name::DIRECT_SHOW));
260 } 273 }
261 } 274 }
262 moniker.Release(); 275 moniker.Release();
263 } 276 }
264 } 277 }
265 278
279 //static
tommi (sloooow) - chröme 2014/01/30 13:25:17 // static
mcasas 2014/01/30 16:29:23 Done.
280 void VideoCaptureDeviceWin::GetDeviceSupportedFormats(const Name& device,
281 VideoCaptureFormats* formats) {
282 NOTIMPLEMENTED();
283 }
284
266 VideoCaptureDeviceWin::VideoCaptureDeviceWin(const Name& device_name) 285 VideoCaptureDeviceWin::VideoCaptureDeviceWin(const Name& device_name)
267 : device_name_(device_name), 286 : device_name_(device_name),
268 state_(kIdle) { 287 state_(kIdle) {
269 DetachFromThread(); 288 DetachFromThread();
270 } 289 }
271 290
272 VideoCaptureDeviceWin::~VideoCaptureDeviceWin() { 291 VideoCaptureDeviceWin::~VideoCaptureDeviceWin() {
273 DCHECK(CalledOnValidThread()); 292 DCHECK(CalledOnValidThread());
274 if (media_control_) 293 if (media_control_)
275 media_control_->Stop(); 294 media_control_->Stop();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 return !capabilities_.empty(); 609 return !capabilities_.empty();
591 } 610 }
592 611
593 void VideoCaptureDeviceWin::SetErrorState(const char* reason) { 612 void VideoCaptureDeviceWin::SetErrorState(const char* reason) {
594 DCHECK(CalledOnValidThread()); 613 DCHECK(CalledOnValidThread());
595 DVLOG(1) << reason; 614 DVLOG(1) << reason;
596 state_ = kError; 615 state_ = kError;
597 client_->OnError(); 616 client_->OnError();
598 } 617 }
599 } // namespace media 618 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698