// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include #include #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qLcCamera, "qt.multimedia.camera") AVFPSRange qt_connection_framerates(AVCaptureConnection *videoConnection) { Q_ASSERT(videoConnection); AVFPSRange newRange; // "The value in the videoMinFrameDuration is equivalent to the reciprocal // of the maximum framerate, the value in the videoMaxFrameDuration is equivalent // to the reciprocal of the minimum framerate." if (videoConnection.supportsVideoMinFrameDuration) { const CMTime cmMin = videoConnection.videoMinFrameDuration; if (CMTimeCompare(cmMin, kCMTimeInvalid)) { // Has some non-default value: if (const Float64 minSeconds = CMTimeGetSeconds(cmMin)) newRange.second = 1. / minSeconds; } } if (videoConnection.supportsVideoMaxFrameDuration) { const CMTime cmMax = videoConnection.videoMaxFrameDuration; if (CMTimeCompare(cmMax, kCMTimeInvalid)) { if (const Float64 maxSeconds = CMTimeGetSeconds(cmMax)) newRange.first = 1. / maxSeconds; } } return newRange; } namespace { inline bool qt_area_sane(const QSize &size) { return !size.isNull() && size.isValid() && std::numeric_limits::max() / size.width() >= size.height(); } template