Chromium Code Reviews| 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/video/capture/win/video_capture_device_win.h" | 5 #include "media/video/capture/win/video_capture_device_win.h" |
| 6 | 6 |
| 7 #include <ks.h> | |
| 8 #include <ksmedia.h> | |
| 9 | |
| 7 #include <algorithm> | 10 #include <algorithm> |
| 8 #include <list> | 11 #include <list> |
| 9 | 12 |
| 10 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 11 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 13 #include "base/win/metro.h" | 16 #include "base/win/metro.h" |
| 14 #include "base/win/scoped_co_mem.h" | 17 #include "base/win/scoped_co_mem.h" |
| 15 #include "base/win/scoped_variant.h" | 18 #include "base/win/scoped_variant.h" |
| 16 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 hr = graph_builder_->AddFilter(mjpg_filter_, NULL); | 587 hr = graph_builder_->AddFilter(mjpg_filter_, NULL); |
| 585 } | 588 } |
| 586 | 589 |
| 587 if (FAILED(hr)) { | 590 if (FAILED(hr)) { |
| 588 mjpg_filter_.Release(); | 591 mjpg_filter_.Release(); |
| 589 input_mjpg_pin_.Release(); | 592 input_mjpg_pin_.Release(); |
| 590 output_mjpg_pin_.Release(); | 593 output_mjpg_pin_.Release(); |
| 591 } | 594 } |
| 592 } | 595 } |
| 593 | 596 |
| 597 const int power_line_frequency = GetPowerLineFrequencyForLocation(); | |
|
tommi (sloooow) - chröme
2014/04/08 10:16:19
This function is getting long.
Can you extract thi
mcasas
2014/04/08 10:33:31
Done.
| |
| 598 if ((power_line_frequency == kPowerLine50Hz) || | |
|
tommi (sloooow) - chröme
2014/04/08 10:16:19
nit: remove superfluous parenthesis
mcasas
2014/04/08 10:33:31
Done.
| |
| 599 (power_line_frequency == kPowerLine60Hz)) { | |
| 600 ScopedComPtr<IKsPropertySet> ks_propset; | |
| 601 hr = ks_propset.QueryFrom(capture_filter_); | |
|
tommi (sloooow) - chröme
2014/04/08 10:16:19
handle this return value?
You could do something
mcasas
2014/04/08 10:33:31
Done.
| |
| 602 DWORD type_support = 0; | |
| 603 hr = ks_propset->QuerySupported(PROPSETID_VIDCAP_VIDEOPROCAMP, | |
| 604 KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY, | |
| 605 &type_support); | |
| 606 DVLOG_IF(1, FAILED(hr)) << "Anti-flicker setting not supported."; | |
| 607 if (SUCCEEDED(hr) && (type_support & KSPROPERTY_SUPPORT_SET)) { | |
| 608 KSPROPERTY_VIDEOPROCAMP_S data = {}; | |
| 609 data.Property.Set = PROPSETID_VIDCAP_VIDEOPROCAMP; | |
| 610 data.Property.Id = KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY; | |
| 611 data.Property.Flags = KSPROPERTY_TYPE_SET; | |
| 612 data.Value = (power_line_frequency == kPowerLine50Hz) ? 1 : 2; | |
| 613 data.Flags = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL; | |
| 614 hr = ks_propset->Set(PROPSETID_VIDCAP_VIDEOPROCAMP, | |
| 615 KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY, | |
| 616 &data, sizeof(data), &data, sizeof(data)); | |
| 617 DVLOG_IF(2, FAILED(hr)) << "Anti-flicker setting failed."; | |
| 618 DVLOG_IF(2, SUCCEEDED(hr)) << "Anti-flicker setting correctly done."; | |
| 619 } | |
| 620 } | |
| 621 | |
| 594 if (format.pixel_format == PIXEL_FORMAT_MJPEG && mjpg_filter_.get()) { | 622 if (format.pixel_format == PIXEL_FORMAT_MJPEG && mjpg_filter_.get()) { |
| 595 // Connect the camera to the MJPEG decoder. | 623 // Connect the camera to the MJPEG decoder. |
| 596 hr = graph_builder_->ConnectDirect(output_capture_pin_, input_mjpg_pin_, | 624 hr = graph_builder_->ConnectDirect(output_capture_pin_, input_mjpg_pin_, |
| 597 NULL); | 625 NULL); |
| 598 // Connect the MJPEG filter to the Capture filter. | 626 // Connect the MJPEG filter to the Capture filter. |
| 599 hr += graph_builder_->ConnectDirect(output_mjpg_pin_, input_sink_pin_, | 627 hr += graph_builder_->ConnectDirect(output_mjpg_pin_, input_sink_pin_, |
| 600 NULL); | 628 NULL); |
| 601 } else { | 629 } else { |
| 602 hr = graph_builder_->ConnectDirect(output_capture_pin_, input_sink_pin_, | 630 hr = graph_builder_->ConnectDirect(output_capture_pin_, input_sink_pin_, |
| 603 NULL); | 631 NULL); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 return !capabilities_.empty(); | 777 return !capabilities_.empty(); |
| 750 } | 778 } |
| 751 | 779 |
| 752 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { | 780 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { |
| 753 DCHECK(CalledOnValidThread()); | 781 DCHECK(CalledOnValidThread()); |
| 754 DVLOG(1) << reason; | 782 DVLOG(1) << reason; |
| 755 state_ = kError; | 783 state_ = kError; |
| 756 client_->OnError(reason); | 784 client_->OnError(reason); |
| 757 } | 785 } |
| 758 } // namespace media | 786 } // namespace media |
| OLD | NEW |