Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: device/capture/video/win/video_capture_device_win.cc

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/capture/video/win/video_capture_device_win.h ('k') | media/base/media_switches.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "device/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/macros.h" 14 #include "base/macros.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "base/win/scoped_co_mem.h" 16 #include "base/win/scoped_co_mem.h"
17 #include "base/win/scoped_variant.h" 17 #include "base/win/scoped_variant.h"
18 #include "media/base/timestamp_constants.h" 18 #include "media/base/timestamp_constants.h"
19 19
20 using base::win::ScopedCoMem; 20 using base::win::ScopedCoMem;
21 using base::win::ScopedComPtr; 21 using base::win::ScopedComPtr;
22 using base::win::ScopedVariant; 22 using base::win::ScopedVariant;
23 23
24 namespace media { 24 namespace device {
25 25
26 // Check if a Pin matches a category. 26 // Check if a Pin matches a category.
27 bool PinMatchesCategory(IPin* pin, REFGUID category) { 27 bool PinMatchesCategory(IPin* pin, REFGUID category) {
28 DCHECK(pin); 28 DCHECK(pin);
29 bool found = false; 29 bool found = false;
30 ScopedComPtr<IKsPropertySet> ks_property; 30 ScopedComPtr<IKsPropertySet> ks_property;
31 HRESULT hr = ks_property.QueryFrom(pin); 31 HRESULT hr = ks_property.QueryFrom(pin);
32 if (SUCCEEDED(hr)) { 32 if (SUCCEEDED(hr)) {
33 GUID pin_category; 33 GUID pin_category;
34 DWORD return_value; 34 DWORD return_value;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 144
145 // static 145 // static
146 VideoPixelFormat 146 VideoPixelFormat
147 VideoCaptureDeviceWin::TranslateMediaSubtypeToPixelFormat( 147 VideoCaptureDeviceWin::TranslateMediaSubtypeToPixelFormat(
148 const GUID& sub_type) { 148 const GUID& sub_type) {
149 static struct { 149 static struct {
150 const GUID& sub_type; 150 const GUID& sub_type;
151 VideoPixelFormat format; 151 VideoPixelFormat format;
152 } const kMediaSubtypeToPixelFormatCorrespondence[] = { 152 } const kMediaSubtypeToPixelFormatCorrespondence[] = {
153 {kMediaSubTypeI420, PIXEL_FORMAT_I420}, 153 {kMediaSubTypeI420, media::PIXEL_FORMAT_I420},
154 {MEDIASUBTYPE_IYUV, PIXEL_FORMAT_I420}, 154 {MEDIASUBTYPE_IYUV, media::PIXEL_FORMAT_I420},
155 {MEDIASUBTYPE_RGB24, PIXEL_FORMAT_RGB24}, 155 {MEDIASUBTYPE_RGB24, media::PIXEL_FORMAT_RGB24},
156 {MEDIASUBTYPE_YUY2, PIXEL_FORMAT_YUY2}, 156 {MEDIASUBTYPE_YUY2, media::PIXEL_FORMAT_YUY2},
157 {MEDIASUBTYPE_MJPG, PIXEL_FORMAT_MJPEG}, 157 {MEDIASUBTYPE_MJPG, media::PIXEL_FORMAT_MJPEG},
158 {MEDIASUBTYPE_UYVY, PIXEL_FORMAT_UYVY}, 158 {MEDIASUBTYPE_UYVY, media::PIXEL_FORMAT_UYVY},
159 {MEDIASUBTYPE_ARGB32, PIXEL_FORMAT_ARGB}, 159 {MEDIASUBTYPE_ARGB32, media::PIXEL_FORMAT_ARGB},
160 {kMediaSubTypeHDYC, PIXEL_FORMAT_UYVY}, 160 {kMediaSubTypeHDYC, media::PIXEL_FORMAT_UYVY},
161 }; 161 };
162 for (const auto& pixel_format : kMediaSubtypeToPixelFormatCorrespondence) { 162 for (const auto& pixel_format : kMediaSubtypeToPixelFormatCorrespondence) {
163 if (sub_type == pixel_format.sub_type) 163 if (sub_type == pixel_format.sub_type)
164 return pixel_format.format; 164 return pixel_format.format;
165 } 165 }
166 #ifndef NDEBUG 166 #ifndef NDEBUG
167 WCHAR guid_str[128]; 167 WCHAR guid_str[128];
168 StringFromGUID2(sub_type, guid_str, arraysize(guid_str)); 168 StringFromGUID2(sub_type, guid_str, arraysize(guid_str));
169 DVLOG(2) << "Device (also) supports an unknown media type " << guid_str; 169 DVLOG(2) << "Device (also) supports an unknown media type " << guid_str;
170 #endif 170 #endif
171 return PIXEL_FORMAT_UNKNOWN; 171 return media::PIXEL_FORMAT_UNKNOWN;
172 } 172 }
173 173
174 void VideoCaptureDeviceWin::ScopedMediaType::Free() { 174 void VideoCaptureDeviceWin::ScopedMediaType::Free() {
175 if (!media_type_) 175 if (!media_type_)
176 return; 176 return;
177 177
178 DeleteMediaType(media_type_); 178 DeleteMediaType(media_type_);
179 media_type_ = NULL; 179 media_type_ = NULL;
180 } 180 }
181 181
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 DLOG(ERROR) << "Failed to GetStreamCaps: " 501 DLOG(ERROR) << "Failed to GetStreamCaps: "
502 << logging::SystemErrorCodeToString(hr); 502 << logging::SystemErrorCodeToString(hr);
503 return false; 503 return false;
504 } 504 }
505 505
506 if (media_type->majortype == MEDIATYPE_Video && 506 if (media_type->majortype == MEDIATYPE_Video &&
507 media_type->formattype == FORMAT_VideoInfo) { 507 media_type->formattype == FORMAT_VideoInfo) {
508 VideoCaptureFormat format; 508 VideoCaptureFormat format;
509 format.pixel_format = 509 format.pixel_format =
510 TranslateMediaSubtypeToPixelFormat(media_type->subtype); 510 TranslateMediaSubtypeToPixelFormat(media_type->subtype);
511 if (format.pixel_format == PIXEL_FORMAT_UNKNOWN) 511 if (format.pixel_format == media::PIXEL_FORMAT_UNKNOWN)
512 continue; 512 continue;
513 513
514 VIDEOINFOHEADER* h = 514 VIDEOINFOHEADER* h =
515 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); 515 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat);
516 format.frame_size.SetSize(h->bmiHeader.biWidth, h->bmiHeader.biHeight); 516 format.frame_size.SetSize(h->bmiHeader.biWidth, h->bmiHeader.biHeight);
517 517
518 // Try to get a better |time_per_frame| from IAMVideoControl. If not, use 518 // Try to get a better |time_per_frame| from IAMVideoControl. If not, use
519 // the value from VIDEOINFOHEADER. 519 // the value from VIDEOINFOHEADER.
520 REFERENCE_TIME time_per_frame = h->AvgTimePerFrame; 520 REFERENCE_TIME time_per_frame = h->AvgTimePerFrame;
521 if (video_control.get()) { 521 if (video_control.get()) {
(...skipping 22 matching lines...) Expand all
544 capabilities_.emplace_back(stream_index, format, h->bmiHeader); 544 capabilities_.emplace_back(stream_index, format, h->bmiHeader);
545 } 545 }
546 } 546 }
547 547
548 return !capabilities_.empty(); 548 return !capabilities_.empty();
549 } 549 }
550 550
551 // Set the power line frequency removal in |capture_filter_| if available. 551 // Set the power line frequency removal in |capture_filter_| if available.
552 void VideoCaptureDeviceWin::SetAntiFlickerInCaptureFilter( 552 void VideoCaptureDeviceWin::SetAntiFlickerInCaptureFilter(
553 const VideoCaptureParams& params) { 553 const VideoCaptureParams& params) {
554 const PowerLineFrequency power_line_frequency = GetPowerLineFrequency(params); 554 const media::PowerLineFrequency power_line_frequency =
555 GetPowerLineFrequency(params);
555 if (power_line_frequency != media::PowerLineFrequency::FREQUENCY_50HZ && 556 if (power_line_frequency != media::PowerLineFrequency::FREQUENCY_50HZ &&
556 power_line_frequency != media::PowerLineFrequency::FREQUENCY_60HZ) { 557 power_line_frequency != media::PowerLineFrequency::FREQUENCY_60HZ) {
557 return; 558 return;
558 } 559 }
559 ScopedComPtr<IKsPropertySet> ks_propset; 560 ScopedComPtr<IKsPropertySet> ks_propset;
560 DWORD type_support = 0; 561 DWORD type_support = 0;
561 HRESULT hr; 562 HRESULT hr;
562 if (SUCCEEDED(hr = ks_propset.QueryFrom(capture_filter_.get())) && 563 if (SUCCEEDED(hr = ks_propset.QueryFrom(capture_filter_.get())) &&
563 SUCCEEDED(hr = ks_propset->QuerySupported( 564 SUCCEEDED(hr = ks_propset->QuerySupported(
564 PROPSETID_VIDCAP_VIDEOPROCAMP, 565 PROPSETID_VIDCAP_VIDEOPROCAMP,
(...skipping 19 matching lines...) Expand all
584 } 585 }
585 } 586 }
586 587
587 void VideoCaptureDeviceWin::SetErrorState( 588 void VideoCaptureDeviceWin::SetErrorState(
588 const tracked_objects::Location& from_here, 589 const tracked_objects::Location& from_here,
589 const std::string& reason) { 590 const std::string& reason) {
590 DCHECK(thread_checker_.CalledOnValidThread()); 591 DCHECK(thread_checker_.CalledOnValidThread());
591 state_ = kError; 592 state_ = kError;
592 client_->OnError(from_here, reason); 593 client_->OnError(from_here, reason);
593 } 594 }
594 } // namespace media 595 } // namespace device
OLDNEW
« no previous file with comments | « device/capture/video/win/video_capture_device_win.h ('k') | media/base/media_switches.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698