diff options
Diffstat (limited to 'src/multimedia')
34 files changed, 144 insertions, 612 deletions
diff --git a/src/multimedia/audio/qaudiobuffer.cpp b/src/multimedia/audio/qaudiobuffer.cpp index 1e43ebd00..999f280b3 100644 --- a/src/multimedia/audio/qaudiobuffer.cpp +++ b/src/multimedia/audio/qaudiobuffer.cpp @@ -164,7 +164,7 @@ QAudioBufferPrivate *QAudioBufferPrivate::clone() // We want to create a single bufferprivate with a // single qaab // This should only be called when the count is > 1 - Q_ASSERT(mCount.load() > 1); + Q_ASSERT(mCount.loadRelaxed() > 1); if (mProvider) { QAbstractAudioBuffer *abuf = mProvider->clone(); @@ -458,7 +458,7 @@ void *QAudioBuffer::data() if (!isValid()) return nullptr; - if (d->mCount.load() != 1) { + if (d->mCount.loadRelaxed() != 1) { // Can't share a writable buffer // so we need to detach QAudioBufferPrivate *newd = d->clone(); @@ -483,7 +483,7 @@ void *QAudioBuffer::data() if (memBuffer) { d->mProvider->release(); - d->mCount.store(1); + d->mCount.storeRelaxed(1); d->mProvider = memBuffer; return memBuffer->writableData(); diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index b8cac18eb..051ef8b3f 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -328,16 +328,12 @@ QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const nearest.setByteOrder(order); for (QAudioFormat::SampleType sample : qAsConst(testSampleTypes)) { nearest.setSampleType(sample); - QMapIterator<int, int> sz(testSampleSizes); - while (sz.hasNext()) { - sz.next(); - nearest.setSampleSize(sz.value()); + for (int sampleSize : qAsConst(testSampleSizes)) { + nearest.setSampleSize(sampleSize); for (int channel : qAsConst(testChannels)) { nearest.setChannelCount(channel); - QMapIterator<int, int> i(testSampleRates); - while (i.hasNext()) { - i.next(); - nearest.setSampleRate(i.value()); + for (int sampleRate : qAsConst(testSampleRates)) { + nearest.setSampleRate(sampleRate); if (isFormatSupported(nearest)) return nearest; } @@ -449,7 +445,10 @@ QAudioDeviceInfo::QAudioDeviceInfo(const QString &realm, const QByteArray &handl } /*! - \internal + Returns the key that represents the audio plugin. + + \since 5.14 + \sa QAudioSystemPlugin */ QString QAudioDeviceInfo::realm() const { diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 390458b39..015c8bad7 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -87,6 +87,7 @@ public: QList<int> supportedSampleSizes() const; QList<QAudioFormat::Endian> supportedByteOrders() const; QList<QAudioFormat::SampleType> supportedSampleTypes() const; + QString realm() const; static QAudioDeviceInfo defaultInputDevice(); static QAudioDeviceInfo defaultOutputDevice(); @@ -95,7 +96,6 @@ public: private: QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); - QString realm() const; QByteArray handle() const; QAudio::Mode mode() const; diff --git a/src/multimedia/audio/qsamplecache_p.cpp b/src/multimedia/audio/qsamplecache_p.cpp index 35234f8bb..8c4fdc210 100644 --- a/src/multimedia/audio/qsamplecache_p.cpp +++ b/src/multimedia/audio/qsamplecache_p.cpp @@ -47,6 +47,8 @@ #include <QtCore/QDebug> //#define QT_SAMPLECACHE_DEBUG +#include <mutex> + QT_BEGIN_NAMESPACE @@ -98,7 +100,6 @@ QT_BEGIN_NAMESPACE QSampleCache::QSampleCache(QObject *parent) : QObject(parent) , m_networkAccessManager(nullptr) - , m_mutex(QMutex::Recursive) , m_capacity(0) , m_usage(0) , m_loadingRefCount(0) @@ -117,7 +118,7 @@ QNetworkAccessManager& QSampleCache::networkAccessManager() QSampleCache::~QSampleCache() { - QMutexLocker m(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); m_loadingThread.quit(); m_loadingThread.wait(); @@ -157,7 +158,7 @@ bool QSampleCache::isLoading() const bool QSampleCache::isCached(const QUrl &url) const { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); return m_samples.contains(url); } @@ -174,7 +175,7 @@ QSample* QSampleCache::requestSample(const QUrl& url) #ifdef QT_SAMPLECACHE_DEBUG qDebug() << "QSampleCache: request sample [" << url << "]"; #endif - QMutexLocker locker(&m_mutex); + std::unique_lock<QRecursiveMutex> locker(m_mutex); QMap<QUrl, QSample*>::iterator it = m_samples.find(url); QSample* sample; if (it == m_samples.end()) { @@ -194,7 +195,7 @@ QSample* QSampleCache::requestSample(const QUrl& url) void QSampleCache::setCapacity(qint64 capacity) { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (m_capacity == capacity) return; #ifdef QT_SAMPLECACHE_DEBUG @@ -227,7 +228,7 @@ void QSampleCache::unloadSample(QSample *sample) // Called in both threads void QSampleCache::refresh(qint64 usageChange) { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); m_usage += usageChange; if (m_capacity <= 0 || m_usage <= m_capacity) return; @@ -265,7 +266,7 @@ void QSampleCache::refresh(qint64 usageChange) // Called in both threads void QSampleCache::removeUnreferencedSample(QSample *sample) { - QMutexLocker m(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); m_staleSamples.remove(sample); } @@ -301,7 +302,8 @@ bool QSampleCache::notifyUnreferencedSample(QSample* sample) if (m_loadingThread.isRunning()) m_loadingThread.wait(); - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); + if (m_capacity > 0) return false; m_samples.remove(sample->m_url); diff --git a/src/multimedia/audio/qsamplecache_p.h b/src/multimedia/audio/qsamplecache_p.h index 094e3281e..4c2384743 100644 --- a/src/multimedia/audio/qsamplecache_p.h +++ b/src/multimedia/audio/qsamplecache_p.h @@ -143,7 +143,7 @@ private: QMap<QUrl, QSample*> m_samples; QSet<QSample*> m_staleSamples; QNetworkAccessManager *m_networkAccessManager; - mutable QMutex m_mutex; + mutable QRecursiveMutex m_mutex; qint64 m_capacity; qint64 m_usage; QThread m_loadingThread; diff --git a/src/multimedia/camera/qcameraexposure.h b/src/multimedia/camera/qcameraexposure.h index f8eb68fbf..a1dc96701 100644 --- a/src/multimedia/camera/qcameraexposure.h +++ b/src/multimedia/camera/qcameraexposure.h @@ -165,11 +165,13 @@ Q_SIGNALS: void isoSensitivityChanged(int); void exposureCompensationChanged(qreal); +protected: + virtual ~QCameraExposure(); + private: friend class QCamera; friend class QCameraPrivate; explicit QCameraExposure(QCamera *parent = nullptr); - virtual ~QCameraExposure(); Q_DISABLE_COPY(QCameraExposure) Q_DECLARE_PRIVATE(QCameraExposure) diff --git a/src/multimedia/camera/qcamerafocus.cpp b/src/multimedia/camera/qcamerafocus.cpp index e73a8ea46..775e49b63 100644 --- a/src/multimedia/camera/qcamerafocus.cpp +++ b/src/multimedia/camera/qcamerafocus.cpp @@ -325,8 +325,6 @@ class QCameraFocusPrivate : public QMediaObjectPrivate public: void initControls(); - QCameraFocus *q_ptr; - QCamera *camera; QCameraFocusControl *focusControl; @@ -373,12 +371,11 @@ void QCameraFocusPrivate::initControls() Construct a QCameraFocus for \a camera. */ -QCameraFocus::QCameraFocus(QCamera *camera): - QObject(camera), d_ptr(new QCameraFocusPrivate) +QCameraFocus::QCameraFocus(QCamera *camera) + : QObject(*new QCameraFocusPrivate, camera) { Q_D(QCameraFocus); d->camera = camera; - d->q_ptr = this; d->initControls(); } @@ -389,7 +386,6 @@ QCameraFocus::QCameraFocus(QCamera *camera): QCameraFocus::~QCameraFocus() { - delete d_ptr; } /*! diff --git a/src/multimedia/camera/qcamerafocus.h b/src/multimedia/camera/qcamerafocus.h index 31d056de9..a5d7725e3 100644 --- a/src/multimedia/camera/qcamerafocus.h +++ b/src/multimedia/camera/qcamerafocus.h @@ -152,15 +152,19 @@ Q_SIGNALS: void maximumOpticalZoomChanged(qreal); void maximumDigitalZoomChanged(qreal); +protected: + ~QCameraFocus(); + private: friend class QCamera; friend class QCameraPrivate; QCameraFocus(QCamera *camera); - ~QCameraFocus(); Q_DISABLE_COPY(QCameraFocus) Q_DECLARE_PRIVATE(QCameraFocus) - QCameraFocusPrivate *d_ptr; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QCameraFocusPrivate *d_ptr_deprecated; +#endif }; Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraFocus::FocusModes) diff --git a/src/multimedia/camera/qcameraimageprocessing.cpp b/src/multimedia/camera/qcameraimageprocessing.cpp index c2cefeae7..0328f4a56 100644 --- a/src/multimedia/camera/qcameraimageprocessing.cpp +++ b/src/multimedia/camera/qcameraimageprocessing.cpp @@ -114,8 +114,6 @@ class QCameraImageProcessingPrivate : public QMediaObjectPrivate public: void initControls(); - QCameraImageProcessing *q_ptr; - QCamera *camera; QCameraImageProcessingControl *imageControl; bool available; @@ -140,12 +138,11 @@ void QCameraImageProcessingPrivate::initControls() Construct a QCameraImageProcessing for \a camera. */ -QCameraImageProcessing::QCameraImageProcessing(QCamera *camera): - QObject(camera), d_ptr(new QCameraImageProcessingPrivate) +QCameraImageProcessing::QCameraImageProcessing(QCamera *camera) + : QObject(*new QCameraImageProcessingPrivate, camera) { Q_D(QCameraImageProcessing); d->camera = camera; - d->q_ptr = this; d->initControls(); } @@ -156,7 +153,6 @@ QCameraImageProcessing::QCameraImageProcessing(QCamera *camera): QCameraImageProcessing::~QCameraImageProcessing() { - delete d_ptr; } diff --git a/src/multimedia/camera/qcameraimageprocessing.h b/src/multimedia/camera/qcameraimageprocessing.h index 3eb7c8569..f76daf85e 100644 --- a/src/multimedia/camera/qcameraimageprocessing.h +++ b/src/multimedia/camera/qcameraimageprocessing.h @@ -116,15 +116,19 @@ public: void setColorFilter(ColorFilter filter); bool isColorFilterSupported(ColorFilter filter) const; +protected: + ~QCameraImageProcessing(); + private: friend class QCamera; friend class QCameraPrivate; QCameraImageProcessing(QCamera *camera); - ~QCameraImageProcessing(); Q_DISABLE_COPY(QCameraImageProcessing) Q_DECLARE_PRIVATE(QCameraImageProcessing) - QCameraImageProcessingPrivate *d_ptr; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QCameraImageProcessingPrivate *d_ptr_deprecated; +#endif }; QT_END_NAMESPACE diff --git a/src/multimedia/configure.json b/src/multimedia/configure.json index 6d56af5ed..ca2839cea 100644 --- a/src/multimedia/configure.json +++ b/src/multimedia/configure.json @@ -95,6 +95,17 @@ { "libs": "-lgstphotography-1.0" } ] }, + "gstreamer_gl_1_0": { + "label": "GStreamer OpenGL 1.0", + "export": "gstreamer_gl", + "test": { + "include": "gst/gl/gl.h" + }, + "use": "gstreamer_1_0", + "sources": [ + { "type": "pkgConfig", "args": "gstreamer-gl-1.0" } + ] + }, "libresourceqt5": { "label": "libresourceqt5", "test": "resourcepolicy", @@ -229,6 +240,11 @@ "condition": "(features.gstreamer_1_0 && libs.gstreamer_photography_1_0) || (features.gstreamer_0_10 && libs.gstreamer_photography_0_10)", "output": [ "privateFeature" ] }, + "gstreamer_gl": { + "label": "GStreamer OpenGL", + "condition": "features.gstreamer_1_0 && libs.gstreamer_gl_1_0", + "output": [ "privateFeature" ] + }, "gpu_vivante": { "label": "Vivante GPU", "condition": "features.gui && features.opengles2 && tests.gpu_vivante", diff --git a/src/multimedia/doc/snippets/multimedia-snippets/audio.cpp b/src/multimedia/doc/snippets/multimedia-snippets/audio.cpp index 9646b708e..57d3adfb4 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/audio.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/audio.cpp @@ -213,7 +213,8 @@ void AudioDeviceInfo() //! [Setting audio format] //! [Dumping audio formats] - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); + for (const QAudioDeviceInfo &deviceInfo : deviceInfos) qDebug() << "Device name: " << deviceInfo.deviceName(); //! [Dumping audio formats] } diff --git a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp index 52f3203be..f851caadd 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp @@ -179,8 +179,8 @@ void overview_movie() void camera_listing() { //! [Camera listing] - QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); - foreach (const QCameraInfo &cameraInfo, cameras) + const QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); + for (const QCameraInfo &cameraInfo : cameras) qDebug() << cameraInfo.deviceName(); //! [Camera listing] } @@ -188,8 +188,8 @@ void camera_listing() void camera_selection() { //! [Camera selection] - QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); - foreach (const QCameraInfo &cameraInfo, cameras) { + const QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); + for (const QCameraInfo &cameraInfo : cameras) { if (cameraInfo.deviceName() == "mycamera") camera = new QCamera(cameraInfo); } @@ -269,8 +269,8 @@ void camerafocus() //! [Camera focus zones] focus->setFocusPointMode(QCameraFocus::FocusPointAuto); - QList<QCameraFocusZone> zones = focus->focusZones(); - foreach (QCameraFocusZone zone, zones) { + const QList<QCameraFocusZone> zones = focus->focusZones(); + for (const QCameraFocusZone &zone : zones) { if (zone.status() == QCameraFocusZone::Focused) { // Draw a green box at zone.area() } else if (zone.status() == QCameraFocusZone::Selected) { diff --git a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp index 4e8c06409..8ec7cb072 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp @@ -254,10 +254,10 @@ void MediaExample::AudioRecorder() //! [Audio recorder] //! [Audio recorder inputs] - QStringList inputs = audioRecorder->audioInputs(); + const QStringList inputs = audioRecorder->audioInputs(); QString selectedInput = audioRecorder->defaultAudioInput(); - foreach (QString input, inputs) { + for (const QString &input : inputs) { QString description = audioRecorder->audioInputDescription(input); // show descriptions to user and allow selection selectedInput = input; diff --git a/src/multimedia/playback/qmediacontent.cpp b/src/multimedia/playback/qmediacontent.cpp index 95116d02f..f61511f1c 100644 --- a/src/multimedia/playback/qmediacontent.cpp +++ b/src/multimedia/playback/qmediacontent.cpp @@ -123,8 +123,7 @@ private: which provides the URL of the content. A non-null QMediaContent will always have a reference to - the content available through the canonicalUrl() or canonicalRequest() - methods. + the content available through the request() method. Alternatively QMediaContent can represent a playlist and contain a pointer to a valid QMediaPlaylist object. In this case URL is optional and can either be empty @@ -258,25 +257,34 @@ bool QMediaContent::isNull() const return d.constData() == nullptr; } +QNetworkRequest QMediaContent::request() const +{ + return (d && !d->requests.isEmpty()) ? d->requests.first() : QNetworkRequest(); +} + +#if QT_DEPRECATED_SINCE(6, 0) /*! + \obsolete + Returns a QUrl that represents that canonical resource for this media content. */ QUrl QMediaContent::canonicalUrl() const { - return canonicalRequest().url(); + return request().url(); } /*! + \obsolete + Returns a QNetworkRequest that represents that canonical resource for this media content. */ QNetworkRequest QMediaContent::canonicalRequest() const { - return (d && !d->requests.isEmpty()) ? d->requests.first() : QNetworkRequest(); + return request(); } -#if QT_DEPRECATED_SINCE(6, 0) /*! \obsolete diff --git a/src/multimedia/playback/qmediacontent.h b/src/multimedia/playback/qmediacontent.h index 5193a1fcc..244715b41 100644 --- a/src/multimedia/playback/qmediacontent.h +++ b/src/multimedia/playback/qmediacontent.h @@ -72,10 +72,11 @@ public: bool operator!=(const QMediaContent &other) const; bool isNull() const; + QNetworkRequest request() const; - QUrl canonicalUrl() const; - QNetworkRequest canonicalRequest() const; #if QT_DEPRECATED_SINCE(6, 0) + QT_DEPRECATED_X("Use QMediaContent::request().url()") QUrl canonicalUrl() const; + QT_DEPRECATED_X("Use QMediaContent::request()") QNetworkRequest canonicalRequest() const; QT_DEPRECATED QMediaResource canonicalResource() const; QT_DEPRECATED QMediaResourceList resources() const; #endif diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index c4d574d4e..5723a77dd 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -183,7 +183,7 @@ bool QMediaPlayerPrivate::isInChain(const QUrl &url) // Check whether a URL is already in the chain of playlists. // Also see a comment in parentPlaylist(). for (QMediaPlaylist *current = rootMedia.playlist(); current && current != playlist; current = current->currentMedia().playlist()) - if (current->currentMedia().canonicalUrl() == url) { + if (current->currentMedia().request().url() == url) { return true; } return false; @@ -345,10 +345,10 @@ void QMediaPlayerPrivate::setMedia(const QMediaContent &media, QIODevice *stream // Backends can't play qrc files directly. // If the backend supports StreamPlayback, we pass a QFile for that resource. // If it doesn't, we copy the data to a temporary file and pass its path. - if (!media.isNull() && !stream && media.canonicalUrl().scheme() == QLatin1String("qrc")) { + if (!media.isNull() && !stream && media.request().url().scheme() == QLatin1String("qrc")) { qrcMedia = media; - file.reset(new QFile(QLatin1Char(':') + media.canonicalUrl().path())); + file.reset(new QFile(QLatin1Char(':') + media.request().url().path())); if (!file->open(QFile::ReadOnly)) { QMetaObject::invokeMethod(q, "_q_error", Qt::QueuedConnection, Q_ARG(int, QMediaPlayer::ResourceError), @@ -464,11 +464,14 @@ void QMediaPlayerPrivate::loadPlaylist() // Do not load a playlist if there are more than MAX_NESTED_PLAYLISTS in the chain already, // or if the playlist URL is already in the chain, i.e. do not allow recursive playlists and loops. - if (nestedPlaylists < MAX_NESTED_PLAYLISTS && !q->currentMedia().canonicalUrl().isEmpty() && !isInChain(q->currentMedia().canonicalUrl())) { - pendingPlaylist = QMediaContent(new QMediaPlaylist, q->currentMedia().canonicalUrl(), true); + if (nestedPlaylists < MAX_NESTED_PLAYLISTS + && !q->currentMedia().request().url().isEmpty() + && !isInChain(q->currentMedia().request().url())) + { + pendingPlaylist = QMediaContent(new QMediaPlaylist, q->currentMedia().request().url(), true); QObject::connect(pendingPlaylist.playlist(), SIGNAL(loaded()), q, SLOT(_q_handlePlaylistLoaded())); QObject::connect(pendingPlaylist.playlist(), SIGNAL(loadFailed()), q, SLOT(_q_handlePlaylistLoadFailed())); - pendingPlaylist.playlist()->load(pendingPlaylist.canonicalRequest()); + pendingPlaylist.playlist()->load(pendingPlaylist.request()); } else if (playlist) { playlist->next(); } diff --git a/src/multimedia/playback/qplaylistfileparser.cpp b/src/multimedia/playback/qplaylistfileparser.cpp index 92e7f97e8..9af447032 100644 --- a/src/multimedia/playback/qplaylistfileparser.cpp +++ b/src/multimedia/playback/qplaylistfileparser.cpp @@ -504,7 +504,7 @@ void QPlaylistFileParser::start(const QMediaContent &media, QIODevice *stream, c if (stream) start(stream, mimeType); else - start(media.canonicalRequest(), mimeType); + start(media.request(), mimeType); } void QPlaylistFileParser::start(QIODevice *stream, const QString &mimeType) diff --git a/src/multimedia/qmediaobject.cpp b/src/multimedia/qmediaobject.cpp index a12cab404..b5fc3273b 100644 --- a/src/multimedia/qmediaobject.cpp +++ b/src/multimedia/qmediaobject.cpp @@ -113,7 +113,6 @@ void QMediaObjectPrivate::_q_availabilityChanged() QMediaObject::~QMediaObject() { - delete d_ptr; } /*! @@ -230,15 +229,11 @@ void QMediaObject::unbind(QObject *object) constructor is protected. */ -QMediaObject::QMediaObject(QObject *parent, QMediaService *service): - QObject(parent), - d_ptr(new QMediaObjectPrivate) - +QMediaObject::QMediaObject(QObject *parent, QMediaService *service) + : QObject(*new QMediaObjectPrivate, parent) { Q_D(QMediaObject); - d->q_ptr = this; - d->notifyTimer = new QTimer(this); d->notifyTimer->setInterval(1000); connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); @@ -252,13 +247,10 @@ QMediaObject::QMediaObject(QObject *parent, QMediaService *service): \internal */ -QMediaObject::QMediaObject(QMediaObjectPrivate &dd, QObject *parent, - QMediaService *service): - QObject(parent), - d_ptr(&dd) +QMediaObject::QMediaObject(QMediaObjectPrivate &dd, QObject *parent, QMediaService *service) + : QObject(dd, parent) { Q_D(QMediaObject); - d->q_ptr = this; d->notifyTimer = new QTimer(this); d->notifyTimer->setInterval(1000); diff --git a/src/multimedia/qmediaobject.h b/src/multimedia/qmediaobject.h index 5788254b8..fabd015fe 100644 --- a/src/multimedia/qmediaobject.h +++ b/src/multimedia/qmediaobject.h @@ -93,7 +93,9 @@ protected: void addPropertyWatch(QByteArray const &name); void removePropertyWatch(QByteArray const &name); - QMediaObjectPrivate *d_ptr; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QMediaObjectPrivate *d_ptr_deprecated; +#endif private: void setupControls(); diff --git a/src/multimedia/qmediaobject_p.h b/src/multimedia/qmediaobject_p.h index 85caf9a50..5067fa6d1 100644 --- a/src/multimedia/qmediaobject_p.h +++ b/src/multimedia/qmediaobject_p.h @@ -56,6 +56,7 @@ #include <QtCore/qtimer.h> #include "qmediaobject.h" +#include "private/qobject_p.h" QT_BEGIN_NAMESPACE @@ -68,12 +69,12 @@ class QMediaAvailabilityControl; friend class Class; -class QMediaObjectPrivate +class QMediaObjectPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QMediaObject) public: - QMediaObjectPrivate() : service(nullptr), metaDataControl(nullptr), availabilityControl(nullptr), notifyTimer(nullptr), q_ptr(nullptr) {} + QMediaObjectPrivate() : service(nullptr), metaDataControl(nullptr), availabilityControl(nullptr), notifyTimer(nullptr) {} virtual ~QMediaObjectPrivate() {} void _q_notify(); @@ -85,8 +86,6 @@ public: QTimer* notifyTimer; QSet<int> notifyProperties; - - QMediaObject *q_ptr; }; QT_END_NAMESPACE diff --git a/src/multimedia/qmediaservice.cpp b/src/multimedia/qmediaservice.cpp index 4d6b3c039..52f5fdee3 100644 --- a/src/multimedia/qmediaservice.cpp +++ b/src/multimedia/qmediaservice.cpp @@ -87,20 +87,16 @@ QT_BEGIN_NAMESPACE */ QMediaService::QMediaService(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaServicePrivate) + : QObject(*new QMediaServicePrivate, parent) { - d_ptr->q_ptr = this; } /*! \internal */ QMediaService::QMediaService(QMediaServicePrivate &dd, QObject *parent) - : QObject(parent) - , d_ptr(&dd) + : QObject(dd, parent) { - d_ptr->q_ptr = this; } /*! @@ -109,7 +105,6 @@ QMediaService::QMediaService(QMediaServicePrivate &dd, QObject *parent) QMediaService::~QMediaService() { - delete d_ptr; } /*! diff --git a/src/multimedia/qmediaservice.h b/src/multimedia/qmediaservice.h index 9e653b2d8..019b86693 100644 --- a/src/multimedia/qmediaservice.h +++ b/src/multimedia/qmediaservice.h @@ -74,7 +74,9 @@ protected: QMediaService(QObject* parent); QMediaService(QMediaServicePrivate &dd, QObject *parent); - QMediaServicePrivate *d_ptr; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QMediaServicePrivate *d_ptr_deprecated; +#endif private: Q_DECLARE_PRIVATE(QMediaService) diff --git a/src/multimedia/qmediaservice_p.h b/src/multimedia/qmediaservice_p.h index 8c18ab1df..a9dbd5d29 100644 --- a/src/multimedia/qmediaservice_p.h +++ b/src/multimedia/qmediaservice_p.h @@ -51,18 +51,19 @@ // We mean it. // +#include "private/qobject_p.h" + QT_BEGIN_NAMESPACE class QAudioDeviceControl; -class QMediaServicePrivate +class QMediaServicePrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QMediaService) public: - QMediaServicePrivate(): q_ptr(0) {} + QMediaServicePrivate() {} virtual ~QMediaServicePrivate() {} - - QMediaService *q_ptr; }; QT_END_NAMESPACE diff --git a/src/multimedia/qmediaserviceproviderplugin.h b/src/multimedia/qmediaserviceproviderplugin.h index 6447e319a..9afb4f4cd 100644 --- a/src/multimedia/qmediaserviceproviderplugin.h +++ b/src/multimedia/qmediaserviceproviderplugin.h @@ -50,6 +50,8 @@ # pragma Q_MOC_EXPAND_MACROS #endif +#if QT_DEPRECATED_SINCE(5, 14) + QT_BEGIN_NAMESPACE // Required for QDoc workaround @@ -252,4 +254,5 @@ public: QT_END_NAMESPACE +#endif // #if QT_DEPRECATED_SINCE(5, 14) #endif // QMEDIASERVICEPROVIDERPLUGIN_H diff --git a/src/multimedia/qmediatimerange.cpp b/src/multimedia/qmediatimerange.cpp index 676d3d391..3a22e000f 100644 --- a/src/multimedia/qmediatimerange.cpp +++ b/src/multimedia/qmediatimerange.cpp @@ -94,6 +94,7 @@ QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! \fn QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) @@ -105,6 +106,7 @@ QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) { } +#endif /*! \fn QMediaTimeInterval::start() const diff --git a/src/multimedia/qmediatimerange.h b/src/multimedia/qmediatimerange.h index 5b6d711af..71145adde 100644 --- a/src/multimedia/qmediatimerange.h +++ b/src/multimedia/qmediatimerange.h @@ -54,8 +54,12 @@ class Q_MULTIMEDIA_EXPORT QMediaTimeInterval public: QMediaTimeInterval(); QMediaTimeInterval(qint64 start, qint64 end); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QMediaTimeInterval(const QMediaTimeInterval&); QMediaTimeInterval &operator=(const QMediaTimeInterval&) = default; + QMediaTimeInterval(QMediaTimeInterval &&) = default; + QMediaTimeInterval &operator=(QMediaTimeInterval &&) = default; +#endif qint64 start() const; qint64 end() const; diff --git a/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_backend_p.h b/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_backend_p.h deleted file mode 100644 index da99b387a..000000000 --- a/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_backend_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIDEOOUTPUT_BACKEND_P_H -#define QDECLARATIVEVIDEOOUTPUT_BACKEND_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qpointer.h> -#include <QtCore/qsize.h> -#include <QtQuick/qquickitem.h> -#include <QtQuick/qsgnode.h> -#include <private/qtmultimediaquickdefs_p.h> - -QT_BEGIN_NAMESPACE - -class QAbstractVideoSurface; -class QDeclarativeVideoOutput; -class QMediaService; -class QAbstractVideoFilter; - -class Q_MULTIMEDIAQUICK_EXPORT QDeclarativeVideoBackend -{ -public: - explicit QDeclarativeVideoBackend(QDeclarativeVideoOutput *parent) - : q(parent) - {} - - virtual ~QDeclarativeVideoBackend() - {} - - virtual bool init(QMediaService *service) = 0; - virtual void releaseSource() = 0; - virtual void releaseControl() = 0; - virtual void itemChange(QQuickItem::ItemChange change, - const QQuickItem::ItemChangeData &changeData) = 0; - virtual QSize nativeSize() const = 0; - virtual void updateGeometry() = 0; - virtual QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) = 0; - virtual QAbstractVideoSurface *videoSurface() const = 0; - - // The viewport, adjusted for the pixel aspect ratio - virtual QRectF adjustedViewport() const = 0; - - virtual void appendFilter(QAbstractVideoFilter *filter) { Q_UNUSED(filter); } - virtual void clearFilters() { } - - virtual void releaseResources() { } - virtual void invalidateSceneGraph() { } - -protected: - QDeclarativeVideoOutput *q; - QPointer<QMediaService> m_service; -}; - -class QDeclarativeVideoBackendFactoryInterface -{ -public: - virtual QDeclarativeVideoBackend *create(QDeclarativeVideoOutput *parent) = 0; -}; - -#define QDeclarativeVideoBackendFactoryInterface_iid "org.qt-project.qt.declarativevideobackendfactory/5.2" -Q_DECLARE_INTERFACE(QDeclarativeVideoBackendFactoryInterface, QDeclarativeVideoBackendFactoryInterface_iid) - -/* - * Helper - returns true if the given orientation has the same aspect as the default (e.g. 180*n) - */ -namespace { - -inline bool qIsDefaultAspect(int o) -{ - return (o % 180) == 0; -} - -/* - * Return the orientation normalized to 0-359 - */ -inline int qNormalizedOrientation(int o) -{ - // Negative orientations give negative results - int o2 = o % 360; - if (o2 < 0) - o2 += 360; - return o2; -} - -} - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h b/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h deleted file mode 100644 index 8ea0dc338..000000000 --- a/src/multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIDEOOUTPUT_P_H -#define QDECLARATIVEVIDEOOUTPUT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qrect.h> -#include <QtCore/qsharedpointer.h> -#include <QtQuick/qquickitem.h> -#include <QtCore/qpointer.h> -#include <QtMultimedia/qcamerainfo.h> -#include <QtMultimedia/qabstractvideofilter.h> - -#include <private/qtmultimediaquickdefs_p.h> - -QT_BEGIN_NAMESPACE - -class QMediaObject; -class QMediaService; -class QDeclarativeVideoBackend; -class QVideoOutputOrientationHandler; - -class Q_MULTIMEDIAQUICK_EXPORT QDeclarativeVideoOutput : public QQuickItem -{ - Q_OBJECT - Q_DISABLE_COPY(QDeclarativeVideoOutput) - Q_PROPERTY(QObject* source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) - Q_PROPERTY(int orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) - Q_PROPERTY(bool autoOrientation READ autoOrientation WRITE setAutoOrientation NOTIFY autoOrientationChanged REVISION 2) - Q_PROPERTY(QRectF sourceRect READ sourceRect NOTIFY sourceRectChanged) - Q_PROPERTY(QRectF contentRect READ contentRect NOTIFY contentRectChanged) - Q_PROPERTY(QQmlListProperty<QAbstractVideoFilter> filters READ filters); - Q_PROPERTY(FlushMode flushMode READ flushMode WRITE setFlushMode NOTIFY flushModeChanged REVISION 13) - Q_ENUMS(FlushMode) - Q_ENUMS(FillMode) - -public: - - enum FlushMode - { - EmptyFrame, - FirstFrame, - LastFrame - }; - - enum FillMode - { - Stretch = Qt::IgnoreAspectRatio, - PreserveAspectFit = Qt::KeepAspectRatio, - PreserveAspectCrop = Qt::KeepAspectRatioByExpanding - }; - - QDeclarativeVideoOutput(QQuickItem *parent = 0); - ~QDeclarativeVideoOutput(); - - QObject *source() const { return m_source.data(); } - void setSource(QObject *source); - - FillMode fillMode() const; - void setFillMode(FillMode mode); - - int orientation() const; - void setOrientation(int); - - bool autoOrientation() const; - void setAutoOrientation(bool); - - QRectF sourceRect() const; - QRectF contentRect() const; - - Q_INVOKABLE QPointF mapPointToItem(const QPointF &point) const; - Q_INVOKABLE QRectF mapRectToItem(const QRectF &rectangle) const; - Q_INVOKABLE QPointF mapNormalizedPointToItem(const QPointF &point) const; - Q_INVOKABLE QRectF mapNormalizedRectToItem(const QRectF &rectangle) const; - Q_INVOKABLE QPointF mapPointToSource(const QPointF &point) const; - Q_INVOKABLE QRectF mapRectToSource(const QRectF &rectangle) const; - Q_INVOKABLE QPointF mapPointToSourceNormalized(const QPointF &point) const; - Q_INVOKABLE QRectF mapRectToSourceNormalized(const QRectF &rectangle) const; - - enum SourceType { - NoSource, - MediaObjectSource, - VideoSurfaceSource - }; - SourceType sourceType() const; - - QQmlListProperty<QAbstractVideoFilter> filters(); - - FlushMode flushMode() const { return m_flushMode; } - void setFlushMode(FlushMode mode); - -Q_SIGNALS: - void sourceChanged(); - void fillModeChanged(QDeclarativeVideoOutput::FillMode); - void orientationChanged(); - void autoOrientationChanged(); - void sourceRectChanged(); - void contentRectChanged(); - void flushModeChanged(); - -protected: - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; - void itemChange(ItemChange change, const ItemChangeData &changeData) override; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; - void releaseResources() override; - -private Q_SLOTS: - void _q_updateMediaObject(); - void _q_updateCameraInfo(); - void _q_updateNativeSize(); - void _q_updateGeometry(); - void _q_screenOrientationChanged(int); - void _q_invalidateSceneGraph(); - -private: - bool createBackend(QMediaService *service); - - static void filter_append(QQmlListProperty<QAbstractVideoFilter> *property, QAbstractVideoFilter *value); - static int filter_count(QQmlListProperty<QAbstractVideoFilter> *property); - static QAbstractVideoFilter *filter_at(QQmlListProperty<QAbstractVideoFilter> *property, int index); - static void filter_clear(QQmlListProperty<QAbstractVideoFilter> *property); - - SourceType m_sourceType; - - QPointer<QObject> m_source; - QPointer<QMediaObject> m_mediaObject; - QPointer<QMediaService> m_service; - QCameraInfo m_cameraInfo; - - FillMode m_fillMode; - QSize m_nativeSize; - - bool m_geometryDirty; - QRectF m_lastRect; // Cache of last rect to avoid recalculating geometry - QRectF m_contentRect; // Destination pixel coordinates, unclipped - int m_orientation; - bool m_autoOrientation; - QVideoOutputOrientationHandler *m_screenOrientationHandler; - - QScopedPointer<QDeclarativeVideoBackend> m_backend; - - QList<QAbstractVideoFilter *> m_filters; - FlushMode m_flushMode = EmptyFrame; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEVIDEOOUTPUT_H diff --git a/src/multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h b/src/multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h deleted file mode 100644 index c094bed1f..000000000 --- a/src/multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSGVIDEONODE_P_H -#define QSGVIDEONODE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuick/qsgnode.h> -#include <private/qtmultimediaquickdefs_p.h> - -#include <QtMultimedia/qvideoframe.h> -#include <QtMultimedia/qvideosurfaceformat.h> -#include <QtGui/qopenglfunctions.h> - -QT_BEGIN_NAMESPACE - -class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNode : public QSGGeometryNode -{ -public: - enum FrameFlag { - FrameFiltered = 0x01 - }; - Q_DECLARE_FLAGS(FrameFlags, FrameFlag) - - QSGVideoNode(); - - virtual void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) = 0; - virtual QVideoFrame::PixelFormat pixelFormat() const = 0; - virtual QAbstractVideoBuffer::HandleType handleType() const = 0; - - void setTexturedRectGeometry(const QRectF &boundingRect, const QRectF &textureRect, int orientation); - -private: - QRectF m_rect; - QRectF m_textureRect; - int m_orientation; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QSGVideoNode::FrameFlags) - -class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryInterface -{ -public: - virtual ~QSGVideoNodeFactoryInterface(); - - virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const = 0; - virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0; -}; - -#define QSGVideoNodeFactoryInterface_iid "org.qt-project.qt.sgvideonodefactory/5.2" -Q_DECLARE_INTERFACE(QSGVideoNodeFactoryInterface, QSGVideoNodeFactoryInterface_iid) - -class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryPlugin : public QObject, public QSGVideoNodeFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QSGVideoNodeFactoryInterface) -public: - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const override = 0; - QSGVideoNode *createNode(const QVideoSurfaceFormat &format) override = 0; -}; - -QT_END_NAMESPACE - -#endif // QSGVIDEONODE_H diff --git a/src/multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h b/src/multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h deleted file mode 100644 index 20188739c..000000000 --- a/src/multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QMULTIMEDIAQUICKDEFS_P_H -#define QMULTIMEDIAQUICKDEFS_P_H - -#include <QtCore/qglobal.h> - -#ifndef QT_STATIC -# if defined(QT_BUILD_QTMULTIMEDIAQUICKTOOLS_LIB) -# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_EXPORT -# else -# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_MULTIMEDIAQUICK_EXPORT -#endif - - -#endif // QMULTIMEDIAQUICKDEFS_P_H - diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index e94b838f9..dfc6ad3ee 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -227,6 +227,11 @@ private: horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are half that of the Y plane. + \value Format_YUV422P + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally sub-sampled, i.e. the width of the U and V planes are + half that of the Y plane, and height of U and V planes is the same as Y. + \value Format_YV12 The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are @@ -638,6 +643,7 @@ bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) // Single plane or opaque format. break; case Format_YUV420P: + case Format_YUV422P: case Format_YV12: { // The UV stride is usually half the Y stride and is 32-bit aligned. // However it's not always the case, at least on Windows where the @@ -646,13 +652,14 @@ bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) // have a correct stride. const int height = d->size.height(); const int yStride = d->bytesPerLine[0]; - const int uvStride = (d->mappedBytes - (yStride * height)) / height; + const int uvHeight = d->pixelFormat == Format_YUV422P ? height : height / 2; + const int uvStride = (d->mappedBytes - (yStride * height)) / uvHeight / 2; - // Three planes, the second and third vertically and horizontally subsampled. + // Three planes, the second and third vertically (and horizontally for other than Format_YUV422P formats) subsampled. d->planeCount = 3; d->bytesPerLine[2] = d->bytesPerLine[1] = uvStride; d->data[1] = d->data[0] + (yStride * height); - d->data[2] = d->data[1] + (uvStride * height / 2); + d->data[2] = d->data[1] + (uvStride * uvHeight); break; } case Format_NV12: @@ -1001,6 +1008,7 @@ QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format) case Format_AYUV444_Premultiplied: case Format_YUV444: case Format_YUV420P: + case Format_YUV422P: case Format_YV12: case Format_UYVY: case Format_YUYV: @@ -1058,6 +1066,7 @@ static VideoFrameConvertFunc qConvertFuncs[QVideoFrame::NPixelFormats] = { /* Format_AYUV444_Premultiplied */ nullptr, /* Format_YUV444 */ qt_convert_YUV444_to_ARGB32, /* Format_YUV420P */ qt_convert_YUV420P_to_ARGB32, + /* Format_YUV422P */ nullptr, /* Format_YV12 */ qt_convert_YV12_to_ARGB32, /* Format_UYVY */ qt_convert_UYVY_to_ARGB32, /* Format_YUYV */ qt_convert_YUYV_to_ARGB32, @@ -1191,6 +1200,8 @@ QDebug operator<<(QDebug dbg, QVideoFrame::PixelFormat pf) return dbg << "Format_YUV444"; case QVideoFrame::Format_YUV420P: return dbg << "Format_YUV420P"; + case QVideoFrame::Format_YUV422P: + return dbg << "Format_YUV422P"; case QVideoFrame::Format_YV12: return dbg << "Format_YV12"; case QVideoFrame::Format_UYVY: diff --git a/src/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h index 375f80dac..b0710cd27 100644 --- a/src/multimedia/video/qvideoframe.h +++ b/src/multimedia/video/qvideoframe.h @@ -86,6 +86,7 @@ public: Format_AYUV444_Premultiplied, Format_YUV444, Format_YUV420P, + Format_YUV422P, Format_YV12, Format_UYVY, Format_YUYV, diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp index 7a703c260..77ea276c7 100644 --- a/src/multimedia/video/qvideosurfaceformat.cpp +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -519,9 +519,9 @@ QList<QByteArray> QVideoSurfaceFormat::propertyNames() const QVariant QVideoSurfaceFormat::property(const char *name) const { if (qstrcmp(name, "handleType") == 0) { - return qVariantFromValue(d->handleType); + return QVariant::fromValue(d->handleType); } else if (qstrcmp(name, "pixelFormat") == 0) { - return qVariantFromValue(d->pixelFormat); + return QVariant::fromValue(d->pixelFormat); } else if (qstrcmp(name, "frameSize") == 0) { return d->frameSize; } else if (qstrcmp(name, "frameWidth") == 0) { @@ -531,15 +531,15 @@ QVariant QVideoSurfaceFormat::property(const char *name) const } else if (qstrcmp(name, "viewport") == 0) { return d->viewport; } else if (qstrcmp(name, "scanLineDirection") == 0) { - return qVariantFromValue(d->scanLineDirection); + return QVariant::fromValue(d->scanLineDirection); } else if (qstrcmp(name, "frameRate") == 0) { - return qVariantFromValue(d->frameRate); + return QVariant::fromValue(d->frameRate); } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - return qVariantFromValue(d->pixelAspectRatio); + return QVariant::fromValue(d->pixelAspectRatio); } else if (qstrcmp(name, "sizeHint") == 0) { return sizeHint(); } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - return qVariantFromValue(d->ycbcrColorSpace); + return QVariant::fromValue(d->ycbcrColorSpace); } else if (qstrcmp(name, "mirrored") == 0) { return d->mirrored; } else { |