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

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: scherkus@ nit 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
« no previous file with comments | « media/video/capture/win/video_capture_device_win.h ('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 "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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 FreeMediaType(mt); 148 FreeMediaType(mt);
148 CoTaskMemFree(mt); 149 CoTaskMemFree(mt);
149 } 150 }
150 } 151 }
151 152
152 } // namespace 153 } // namespace
153 154
154 // static 155 // static
155 void VideoCaptureDevice::GetDeviceNames(Names* device_names) { 156 void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
156 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 157 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
157 // Use Media Foundation for Metro processes (after and including Win8) 158 // Use Media Foundation for Metro processes (after and including Win8) and
158 // and DirectShow for any other platforms. 159 // DirectShow for any other versions, unless forced via flag. Media Foundation
159 if (base::win::IsMetroProcess() && 160 // can also be forced if appropriate flag is set and we are in Windows 7 or
160 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) { 161 // 8 in non-Metro mode.
162 if ((base::win::IsMetroProcess() &&
163 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) ||
164 (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
165 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture))) {
161 VideoCaptureDeviceMFWin::GetDeviceNames(device_names); 166 VideoCaptureDeviceMFWin::GetDeviceNames(device_names);
162 } else { 167 } else {
163 VideoCaptureDeviceWin::GetDeviceNames(device_names); 168 VideoCaptureDeviceWin::GetDeviceNames(device_names);
164 } 169 }
165 } 170 }
166 171
167 // static 172 // static
168 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device, 173 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
169 VideoCaptureFormats* formats) { 174 VideoCaptureFormats* formats) {
170 NOTIMPLEMENTED(); 175 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
176 // Use Media Foundation for Metro processes (after and including Win8) and
177 // DirectShow for any other versions, unless forced via flag. Media Foundation
178 // can also be forced if appropriate flag is set and we are in Windows 7 or
179 // 8 in non-Metro mode.
180 if ((base::win::IsMetroProcess() &&
181 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) ||
182 (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
183 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture))) {
184 VideoCaptureDeviceMFWin::GetDeviceSupportedFormats(device, formats);
185 } else {
186 VideoCaptureDeviceWin::GetDeviceSupportedFormats(device, formats);
187 }
171 } 188 }
172 189
173 // static 190 // static
174 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { 191 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
175 VideoCaptureDevice* ret = NULL; 192 VideoCaptureDevice* ret = NULL;
176 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) { 193 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) {
177 DCHECK(VideoCaptureDeviceMFWin::PlatformSupported()); 194 DCHECK(VideoCaptureDeviceMFWin::PlatformSupported());
178 scoped_ptr<VideoCaptureDeviceMFWin> device( 195 scoped_ptr<VideoCaptureDeviceMFWin> device(
179 new VideoCaptureDeviceMFWin(device_name)); 196 new VideoCaptureDeviceMFWin(device_name));
180 DVLOG(1) << " MediaFoundation Device: " << device_name.name(); 197 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)); 273 id = base::SysWideToUTF8(V_BSTR(&name));
257 } 274 }
258 275
259 device_names->push_back(Name(device_name, id, Name::DIRECT_SHOW)); 276 device_names->push_back(Name(device_name, id, Name::DIRECT_SHOW));
260 } 277 }
261 } 278 }
262 moniker.Release(); 279 moniker.Release();
263 } 280 }
264 } 281 }
265 282
283 // static
284 void VideoCaptureDeviceWin::GetDeviceSupportedFormats(const Name& device,
285 VideoCaptureFormats* formats) {
286 NOTIMPLEMENTED();
287 }
288
266 VideoCaptureDeviceWin::VideoCaptureDeviceWin(const Name& device_name) 289 VideoCaptureDeviceWin::VideoCaptureDeviceWin(const Name& device_name)
267 : device_name_(device_name), 290 : device_name_(device_name),
268 state_(kIdle) { 291 state_(kIdle) {
269 DetachFromThread(); 292 DetachFromThread();
270 } 293 }
271 294
272 VideoCaptureDeviceWin::~VideoCaptureDeviceWin() { 295 VideoCaptureDeviceWin::~VideoCaptureDeviceWin() {
273 DCHECK(CalledOnValidThread()); 296 DCHECK(CalledOnValidThread());
274 if (media_control_) 297 if (media_control_)
275 media_control_->Stop(); 298 media_control_->Stop();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 return !capabilities_.empty(); 613 return !capabilities_.empty();
591 } 614 }
592 615
593 void VideoCaptureDeviceWin::SetErrorState(const char* reason) { 616 void VideoCaptureDeviceWin::SetErrorState(const char* reason) {
594 DCHECK(CalledOnValidThread()); 617 DCHECK(CalledOnValidThread());
595 DVLOG(1) << reason; 618 DVLOG(1) << reason;
596 state_ = kError; 619 state_ = kError;
597 client_->OnError(); 620 client_->OnError();
598 } 621 }
599 } // namespace media 622 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698