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_win.h" | 5 #include "media/capture/video/win/video_capture_device_win.h" |
6 | 6 |
7 #include <ks.h> | 7 #include <ks.h> |
8 #include <ksmedia.h> | 8 #include <ksmedia.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <list> | 11 #include <list> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
| 14 #include "base/big_endian.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
16 #include "base/win/scoped_co_mem.h" | 17 #include "base/win/scoped_co_mem.h" |
17 #include "base/win/scoped_variant.h" | 18 #include "base/win/scoped_variant.h" |
18 #include "media/base/timestamp_constants.h" | 19 #include "media/base/timestamp_constants.h" |
19 | 20 |
20 using base::win::ScopedCoMem; | 21 using base::win::ScopedCoMem; |
21 using base::win::ScopedComPtr; | 22 using base::win::ScopedComPtr; |
22 using base::win::ScopedVariant; | 23 using base::win::ScopedVariant; |
23 | 24 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 {MEDIASUBTYPE_YUY2, PIXEL_FORMAT_YUY2}, | 157 {MEDIASUBTYPE_YUY2, PIXEL_FORMAT_YUY2}, |
157 {MEDIASUBTYPE_MJPG, PIXEL_FORMAT_MJPEG}, | 158 {MEDIASUBTYPE_MJPG, PIXEL_FORMAT_MJPEG}, |
158 {MEDIASUBTYPE_UYVY, PIXEL_FORMAT_UYVY}, | 159 {MEDIASUBTYPE_UYVY, PIXEL_FORMAT_UYVY}, |
159 {MEDIASUBTYPE_ARGB32, PIXEL_FORMAT_ARGB}, | 160 {MEDIASUBTYPE_ARGB32, PIXEL_FORMAT_ARGB}, |
160 {kMediaSubTypeHDYC, PIXEL_FORMAT_UYVY}, | 161 {kMediaSubTypeHDYC, PIXEL_FORMAT_UYVY}, |
161 }; | 162 }; |
162 for (const auto& pixel_format : kMediaSubtypeToPixelFormatCorrespondence) { | 163 for (const auto& pixel_format : kMediaSubtypeToPixelFormatCorrespondence) { |
163 if (sub_type == pixel_format.sub_type) | 164 if (sub_type == pixel_format.sub_type) |
164 return pixel_format.format; | 165 return pixel_format.format; |
165 } | 166 } |
| 167 // TODO(astojilj) Define GUIDs and move this to common place as the code is |
| 168 // replicated around. |
| 169 uint32_t fourcc; |
| 170 base::ReadBigEndian(reinterpret_cast<const char*>(&sub_type.Data1), &fourcc); |
| 171 if (fourcc == 'Z16 ' || fourcc == 'INVZ') { |
| 172 return PIXEL_FORMAT_Y16; |
| 173 } else if (fourcc == 'Y8 ') { |
| 174 return PIXEL_FORMAT_Y8; |
| 175 } |
166 #ifndef NDEBUG | 176 #ifndef NDEBUG |
167 WCHAR guid_str[128]; | 177 WCHAR guid_str[128]; |
168 StringFromGUID2(sub_type, guid_str, arraysize(guid_str)); | 178 StringFromGUID2(sub_type, guid_str, arraysize(guid_str)); |
169 DVLOG(2) << "Device (also) supports an unknown media type " << guid_str; | 179 DVLOG(2) << "Device (also) supports an unknown media type " << guid_str; |
170 #endif | 180 #endif |
171 return PIXEL_FORMAT_UNKNOWN; | 181 return PIXEL_FORMAT_UNKNOWN; |
172 } | 182 } |
173 | 183 |
174 void VideoCaptureDeviceWin::ScopedMediaType::Free() { | 184 void VideoCaptureDeviceWin::ScopedMediaType::Free() { |
175 if (!media_type_) | 185 if (!media_type_) |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 594 } |
585 | 595 |
586 void VideoCaptureDeviceWin::SetErrorState( | 596 void VideoCaptureDeviceWin::SetErrorState( |
587 const tracked_objects::Location& from_here, | 597 const tracked_objects::Location& from_here, |
588 const std::string& reason) { | 598 const std::string& reason) { |
589 DCHECK(thread_checker_.CalledOnValidThread()); | 599 DCHECK(thread_checker_.CalledOnValidThread()); |
590 state_ = kError; | 600 state_ = kError; |
591 client_->OnError(from_here, reason); | 601 client_->OnError(from_here, reason); |
592 } | 602 } |
593 } // namespace media | 603 } // namespace media |
OLD | NEW |