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.
This commit is contained in:
1 parent
b30deb7cc5
commit
b3bdd5f7dc
1 file changed
+11
-1
@@ -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<unsigned long>(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<unsigned long>(hr));
|
||||
SafeRelease(&reader);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user