Merge pull request #22347 from bu3w:filter-camera-streaming-by-format

select correct MediaType in MSMF backend.
This commit is contained in:
Alexander Smorkalov 2022-08-26 12:49:47 +03:00 committed by GitHub
commit 560eba91e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -348,6 +348,12 @@ struct MediaType
} }
return false; return false;
} }
bool VideoIsAvailable() const
{
return ((subType == MFVideoFormat_RGB32) ||
(subType == MFVideoFormat_RGB24) ||
(subType == MFVideoFormat_YUY2));
}
}; };
void printFormat(std::ostream& out, const GUID& fmt) void printFormat(std::ostream& out, const GUID& fmt)
@ -628,7 +634,7 @@ public:
{ {
if (i->second.majorType == MFMediaType_Video) if (i->second.majorType == MFMediaType_Video)
{ {
if (best.second.isEmpty() || i->second.VideoIsBetterThan(best.second, newType)) if (best.second.isEmpty() || (i->second.VideoIsBetterThan(best.second, newType) && i->second.VideoIsAvailable()))
{ {
best = *i; best = *i;
} }