X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmedia%2Fvideo%2Fcapture%2Fwin%2Fvideo_capture_device_mf_win.cc;h=858de6eb122decba6c7a30cfa3a9d1b23ef4a7d3;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=de199c2db4f46786633a5ca5a4a2a92a2ea8590b;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/media/video/capture/win/video_capture_device_mf_win.cc b/src/media/video/capture/win/video_capture_device_mf_win.cc index de199c2..858de6e 100644 --- a/src/media/video/capture/win/video_capture_device_mf_win.cc +++ b/src/media/video/capture/win/video_capture_device_mf_win.cc @@ -287,6 +287,60 @@ void VideoCaptureDeviceMFWin::GetDeviceNames(Names* device_names) { } } +// static +void VideoCaptureDeviceMFWin::GetDeviceSupportedFormats(const Name& device, + VideoCaptureFormats* formats) { + ScopedComPtr source; + if (!CreateVideoCaptureDevice(device.id().c_str(), source.Receive())) + return; + + HRESULT hr; + base::win::ScopedComPtr reader; + if (FAILED(hr = MFCreateSourceReaderFromMediaSource(source, NULL, + reader.Receive()))) { + DLOG(ERROR) << "MFCreateSourceReaderFromMediaSource: " << std::hex << hr; + return; + } + + DWORD stream_index = 0; + ScopedComPtr type; + while (SUCCEEDED(hr = reader->GetNativeMediaType( + MF_SOURCE_READER_FIRST_VIDEO_STREAM, stream_index, type.Receive()))) { + UINT32 width, height; + hr = MFGetAttributeSize(type, MF_MT_FRAME_SIZE, &width, &height); + if (FAILED(hr)) { + DLOG(ERROR) << "MFGetAttributeSize: " << std::hex << hr; + return; + } + VideoCaptureFormat capture_format; + capture_format.frame_size.SetSize(width, height); + + UINT32 numerator, denominator; + hr = MFGetAttributeRatio(type, MF_MT_FRAME_RATE, &numerator, &denominator); + if (FAILED(hr)) { + DLOG(ERROR) << "MFGetAttributeSize: " << std::hex << hr; + return; + } + capture_format.frame_rate = denominator ? numerator / denominator : 0; + + GUID type_guid; + hr = type->GetGUID(MF_MT_SUBTYPE, &type_guid); + if (FAILED(hr)) { + DLOG(ERROR) << "GetGUID: " << std::hex << hr; + return; + } + FormatFromGuid(type_guid, &capture_format.pixel_format); + type.Release(); + formats->push_back(capture_format); + ++stream_index; + + DVLOG(1) << device.name() << " resolution: " + << capture_format.frame_size.ToString() << ", fps: " + << capture_format.frame_rate << ", pixel format: " + << capture_format.pixel_format; + } +} + const std::string VideoCaptureDevice::Name::GetModel() const { const size_t vid_prefix_size = sizeof(kVidPrefix) - 1; const size_t pid_prefix_size = sizeof(kPidPrefix) - 1;