Chromium Code Reviews| Index: media/video/capture/win/video_capture_device_win.cc |
| diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc |
| index 2afb96860177ea648017597a2ce05ee34c0a5316..fa2455f071da5b6da6dba37bd8c51a5651fe1c07 100644 |
| --- a/media/video/capture/win/video_capture_device_win.cc |
| +++ b/media/video/capture/win/video_capture_device_win.cc |
| @@ -4,6 +4,9 @@ |
| #include "media/video/capture/win/video_capture_device_win.h" |
| +#include <ks.h> |
| +#include <ksmedia.h> |
| + |
| #include <algorithm> |
| #include <list> |
| @@ -591,6 +594,8 @@ void VideoCaptureDeviceWin::AllocateAndStart( |
| } |
| } |
| + SetAntiFlickerInCaptureFilter(); |
| + |
| if (format.pixel_format == PIXEL_FORMAT_MJPEG && mjpg_filter_.get()) { |
| // Connect the camera to the MJPEG decoder. |
| hr = graph_builder_->ConnectDirect(output_capture_pin_, input_mjpg_pin_, |
| @@ -749,6 +754,36 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| return !capabilities_.empty(); |
| } |
| +// Set the power line frequency removal in |capture_filter_| if available. |
| +void VideoCaptureDeviceWin::SetAntiFlickerInCaptureFilter() { |
| + HRESULT hr; |
|
tommi (sloooow) - chröme
2014/04/22 14:55:27
nit: define where you need it
mcasas
2014/04/23 17:04:46
Done.
|
| + const int power_line_frequency = GetPowerLineFrequencyForLocation(); |
| + if (power_line_frequency == kPowerLine50Hz || |
| + power_line_frequency == kPowerLine60Hz) { |
|
tommi (sloooow) - chröme
2014/04/22 14:55:27
nit: could also turn this into an early return to
mcasas
2014/04/23 17:04:46
Done.
|
| + ScopedComPtr<IKsPropertySet> ks_propset; |
| + DWORD type_support = 0; |
| + if (SUCCEEDED(hr = ks_propset.QueryFrom(capture_filter_)) && |
| + SUCCEEDED(hr = ks_propset->QuerySupported(PROPSETID_VIDCAP_VIDEOPROCAMP, |
| + KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY, |
|
tommi (sloooow) - chröme
2014/04/22 14:55:27
not sure about this indent... think it should be:
mcasas
2014/04/23 17:04:46
Done.
|
| + &type_support)) && |
| + (type_support & KSPROPERTY_SUPPORT_SET)) { |
| + KSPROPERTY_VIDEOPROCAMP_S data = {}; |
| + data.Property.Set = PROPSETID_VIDCAP_VIDEOPROCAMP; |
| + data.Property.Id = KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY; |
| + data.Property.Flags = KSPROPERTY_TYPE_SET; |
| + data.Value = (power_line_frequency == kPowerLine50Hz) ? 1 : 2; |
| + data.Flags = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL; |
| + hr = ks_propset->Set(PROPSETID_VIDCAP_VIDEOPROCAMP, |
| + KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY, |
| + &data, sizeof(data), &data, sizeof(data)); |
| + DVLOG_IF(2, FAILED(hr)) << "Anti-flicker setting failed."; |
|
tommi (sloooow) - chröme
2014/04/22 14:55:27
DLOG_IF(ERROR, FAILED(hr)) ?
mcasas
2014/04/23 17:04:46
Done.
|
| + DVLOG_IF(2, SUCCEEDED(hr)) << "Anti-flicker set correctly."; |
| + } else { |
| + DVLOG(2) << "Anti-flicker setting not supported."; |
| + } |
| + } |
| +} |
| + |
| void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { |
| DCHECK(CalledOnValidThread()); |
| DVLOG(1) << reason; |