| 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 "device/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/location.h" | 13 #include "base/location.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/win/scoped_co_mem.h" | 18 #include "base/win/scoped_co_mem.h" |
| 19 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
| 20 #include "media/capture/video/win/capability_list_win.h" | 20 #include "device/capture/video/win/capability_list_win.h" |
| 21 | 21 |
| 22 using base::win::ScopedCoMem; | 22 using base::win::ScopedCoMem; |
| 23 using base::win::ScopedComPtr; | 23 using base::win::ScopedComPtr; |
| 24 | 24 |
| 25 namespace media { | 25 namespace device { |
| 26 | 26 |
| 27 static bool GetFrameSize(IMFMediaType* type, gfx::Size* frame_size) { | 27 static bool GetFrameSize(IMFMediaType* type, gfx::Size* frame_size) { |
| 28 UINT32 width32, height32; | 28 UINT32 width32, height32; |
| 29 if (FAILED(MFGetAttributeSize(type, MF_MT_FRAME_SIZE, &width32, &height32))) | 29 if (FAILED(MFGetAttributeSize(type, MF_MT_FRAME_SIZE, &width32, &height32))) |
| 30 return false; | 30 return false; |
| 31 frame_size->SetSize(width32, height32); | 31 frame_size->SetSize(width32, height32); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 static bool GetFrameRate(IMFMediaType* type, float* frame_rate) { | 35 static bool GetFrameRate(IMFMediaType* type, float* frame_rate) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 base::WaitableEvent* wait_event_; | 156 base::WaitableEvent* wait_event_; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 // static | 159 // static |
| 160 bool VideoCaptureDeviceMFWin::FormatFromGuid(const GUID& guid, | 160 bool VideoCaptureDeviceMFWin::FormatFromGuid(const GUID& guid, |
| 161 VideoPixelFormat* format) { | 161 VideoPixelFormat* format) { |
| 162 struct { | 162 struct { |
| 163 const GUID& guid; | 163 const GUID& guid; |
| 164 const VideoPixelFormat format; | 164 const VideoPixelFormat format; |
| 165 } static const kFormatMap[] = { | 165 } static const kFormatMap[] = { |
| 166 {MFVideoFormat_I420, PIXEL_FORMAT_I420}, | 166 {MFVideoFormat_I420, media::PIXEL_FORMAT_I420}, |
| 167 {MFVideoFormat_YUY2, PIXEL_FORMAT_YUY2}, | 167 {MFVideoFormat_YUY2, media::PIXEL_FORMAT_YUY2}, |
| 168 {MFVideoFormat_UYVY, PIXEL_FORMAT_UYVY}, | 168 {MFVideoFormat_UYVY, media::PIXEL_FORMAT_UYVY}, |
| 169 {MFVideoFormat_RGB24, PIXEL_FORMAT_RGB24}, | 169 {MFVideoFormat_RGB24, media::PIXEL_FORMAT_RGB24}, |
| 170 {MFVideoFormat_ARGB32, PIXEL_FORMAT_ARGB}, | 170 {MFVideoFormat_ARGB32, media::PIXEL_FORMAT_ARGB}, |
| 171 {MFVideoFormat_MJPG, PIXEL_FORMAT_MJPEG}, | 171 {MFVideoFormat_MJPG, media::PIXEL_FORMAT_MJPEG}, |
| 172 {MFVideoFormat_YV12, PIXEL_FORMAT_YV12}, | 172 {MFVideoFormat_YV12, media::PIXEL_FORMAT_YV12}, |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 for (const auto& kFormat : kFormatMap) { | 175 for (const auto& kFormat : kFormatMap) { |
| 176 if (kFormat.guid == guid) { | 176 if (kFormat.guid == guid) { |
| 177 *format = kFormat.format; | 177 *format = kFormat.format; |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 return false; | 182 return false; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 const tracked_objects::Location& from_here, | 305 const tracked_objects::Location& from_here, |
| 306 HRESULT hr) { | 306 HRESULT hr) { |
| 307 if (client_.get()) { | 307 if (client_.get()) { |
| 308 client_->OnError( | 308 client_->OnError( |
| 309 from_here, | 309 from_here, |
| 310 base::StringPrintf("VideoCaptureDeviceMFWin: %s", | 310 base::StringPrintf("VideoCaptureDeviceMFWin: %s", |
| 311 logging::SystemErrorCodeToString(hr).c_str())); | 311 logging::SystemErrorCodeToString(hr).c_str())); |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 } // namespace media | 315 } // namespace device |
| OLD | NEW |