Define QCamera::FrameRateRange as a struct.

Instead of an alias for QPair<qreal, qreal>.

Task-number: QTBUG-46563
Change-Id: I7e1ac68242810f7e5f7e161571a11f5de7850e29
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
Yoann Lopes
2015-06-09 18:30:32 +02:00
committed by Jani Heikkinen
parent f93f4e3daa
commit 7f9beeaf9c
4 changed files with 48 additions and 12 deletions

View File

@@ -1094,8 +1094,8 @@ QJSValue QDeclarativeCamera::supportedViewfinderFrameRateRanges(const QSize &res
int i = 0; int i = 0;
Q_FOREACH (const QCamera::FrameRateRange &frameRateRange, frameRateRanges) { Q_FOREACH (const QCamera::FrameRateRange &frameRateRange, frameRateRanges) {
QJSValue range = engine->newObject(); QJSValue range = engine->newObject();
range.setProperty(QStringLiteral("minimumFrameRate"), frameRateRange.first); range.setProperty(QStringLiteral("minimumFrameRate"), frameRateRange.minimumFrameRate);
range.setProperty(QStringLiteral("maximumFrameRate"), frameRateRange.second); range.setProperty(QStringLiteral("maximumFrameRate"), frameRateRange.maximumFrameRate);
supportedFrameRateRanges.setProperty(i++, range); supportedFrameRateRanges.setProperty(i++, range);
} }

View File

@@ -72,7 +72,7 @@ static bool qt_sizeLessThan(const QSize &s1, const QSize &s2)
static bool qt_frameRateRangeLessThan(const QCamera::FrameRateRange &s1, const QCamera::FrameRateRange &s2) static bool qt_frameRateRangeLessThan(const QCamera::FrameRateRange &s1, const QCamera::FrameRateRange &s2)
{ {
return s1.second < s2.second; return s1.maximumFrameRate < s2.maximumFrameRate;
} }
/*! /*!
@@ -1028,15 +1028,29 @@ void QCamera::unlock()
/*! /*!
\typedef QCamera::FrameRateRange \class QCamera::FrameRateRange
\inmodule QtMultimedia
\ingroup multimedia
\ingroup multimedia_camera
\since 5.5
This is a typedef for QPair<qreal, qreal>. \brief A FrameRateRange represents a range of frame rates as minimum and maximum rate.
A frame rate range contains a minimum and a maximum frame rate, respectively the first and If the minimum frame rate is equal to the maximum frame rate, the frame rate is fixed.
second element of the pair. If the minimum frame rate is equal to the maximum frame rate, the If not, the actual frame rate fluctuates between the minimum and the maximum.
frame rate is fixed. If not, the actual frame rate fluctuates between the minimum and the maximum.
\sa QCamera::supportedViewfinderFrameRateRanges(), QCameraViewfinderSettings
*/ */
/*!
\variable QCamera::FrameRateRange::minimumFrameRate
The minimum frame rate supported by the range, in frames per second.
*/
/*!
\variable QCamera::FrameRateRange::maximumFrameRate
The maximum frame rate supported by the range, in frames per second.
*/
/*! /*!
\enum QCamera::State \enum QCamera::State

View File

@@ -77,7 +77,21 @@ class Q_MULTIMEDIA_EXPORT QCamera : public QMediaObject
Q_ENUMS(LockType) Q_ENUMS(LockType)
Q_ENUMS(Position) Q_ENUMS(Position)
public: public:
typedef QPair<qreal, qreal> FrameRateRange; struct FrameRateRange
{
Q_DECL_CONSTEXPR FrameRateRange() Q_DECL_NOTHROW
: minimumFrameRate(0)
, maximumFrameRate(0)
{ }
Q_DECL_CONSTEXPR FrameRateRange(qreal minimum, qreal maximum) Q_DECL_NOTHROW
: minimumFrameRate(minimum)
, maximumFrameRate(maximum)
{ }
qreal minimumFrameRate;
qreal maximumFrameRate;
};
enum Status { enum Status {
UnavailableStatus, UnavailableStatus,
@@ -237,6 +251,14 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::LockTypes) Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::LockTypes)
Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator==(const QCamera::FrameRateRange &r1, const QCamera::FrameRateRange &r2) Q_DECL_NOTHROW
{ return r1.minimumFrameRate == r2.minimumFrameRate && r1.maximumFrameRate == r2.maximumFrameRate; }
Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator!=(const QCamera::FrameRateRange &r1, const QCamera::FrameRateRange &r2) Q_DECL_NOTHROW
{ return !(r1 == r2); }
Q_DECLARE_TYPEINFO(QCamera::FrameRateRange, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE QT_END_NAMESPACE
Q_DECLARE_METATYPE(QCamera::State) Q_DECLARE_METATYPE(QCamera::State)

View File

@@ -789,7 +789,7 @@ void DSCameraSession::disconnectGraph()
static bool qt_frameRateRangeGreaterThan(const QCamera::FrameRateRange &r1, const QCamera::FrameRateRange &r2) static bool qt_frameRateRangeGreaterThan(const QCamera::FrameRateRange &r1, const QCamera::FrameRateRange &r2)
{ {
return r1.second > r2.second; return r1.maximumFrameRate > r2.maximumFrameRate;
} }
void DSCameraSession::updateSourceCapabilities() void DSCameraSession::updateSourceCapabilities()
@@ -896,8 +896,8 @@ void DSCameraSession::updateSourceCapabilities()
Q_FOREACH (const QCamera::FrameRateRange &frameRateRange, frameRateRanges) { Q_FOREACH (const QCamera::FrameRateRange &frameRateRange, frameRateRanges) {
QCameraViewfinderSettings settings; QCameraViewfinderSettings settings;
settings.setResolution(resolution); settings.setResolution(resolution);
settings.setMinimumFrameRate(frameRateRange.first); settings.setMinimumFrameRate(frameRateRange.minimumFrameRate);
settings.setMaximumFrameRate(frameRateRange.second); settings.setMaximumFrameRate(frameRateRange.maximumFrameRate);
settings.setPixelFormat(pixelFormat); settings.setPixelFormat(pixelFormat);
m_supportedViewfinderSettings.append(settings); m_supportedViewfinderSettings.append(settings);