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 7dfd834b2614e7c5c5e75953b5ba25d08459a944..3cae23f77aeee5240f7fa0be9b4f4769a542bef5 100644 |
--- a/media/video/capture/win/video_capture_device_win.cc |
+++ b/media/video/capture/win/video_capture_device_win.cc |
@@ -318,18 +318,15 @@ void VideoCaptureDeviceWin::AllocateAndStart( |
client_ = client.Pass(); |
- // Get the camera capability that best match the requested resolution. |
+ // Get the camera capability that best match the requested format. |
const VideoCaptureCapabilityWin& found_capability = |
- capabilities_.GetBestMatchedFormat( |
- params.requested_format.frame_size.width(), |
- params.requested_format.frame_size.height(), |
- params.requested_format.frame_rate); |
+ *GetBestMatchedFormat(params.requested_format, capabilities_); |
VideoCaptureFormat format = found_capability.supported_format; |
// Reduce the frame rate if the requested frame rate is lower |
// than the capability. |
- if (format.frame_rate > params.requested_format.frame_rate) |
- format.frame_rate = params.requested_format.frame_rate; |
+ format.frame_rate = |
+ std::min(format.frame_rate, params.requested_format.frame_rate); |
ScopedComPtr<IAMStreamConfig> stream_config; |
HRESULT hr = output_capture_pin_.QueryInterface(stream_config.Receive()); |
@@ -501,9 +498,10 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
} |
scoped_ptr<BYTE[]> caps(new BYTE[size]); |
- for (int i = 0; i < count; ++i) { |
+ for (int stream_index = 0; stream_index < count; ++stream_index) { |
ScopedMediaType media_type; |
- hr = stream_config->GetStreamCaps(i, media_type.Receive(), caps.get()); |
+ hr = stream_config->GetStreamCaps( |
+ stream_index, media_type.Receive(), caps.get()); |
// GetStreamCaps() may return S_FALSE, so don't use FAILED() or SUCCEED() |
// macros here since they'll trigger incorrectly. |
if (hr != S_OK) { |
@@ -514,16 +512,15 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
if (media_type->majortype == MEDIATYPE_Video && |
media_type->formattype == FORMAT_VideoInfo) { |
- VideoCaptureCapabilityWin capability(i); |
- capability.supported_format.pixel_format = |
+ VideoCaptureFormat format; |
+ format.pixel_format = |
TranslateMediaSubtypeToPixelFormat(media_type->subtype); |
- if (capability.supported_format.pixel_format == PIXEL_FORMAT_UNKNOWN) |
+ if (format.pixel_format == PIXEL_FORMAT_UNKNOWN) |
continue; |
VIDEOINFOHEADER* h = |
reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); |
- capability.supported_format.frame_size.SetSize(h->bmiHeader.biWidth, |
- h->bmiHeader.biHeight); |
+ format.frame_size.SetSize(h->bmiHeader.biWidth, h->bmiHeader.biHeight); |
// Try to get a better |time_per_frame| from IAMVideoControl. If not, use |
// the value from VIDEOINFOHEADER. |
@@ -531,16 +528,15 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
if (video_control) { |
ScopedCoMem<LONGLONG> max_fps; |
LONG list_size = 0; |
- SIZE size = {capability.supported_format.frame_size.width(), |
- capability.supported_format.frame_size.height()}; |
- |
+ const SIZE size = {format.frame_size.width(), |
+ format.frame_size.height()}; |
// GetFrameRateList doesn't return max frame rate always |
// eg: Logitech Notebook. This may be due to a bug in that API |
// because GetFrameRateList array is reversed in the above camera. So |
// a util method written. Can't assume the first value will return |
mcasas
2014/09/23 12:34:57
Please rewrite doco. ("So a util method written",
magjed_chromium
2014/09/23 14:39:55
Done. I removed that section of comments. I think
|
// the max fps. |
- hr = video_control->GetFrameRateList(output_capture_pin_, i, size, |
- &list_size, &max_fps); |
+ hr = video_control->GetFrameRateList( |
+ output_capture_pin_, stream_index, size, &list_size, &max_fps); |
// Sometimes |list_size| will be > 0, but max_fps will be NULL. Some |
// drivers may return an HRESULT of S_FALSE which SUCCEEDED() translates |
// into success, so explicitly check S_OK. See http://crbug.com/306237. |
@@ -550,17 +546,12 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
} |
} |
- capability.supported_format.frame_rate = |
+ format.frame_rate = |
(time_per_frame > 0) |
? (kSecondsToReferenceTime / static_cast<float>(time_per_frame)) |
: 0.0; |
- // DirectShow works at the moment only on integer frame_rate but the |
- // best capability matching class works on rational frame rates. |
- capability.frame_rate_numerator = capability.supported_format.frame_rate; |
- capability.frame_rate_denominator = 1; |
- |
- capabilities_.Add(capability); |
+ capabilities_.push_back(VideoCaptureCapabilityWin(stream_index, format)); |
} |
} |