From 479a67c1b7b98a58d9b832637459bff715e0f4da Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 1 Aug 2020 00:53:46 +0900 Subject: [PATCH] mfvideosrc: Check framerate for target IMediaFrameFormat selection Not only resolution and format, but framerate needs to be checked for proper target IMediaFrameFormat selection. Part-of: --- sys/mediafoundation/mediacapturewrapper.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/mediafoundation/mediacapturewrapper.cpp b/sys/mediafoundation/mediacapturewrapper.cpp index 657673a..dac3708 100644 --- a/sys/mediafoundation/mediacapturewrapper.cpp +++ b/sys/mediafoundation/mediacapturewrapper.cpp @@ -787,6 +787,8 @@ MediaCaptureWrapper::mediaCaptureInitPost (ComPtr init_async, HString subtype; UINT32 width = 0; UINT32 height = 0; + UINT32 fps_n = 0; + UINT32 fps_d = 1; hr = formatList->GetAt (i, &fmt); if (!gst_mf_result (hr)) @@ -813,6 +815,27 @@ MediaCaptureWrapper::mediaCaptureInitPost (ComPtr init_async, continue; } + hr = fmt->get_FrameRate (&ratio); + if (!gst_mf_result (hr)) + continue; + + hr = ratio->get_Numerator (&fps_n); + if (!gst_mf_result (hr)) + continue; + + hr = ratio->get_Denominator (&fps_d); + if (!gst_mf_result (hr)) + continue; + + if ((gint) fps_n != GST_VIDEO_INFO_FPS_N (&videoInfo) || + (gint) fps_d != GST_VIDEO_INFO_FPS_D (&videoInfo)) { + GST_DEBUG ("IMediaFrameFormat[%d], framerate %d/%d is not equal to " + "target framerate %d/%d", i, width, height, + GST_VIDEO_INFO_FPS_N (&videoInfo), + GST_VIDEO_INFO_FPS_D (&videoInfo)); + continue; + } + /* TODO: check major type for audio */ hr = fmt->get_Subtype (subtype.GetAddressOf ()); if (!gst_mf_result (hr)) -- 2.7.4