| 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 877c543cc187a34fc4b4ef7926fb7bb6628d4d44..b58ccc94e79894ea39224de8010de298f3d39025 100644
|
| --- a/media/video/capture/win/video_capture_device_win.cc
|
| +++ b/media/video/capture/win/video_capture_device_win.cc
|
| @@ -287,18 +287,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);
|
| - VideoCaptureFormat format = found_capability.supported_format;
|
| + *GetBestMatchedFormat(params.requested_format, capabilities_);
|
| + VideoCaptureFormat format = found_capability.second;
|
|
|
| // 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());
|
| @@ -321,7 +318,7 @@ void VideoCaptureDeviceWin::AllocateAndStart(
|
| // GetStreamCaps can return S_FALSE which we consider an error. Therefore the
|
| // FAILED macro can't be used.
|
| hr = stream_config->GetStreamCaps(
|
| - found_capability.stream_index, media_type.Receive(), caps.get());
|
| + found_capability.first, media_type.Receive(), caps.get());
|
| if (hr != S_OK) {
|
| SetErrorState("Failed to get capture device capabilities");
|
| return;
|
| @@ -464,9 +461,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) {
|
| @@ -477,16 +475,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.
|
| @@ -494,16 +491,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
|
| // 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.
|
| @@ -513,17 +509,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));
|
| }
|
| }
|
|
|
|
|