OLD | NEW |
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/capture/video/win/video_capture_device_mf_win.h" | 5 #include "media/capture/video/win/video_capture_device_mf_win.h" |
6 | 6 |
7 #include <mfapi.h> | 7 #include <mfapi.h> |
8 #include <mferror.h> | 8 #include <mferror.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
| 13 #include "base/big_endian.h" |
13 #include "base/location.h" | 14 #include "base/location.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
17 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
18 #include "base/win/scoped_co_mem.h" | 19 #include "base/win/scoped_co_mem.h" |
19 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
20 #include "media/capture/video/win/capability_list_win.h" | 21 #include "media/capture/video/win/capability_list_win.h" |
21 | 22 |
22 using base::win::ScopedCoMem; | 23 using base::win::ScopedCoMem; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 {MFVideoFormat_MJPG, PIXEL_FORMAT_MJPEG}, | 178 {MFVideoFormat_MJPG, PIXEL_FORMAT_MJPEG}, |
178 {MFVideoFormat_YV12, PIXEL_FORMAT_YV12}, | 179 {MFVideoFormat_YV12, PIXEL_FORMAT_YV12}, |
179 }; | 180 }; |
180 | 181 |
181 for (const auto& kFormat : kFormatMap) { | 182 for (const auto& kFormat : kFormatMap) { |
182 if (kFormat.guid == guid) { | 183 if (kFormat.guid == guid) { |
183 *format = kFormat.format; | 184 *format = kFormat.format; |
184 return true; | 185 return true; |
185 } | 186 } |
186 } | 187 } |
| 188 // TODO(astojilj) Define GUIDs and move this to common place as the code is |
| 189 // replicated around. |
| 190 uint32_t fourcc; |
| 191 base::ReadBigEndian(reinterpret_cast<const char*>(&guid.Data1), &fourcc); |
| 192 if (fourcc == 'Z16 ' || fourcc == 'INVZ') { |
| 193 *format = PIXEL_FORMAT_Y16; |
| 194 return true; |
| 195 } else if (fourcc == 'Y8 ') { |
| 196 *format = PIXEL_FORMAT_Y8; |
| 197 return true; |
| 198 } |
187 | 199 |
188 return false; | 200 return false; |
189 } | 201 } |
190 | 202 |
191 const std::string VideoCaptureDevice::Name::GetModel() const { | 203 const std::string VideoCaptureDevice::Name::GetModel() const { |
192 const size_t vid_prefix_size = sizeof(kVidPrefix) - 1; | 204 const size_t vid_prefix_size = sizeof(kVidPrefix) - 1; |
193 const size_t pid_prefix_size = sizeof(kPidPrefix) - 1; | 205 const size_t pid_prefix_size = sizeof(kPidPrefix) - 1; |
194 const size_t vid_location = unique_id_.find(kVidPrefix); | 206 const size_t vid_location = unique_id_.find(kVidPrefix); |
195 if (vid_location == std::string::npos || | 207 if (vid_location == std::string::npos || |
196 vid_location + vid_prefix_size + kVidPidSize > unique_id_.size()) { | 208 vid_location + vid_prefix_size + kVidPidSize > unique_id_.size()) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 HRESULT hr) { | 343 HRESULT hr) { |
332 if (client_.get()) { | 344 if (client_.get()) { |
333 client_->OnError( | 345 client_->OnError( |
334 from_here, | 346 from_here, |
335 base::StringPrintf("VideoCaptureDeviceMFWin: %s", | 347 base::StringPrintf("VideoCaptureDeviceMFWin: %s", |
336 logging::SystemErrorCodeToString(hr).c_str())); | 348 logging::SystemErrorCodeToString(hr).c_str())); |
337 } | 349 } |
338 } | 350 } |
339 | 351 |
340 } // namespace media | 352 } // namespace media |
OLD | NEW |