mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[cscore] Fix USB video mode handling on macOS (#7904)
* fix: UsbCameraImpl on macOS * fix: add back logs
This commit is contained in:
@@ -91,6 +91,5 @@ class UsbCameraImpl : public SourceImpl {
|
||||
private:
|
||||
UsbCameraImplObjc* m_objc;
|
||||
std::vector<CameraModeStore> m_platformModes;
|
||||
VideoMode m_mode;
|
||||
};
|
||||
} // namespace cs
|
||||
|
||||
@@ -380,22 +380,27 @@ static cs::VideoMode::PixelFormat FourCCToPixelFormat(FourCharCode fourcc) {
|
||||
toCheck->height, toCheck->fps);
|
||||
std::vector<CameraModeStore>& platformModes =
|
||||
sharedThis->objcGetPlatformVideoModes();
|
||||
// Find the matching mode
|
||||
auto match = std::find_if(platformModes.begin(), platformModes.end(),
|
||||
[&](CameraModeStore& input) {
|
||||
return input.mode.CompareWithoutFps(*toCheck);
|
||||
});
|
||||
|
||||
// Find all matching modes
|
||||
std::vector<CameraModeStore*> matchingModes;
|
||||
for (auto& mode : platformModes) {
|
||||
if (mode.mode.CompareWithoutFps(*toCheck)) {
|
||||
matchingModes.push_back(&mode);
|
||||
}
|
||||
}
|
||||
|
||||
if (match == platformModes.end()) {
|
||||
if (matchingModes.empty()) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Check FPS
|
||||
for (CameraFPSRange& range : match->fpsRanges) {
|
||||
OBJCDEBUG3("Checking Range {} {}", range.min, range.max);
|
||||
if (range.IsWithinRange(toCheck->fps)) {
|
||||
*fps = toCheck->fps;
|
||||
return match->format;
|
||||
for (auto mode : matchingModes) {
|
||||
for (CameraFPSRange& range : mode->fpsRanges) {
|
||||
OBJCDEBUG3("Checking Range {} {}", range.min, range.max);
|
||||
if (range.IsWithinRange(toCheck->fps)) {
|
||||
*fps = toCheck->fps;
|
||||
return mode->format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user