diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2024-05-08 14:23:54 +0200 |
---|---|---|
committer | Artem Dyomin <artem.dyomin@qt.io> | 2024-05-10 10:19:54 +0000 |
commit | 948ce7b3d6decf7e3edd920a632562a47e2aa56a (patch) | |
tree | 2af9073e88f6103c8649a3009f69355174664ba9 | |
parent | a21f37193f2c105a174db7334cdf8c7a7199b3cb (diff) |
Rename QVideoFrameFormat::frameRate => streamFrameRate
The name 'frameRate' is not consistent with QVideoFrameFormat,
'streamFrameRate' works much better.
[ChangeLog][QVideoFrameFormat] Renamed the property QVideoFrameFormat::frameRate to QVideoFrameFormat::streamFrameRate.
Change-Id: I03413f15669de471371e6ed42ce948c22d1b5f5f
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
15 files changed, 52 insertions, 27 deletions
diff --git a/src/multimedia/platform/qplatformcamera.cpp b/src/multimedia/platform/qplatformcamera.cpp index 0d3975550..1d0e49cdd 100644 --- a/src/multimedia/platform/qplatformcamera.cpp +++ b/src/multimedia/platform/qplatformcamera.cpp @@ -50,7 +50,7 @@ QVideoFrameFormat QPlatformCamera::frameFormat() const m_framePixelFormat == QVideoFrameFormat::Format_Invalid ? m_cameraFormat.pixelFormat() : m_framePixelFormat); - result.setFrameRate(m_cameraFormat.maxFrameRate()); + result.setStreamFrameRate(m_cameraFormat.maxFrameRate()); return result; } diff --git a/src/multimedia/video/qvideoframeformat.cpp b/src/multimedia/video/qvideoframeformat.cpp index b2c9dc5f1..63388aab6 100644 --- a/src/multimedia/video/qvideoframeformat.cpp +++ b/src/multimedia/video/qvideoframeformat.cpp @@ -538,12 +538,13 @@ void QVideoFrameFormat::setScanLineDirection(Direction direction) d->scanLineDirection = direction; } +#if QT_DEPRECATED_SINCE(6, 8) /*! Returns the frame rate of a video stream in frames per second. */ qreal QVideoFrameFormat::frameRate() const { - return d->frameRate; + return streamFrameRate(); } /*! @@ -551,6 +552,23 @@ qreal QVideoFrameFormat::frameRate() const */ void QVideoFrameFormat::setFrameRate(qreal rate) { + setStreamFrameRate(rate); +} +#endif + +/*! + Returns the frame rate of a video stream in frames per second. +*/ +qreal QVideoFrameFormat::streamFrameRate() const +{ + return d->frameRate; +} + +/*! + Sets the frame \a rate of a video stream in frames per second. +*/ +void QVideoFrameFormat::setStreamFrameRate(qreal rate) +{ detach(); d->frameRate = rate; } @@ -984,7 +1002,7 @@ QDebug operator<<(QDebug dbg, const QVideoFrameFormat &f) << "\n frame size=" << f.frameSize() << "\n viewport=" << f.viewport() << "\n colorSpace=" << f.colorSpace() - << "\n frameRate=" << f.frameRate() + << "\n frameRate=" << f.streamFrameRate() << "\n mirrored=" << f.isMirrored(); return dbg; diff --git a/src/multimedia/video/qvideoframeformat.h b/src/multimedia/video/qvideoframeformat.h index 5fb6b3701..9d74e9695 100644 --- a/src/multimedia/video/qvideoframeformat.h +++ b/src/multimedia/video/qvideoframeformat.h @@ -153,8 +153,15 @@ public: Direction scanLineDirection() const; void setScanLineDirection(Direction direction); +#if QT_DEPRECATED_SINCE(6, 8) + QT_DEPRECATED_VERSION_X_6_8("Use streamFrameRate()") qreal frameRate() const; + QT_DEPRECATED_VERSION_X_6_8("Use setStreamFrameRate()") void setFrameRate(qreal rate); +#endif + + qreal streamFrameRate() const; + void setStreamFrameRate(qreal rate); #if QT_DEPRECATED_SINCE(6, 4) QT_DEPRECATED_VERSION_X_6_4("Use colorSpace()") diff --git a/src/plugins/multimedia/ffmpeg/qavfsamplebufferdelegate.mm b/src/plugins/multimedia/ffmpeg/qavfsamplebufferdelegate.mm index 9acca8566..54dc3e578 100644 --- a/src/plugins/multimedia/ffmpeg/qavfsamplebufferdelegate.mm +++ b/src/plugins/multimedia/ffmpeg/qavfsamplebufferdelegate.mm @@ -196,7 +196,7 @@ static QVideoFrame createHwVideoFrame(QAVFSampleBufferDelegate &delegate, return; } - format.setFrameRate(frameRate); + format.setStreamFrameRate(frameRate); auto frame = createHwVideoFrame(*self, imageBuffer, format); if (!frame.isValid()) diff --git a/src/plugins/multimedia/ffmpeg/qcgwindowcapture.mm b/src/plugins/multimedia/ffmpeg/qcgwindowcapture.mm index 93b079bac..c10868e76 100644 --- a/src/plugins/multimedia/ffmpeg/qcgwindowcapture.mm +++ b/src/plugins/multimedia/ffmpeg/qcgwindowcapture.mm @@ -129,7 +129,7 @@ protected: QVideoFrameFormat format(QSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)), QVideoFrameFormat::Format_BGRA8888); - format.setFrameRate(frameRate()); + format.setStreamFrameRate(frameRate()); return QVideoFrame(new QCGImageVideoBuffer(imageRef), format); } diff --git a/src/plugins/multimedia/ffmpeg/qeglfsscreencapture.cpp b/src/plugins/multimedia/ffmpeg/qeglfsscreencapture.cpp index 09fd633bc..f73202aba 100644 --- a/src/plugins/multimedia/ffmpeg/qeglfsscreencapture.cpp +++ b/src/plugins/multimedia/ffmpeg/qeglfsscreencapture.cpp @@ -54,7 +54,7 @@ protected: if (!m_format.isValid()) { auto image = videoBuffer->ensureImageBuffer().underlyingImage(); m_format = { image.size(), QVideoFrameFormat::pixelFormatFromImageFormat(image.format()) }; - m_format.setFrameRate(frameRate()); + m_format.setStreamFrameRate(frameRate()); } return QVideoFrame(videoBuffer.release(), m_format); @@ -90,7 +90,7 @@ protected: if (!m_format.isValid()) { m_format = { image.size(), QVideoFrameFormat::pixelFormatFromImageFormat(image.format()) }; - m_format.setFrameRate(frameRate()); + m_format.setStreamFrameRate(frameRate()); } return QVideoFrame(new QImageVideoBuffer(std::move(image)), m_format); diff --git a/src/plugins/multimedia/ffmpeg/qffmpegscreencapture_dxgi.cpp b/src/plugins/multimedia/ffmpeg/qffmpegscreencapture_dxgi.cpp index 69d2d0643..72e542a34 100644 --- a/src/plugins/multimedia/ffmpeg/qffmpegscreencapture_dxgi.cpp +++ b/src/plugins/multimedia/ffmpeg/qffmpegscreencapture_dxgi.cpp @@ -344,7 +344,7 @@ QVideoFrameFormat getFrameFormat(QScreen* screen) const QSize screenSize = getPhysicalSizePixels(screen); QVideoFrameFormat format = { screenSize, QVideoFrameFormat::Format_BGRA8888 }; - format.setFrameRate(static_cast<int>(screen->refreshRate())); + format.setStreamFrameRate(static_cast<int>(screen->refreshRate())); return format; } diff --git a/src/plugins/multimedia/ffmpeg/qffmpegwindowcapture_uwp.cpp b/src/plugins/multimedia/ffmpeg/qffmpegwindowcapture_uwp.cpp index c8543b593..70746ea4c 100644 --- a/src/plugins/multimedia/ffmpeg/qffmpegwindowcapture_uwp.cpp +++ b/src/plugins/multimedia/ffmpeg/qffmpegwindowcapture_uwp.cpp @@ -306,7 +306,7 @@ public: const qreal refreshRate = getMonitorRefreshRateHz(monitor); - m_format.setFrameRate(refreshRate); + m_format.setStreamFrameRate(refreshRate); setFrameRate(refreshRate); addFrameCallback(capture, &QFFmpegWindowCaptureUwp::newVideoFrame); diff --git a/src/plugins/multimedia/ffmpeg/qgdiwindowcapture.cpp b/src/plugins/multimedia/ffmpeg/qgdiwindowcapture.cpp index 4188ed4c2..ed85cd73a 100644 --- a/src/plugins/multimedia/ffmpeg/qgdiwindowcapture.cpp +++ b/src/plugins/multimedia/ffmpeg/qgdiwindowcapture.cpp @@ -104,7 +104,7 @@ private: } QVideoFrameFormat format(size, QVideoFrameFormat::Format_BGRX8888); - format.setFrameRate(frameRate()); + format.setStreamFrameRate(frameRate()); m_format = format; return true; } diff --git a/src/plugins/multimedia/ffmpeg/qgrabwindowsurfacecapture.cpp b/src/plugins/multimedia/ffmpeg/qgrabwindowsurfacecapture.cpp index df16a8f56..57eda3495 100644 --- a/src/plugins/multimedia/ffmpeg/qgrabwindowsurfacecapture.cpp +++ b/src/plugins/multimedia/ffmpeg/qgrabwindowsurfacecapture.cpp @@ -136,7 +136,7 @@ private: QVideoFrameFormat format(img.size(), QVideoFrameFormat::pixelFormatFromImageFormat(img.format())); - format.setFrameRate(screen->refreshRate()); + format.setStreamFrameRate(screen->refreshRate()); updateFormat(format); if (!format.isValid()) { diff --git a/src/plugins/multimedia/ffmpeg/qx11surfacecapture.cpp b/src/plugins/multimedia/ffmpeg/qx11surfacecapture.cpp index 1f04703f1..ab5ea3f48 100644 --- a/src/plugins/multimedia/ffmpeg/qx11surfacecapture.cpp +++ b/src/plugins/multimedia/ffmpeg/qx11surfacecapture.cpp @@ -245,7 +245,7 @@ private: } QVideoFrameFormat format(QSize(m_xImage->width, m_xImage->height), pixelFormat); - format.setFrameRate(frameRate()); + format.setStreamFrameRate(frameRate()); m_format = format; } diff --git a/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegrecordingengine.cpp b/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegrecordingengine.cpp index 2b32af502..23bd4c02d 100644 --- a/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegrecordingengine.cpp +++ b/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegrecordingengine.cpp @@ -60,8 +60,8 @@ void RecordingEngine::addVideoSource(QPlatformVideoSource * source) qCDebug(qLcFFmpegEncoder) << "adding video source" << source->metaObject()->className() << ":" << "pixelFormat=" << frameFormat.pixelFormat() << "frameSize=" << frameFormat.frameSize() - << "frameRate=" << frameFormat.frameRate() << "ffmpegHWPixelFormat=" - << (hwPixelFormat ? *hwPixelFormat : AV_PIX_FMT_NONE); + << "frameRate=" << frameFormat.streamFrameRate() + << "ffmpegHWPixelFormat=" << (hwPixelFormat ? *hwPixelFormat : AV_PIX_FMT_NONE); auto veUPtr = std::make_unique<VideoEncoder>(*this, m_settings, frameFormat, hwPixelFormat); if (!veUPtr->isValid()) { diff --git a/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoencoder.cpp b/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoencoder.cpp index a47968096..d57415e57 100644 --- a/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoencoder.cpp +++ b/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoencoder.cpp @@ -22,7 +22,7 @@ VideoEncoder::VideoEncoder(RecordingEngine &recordingEngine, const QMediaEncoder AVPixelFormat swFormat = QFFmpegVideoBuffer::toAVPixelFormat(format.pixelFormat()); AVPixelFormat ffmpegPixelFormat = hwFormat && *hwFormat != AV_PIX_FMT_NONE ? *hwFormat : swFormat; - auto frameRate = format.frameRate(); + auto frameRate = format.streamFrameRate(); if (frameRate <= 0.) { qWarning() << "Invalid frameRate" << frameRate << "; Using the default instead"; diff --git a/src/plugins/multimedia/gstreamer/common/qgst.cpp b/src/plugins/multimedia/gstreamer/common/qgst.cpp index 191fae49b..9e0a63488 100644 --- a/src/plugins/multimedia/gstreamer/common/qgst.cpp +++ b/src/plugins/multimedia/gstreamer/common/qgst.cpp @@ -329,7 +329,7 @@ std::optional<std::pair<QVideoFrameFormat, GstVideoInfo>> QGstCaps::formatAndVid qt_videoFormatLookup[index].pixelFormat); if (vidInfo.fps_d > 0) - format.setFrameRate(qreal(vidInfo.fps_n) / vidInfo.fps_d); + format.setStreamFrameRate(qreal(vidInfo.fps_n) / vidInfo.fps_d); QVideoFrameFormat::ColorRange range = QVideoFrameFormat::ColorRange_Unknown; switch (vidInfo.colorimetry.range) { diff --git a/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp b/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp index 2cc062195..41d54de0d 100644 --- a/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp +++ b/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp @@ -84,7 +84,7 @@ void tst_QVideoFrameFormat::constructNull() QCOMPARE(format.frameHeight(), -1); QCOMPARE(format.viewport(), QRect()); QCOMPARE(format.scanLineDirection(), QVideoFrameFormat::TopToBottom); - QCOMPARE(format.frameRate(), 0.0); + QCOMPARE(format.streamFrameRate(), 0.0); QCOMPARE(format.colorSpace(), QVideoFrameFormat::ColorSpace_Undefined); } @@ -132,7 +132,7 @@ void tst_QVideoFrameFormat::construct() QCOMPARE(format.isValid(), valid); QCOMPARE(format.viewport(), viewport); QCOMPARE(format.scanLineDirection(), QVideoFrameFormat::TopToBottom); - QCOMPARE(format.frameRate(), 0.0); + QCOMPARE(format.streamFrameRate(), 0.0); QCOMPARE(format.colorSpace(), QVideoFrameFormat::ColorSpace_Undefined); } @@ -335,9 +335,9 @@ void tst_QVideoFrameFormat::frameRate() QVideoFrameFormat format(QSize(64, 64), QVideoFrameFormat::Format_XRGB8888); - format.setFrameRate(frameRate); + format.setStreamFrameRate(frameRate); - QCOMPARE(format.frameRate(), frameRate); + QCOMPARE(format.streamFrameRate(), frameRate); } void tst_QVideoFrameFormat::compare() @@ -395,13 +395,13 @@ void tst_QVideoFrameFormat::compare() QCOMPARE(format1 == format2, true); QCOMPARE(format1 != format2, false); - format1.setFrameRate(7.5); + format1.setStreamFrameRate(7.5); // Not equal frame rate differs. QCOMPARE(format1 == format2, false); QCOMPARE(format1 != format2, true); - format2.setFrameRate(qreal(7.50001)); + format2.setStreamFrameRate(qreal(7.50001)); // Equal. QCOMPARE(format1 == format2, true); @@ -506,7 +506,7 @@ void tst_QVideoFrameFormat::copyAllParameters() original.setScanLineDirection(QVideoFrameFormat::BottomToTop); original.setViewport(QRect(0, 0, 1024, 1024)); - original.setFrameRate(qreal(15.0)); + original.setStreamFrameRate(qreal(15.0)); original.setColorSpace(QVideoFrameFormat::ColorSpace_BT709); /* Copy the original instance to copy and verify if both the instances @@ -517,7 +517,7 @@ void tst_QVideoFrameFormat::copyAllParameters() QCOMPARE(copy.frameSize(), QSize(1024, 768)); QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop); QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024)); - QCOMPARE(copy.frameRate(), qreal(15.0)); + QCOMPARE(copy.streamFrameRate(), qreal(15.0)); QCOMPARE(copy.colorSpace(), QVideoFrameFormat::ColorSpace_BT709); /* Verify if both the instances are eqaul */ @@ -533,7 +533,7 @@ void tst_QVideoFrameFormat::assignAllParameters() QSize(64, 64), QVideoFrameFormat::Format_AYUV); copy.setScanLineDirection(QVideoFrameFormat::TopToBottom); copy.setViewport(QRect(0, 0, 640, 320)); - copy.setFrameRate(qreal(7.5)); + copy.setStreamFrameRate(qreal(7.5)); copy.setColorSpace(QVideoFrameFormat::ColorSpace_BT601); /* Create the instance and set all the parameters. */ @@ -541,7 +541,7 @@ void tst_QVideoFrameFormat::assignAllParameters() QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888); original.setScanLineDirection(QVideoFrameFormat::BottomToTop); original.setViewport(QRect(0, 0, 1024, 1024)); - original.setFrameRate(qreal(15.0)); + original.setStreamFrameRate(qreal(15.0)); original.setColorSpace(QVideoFrameFormat::ColorSpace_BT709); /* Assign the original instance to copy and verify if both the instancess @@ -552,7 +552,7 @@ void tst_QVideoFrameFormat::assignAllParameters() QCOMPARE(copy.frameSize(), QSize(1024, 768)); QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop); QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024)); - QCOMPARE(copy.frameRate(), qreal(15.0)); + QCOMPARE(copy.streamFrameRate(), qreal(15.0)); QCOMPARE(copy.colorSpace(), QVideoFrameFormat::ColorSpace_BT709); /* Verify if both the instances are eqaul */ |