diff options
Diffstat (limited to 'src/multimedia')
21 files changed, 94 insertions, 560 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/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.h b/src/multimedia/camera/qcamerafocus.h index 31d056de9..024f504e9 100644 --- a/src/multimedia/camera/qcamerafocus.h +++ b/src/multimedia/camera/qcamerafocus.h @@ -152,11 +152,13 @@ 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) diff --git a/src/multimedia/camera/qcameraimageprocessing.h b/src/multimedia/camera/qcameraimageprocessing.h index 3eb7c8569..e4ad00ff8 100644 --- a/src/multimedia/camera/qcameraimageprocessing.h +++ b/src/multimedia/camera/qcameraimageprocessing.h @@ -116,11 +116,13 @@ 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) 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 7cabfabf3..60097d917 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp @@ -223,10 +223,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 81d525ea8..6ff3fc7df 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/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 { |