From b3bdd5f7dcaf11c7bc10404b58625267ba956d7d Mon Sep 17 00:00:00 2001 From: kinect-bot Date: Wed, 25 Nov 2026 19:46:51 -0500 Subject: [PATCH] fix(tracker-native): camera-open fallback to RGB32 default size If a webcam can't deliver RGB32 at the exact chosen native resolution, SetCurrentMediaType failed and the camera wouldn't open at all. Now it retries RGB32 without forcing the frame size (MF picks a supported size + converts) and adopts whatever is negotiated (read back from GetCurrentMediaType), so the app degrades gracefully instead of hard-failing. --- tracker-native/src/win_camera.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tracker-native/src/win_camera.cpp b/tracker-native/src/win_camera.cpp index f93aecd..ccea01a 100644 --- a/tracker-native/src/win_camera.cpp +++ b/tracker-native/src/win_camera.cpp @@ -133,8 +133,18 @@ bool Camera::open(const std::wstring& symbolic_link, int width, int height) { hr = reader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_VIDEO_STREAM, nullptr, mt); SafeRelease(&mt); if (FAILED(hr)) { - TraceLog("camera open FAILED: SetCurrentMediaType RGB32 %dx%d hr=0x%08lX", + TraceLog("camera: RGB32 %dx%d rejected (hr=0x%08lX); retrying RGB32 default size", width, height, static_cast(hr)); + IMFMediaType* mt2 = nullptr; + MFCreateMediaType(&mt2); + mt2->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); + mt2->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32); + hr = reader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_VIDEO_STREAM, nullptr, mt2); + SafeRelease(&mt2); + } + if (FAILED(hr)) { + TraceLog("camera open FAILED: no RGB32 output available hr=0x%08lX", + static_cast(hr)); SafeRelease(&reader); return false; }