summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp15
-rw-r--r--tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp41
-rw-r--r--tests/auto/integration/qmediaplayerbackend/BLACKLIST1
-rw-r--r--tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp48
-rw-r--r--tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp18
-rw-r--r--tests/auto/unit/qcamera/tst_qcamera.cpp2
-rw-r--r--tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro2
-rw-r--r--tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp49
-rw-r--r--tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp43
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp6
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp6
-rw-r--r--tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp113
-rw-r--r--tests/auto/unit/qvideoframe/tst_qvideoframe.cpp171
-rw-r--r--tests/auto/unit/qvideowidget/tst_qvideowidget.cpp29
14 files changed, 461 insertions, 83 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp
index 894486230..068b30653 100644
--- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp
+++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp
@@ -49,7 +49,6 @@
#include <qcameraimagecapture.h>
#include <qvideorenderercontrol.h>
#include <private/qmediaserviceprovider_p.h>
-#include <private/qvideoframe_p.h>
QT_USE_NAMESPACE
@@ -215,7 +214,7 @@ void tst_QCameraBackend::testCameraStates()
QCamera camera;
QCameraImageCapture imageCapture(&camera);
- QSignalSpy errorSignal(&camera, SIGNAL(error(QCamera::Error)));
+ QSignalSpy errorSignal(&camera, SIGNAL(errorOccurred(QCamera::Error)));
QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State)));
QSignalSpy statusChangedSignal(&camera, SIGNAL(statusChanged(QCamera::Status)));
@@ -263,8 +262,8 @@ void tst_QCameraBackend::testCameraStartError()
{
QCamera camera1(QCameraInfo::defaultCamera());
QCamera camera2(QCameraInfo::defaultCamera());
- QSignalSpy errorSpy1(&camera1, QOverload<QCamera::Error>::of(&QCamera::error));
- QSignalSpy errorSpy2(&camera2, QOverload<QCamera::Error>::of(&QCamera::error));
+ QSignalSpy errorSpy1(&camera1, &QCamera::errorOccurred);
+ QSignalSpy errorSpy2(&camera2, &QCamera::errorOccurred);
camera1.start();
camera2.start();
@@ -284,7 +283,7 @@ void tst_QCameraBackend::testCaptureMode()
{
QCamera camera;
- QSignalSpy errorSignal(&camera, SIGNAL(error(QCamera::Error)));
+ QSignalSpy errorSignal(&camera, SIGNAL(errorOccurred(QCamera::Error)));
QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State)));
QSignalSpy captureModeSignal(&camera, SIGNAL(captureModeChanged(QCamera::CaptureModes)));
@@ -451,7 +450,7 @@ void tst_QCameraBackend::testCaptureToBuffer()
QCOMPARE(imageAvailableSignal.first().first().toInt(), id);
QVideoFrame frame = imageAvailableSignal.first().last().value<QVideoFrame>();
- QVERIFY(!qt_imageFromVideoFrame(frame).isNull());
+ QVERIFY(!frame.image().isNull());
frame = QVideoFrame();
capturedSignal.clear();
@@ -509,7 +508,7 @@ void tst_QCameraBackend::testCaptureToBuffer()
QCOMPARE(imageAvailableSignal.first().first().toInt(), id);
frame = imageAvailableSignal.first().last().value<QVideoFrame>();
- QVERIFY(!qt_imageFromVideoFrame(frame).isNull());
+ QVERIFY(!frame.image().isNull());
QString fileName = savedSignal.first().last().toString();
QVERIFY(QFileInfo(fileName).exists());
@@ -632,7 +631,7 @@ void tst_QCameraBackend::testVideoRecording()
QMediaRecorder recorder(camera.data());
- QSignalSpy errorSignal(camera.data(), SIGNAL(error(QCamera::Error)));
+ QSignalSpy errorSignal(camera.data(), SIGNAL(errorOccurred(QCamera::Error)));
QSignalSpy recorderErrorSignal(&recorder, SIGNAL(error(QMediaRecorder::Error)));
QSignalSpy recorderStatusSignal(&recorder, SIGNAL(statusChanged(QMediaRecorder::Status)));
diff --git a/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp b/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp
index 798b63f96..27c7d85de 100644
--- a/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp
+++ b/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp
@@ -32,6 +32,7 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
+#include <QQuickView>
#include "private/qdeclarativevideooutput_p.h"
@@ -109,6 +110,7 @@ private slots:
void flushMode();
void orientation();
void surfaceSource();
+ void paintSurface();
void sourceRect();
void contentRect();
@@ -349,6 +351,45 @@ void tst_QDeclarativeVideoOutput::surfaceSource()
delete videoOutput2;
}
+static const uchar rgb32ImageData[] =
+{// B G R A
+ 0x00, 0x01, 0x02, 0xff, 0x03, 0x04, 0x05, 0xff,
+ 0x06, 0x07, 0x08, 0xff, 0x09, 0x0a, 0x0b, 0xff
+};
+
+void tst_QDeclarativeVideoOutput::paintSurface()
+{
+ QQuickView window;
+ window.setSource(QUrl("qrc:/main.qml"));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ auto videoOutput = qobject_cast<QDeclarativeVideoOutput *>(window.rootObject());
+ QVERIFY(videoOutput);
+
+ auto surface = videoOutput->property("videoSurface").value<QAbstractVideoSurface *>();
+ QVERIFY(surface);
+ QVERIFY(!surface->isActive());
+ videoOutput->setSize(QSize(2, 2));
+ QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
+ QVERIFY(surface->isFormatSupported(format));
+ QVERIFY(surface->start(format));
+ QVERIFY(surface->isActive());
+
+ QImage img(rgb32ImageData, 2, 2, 8, QImage::Format_RGB32);
+ QVERIFY(surface->present(img));
+
+ if (QGuiApplication::platformName() == QLatin1String("offscreen")
+ || QGuiApplication::platformName() == QLatin1String("minimal"))
+ return;
+
+ QImage capture = window.grabWindow();
+ QCOMPARE(capture.pixelColor(0, 0), QColor(rgb32ImageData[2], rgb32ImageData[1], rgb32ImageData[0], rgb32ImageData[3]));
+ QCOMPARE(capture.pixelColor(1, 0), QColor(rgb32ImageData[6], rgb32ImageData[5], rgb32ImageData[4], rgb32ImageData[7]));
+ QCOMPARE(capture.pixelColor(0, 1), QColor(rgb32ImageData[10], rgb32ImageData[9], rgb32ImageData[8], rgb32ImageData[11]));
+ QCOMPARE(capture.pixelColor(1, 1), QColor(rgb32ImageData[14], rgb32ImageData[13], rgb32ImageData[12], rgb32ImageData[15]));
+}
+
void tst_QDeclarativeVideoOutput::sourceRect()
{
QQmlComponent component(&m_engine);
diff --git a/tests/auto/integration/qmediaplayerbackend/BLACKLIST b/tests/auto/integration/qmediaplayerbackend/BLACKLIST
index c2833f1f7..e91f47755 100644
--- a/tests/auto/integration/qmediaplayerbackend/BLACKLIST
+++ b/tests/auto/integration/qmediaplayerbackend/BLACKLIST
@@ -5,6 +5,7 @@ windows-7
windows-7sp1
windows-10 msvc-2015
windows-10 msvc-2017
+windows-10 msvc-2019
# Media player plugin not built at the moment on this platform
opensuse-13.1 64bit
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
index af4e2c275..ec520e901 100644
--- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
+++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
@@ -78,8 +78,10 @@ private slots:
void playlistObject();
void surfaceTest_data();
void surfaceTest();
+ void multipleSurfaces();
void metadata();
void playerStateAtEOS();
+ void playFromBuffer();
private:
QMediaContent selectVideoFile(const QStringList& mediaCandidates);
@@ -1389,6 +1391,33 @@ void tst_QMediaPlayerBackend::surfaceTest()
QVERIFY2(surface.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface.m_totalFrames)));
}
+void tst_QMediaPlayerBackend::multipleSurfaces()
+{
+ if (localVideoFile.isNull())
+ QSKIP("No supported video file");
+
+ QList<QVideoFrame::PixelFormat> formats1;
+ formats1 << QVideoFrame::Format_RGB32
+ << QVideoFrame::Format_ARGB32;
+ QList<QVideoFrame::PixelFormat> formats2;
+ formats2 << QVideoFrame::Format_YUV420P
+ << QVideoFrame::Format_RGB32;
+
+ TestVideoSurface surface1(false);
+ surface1.setSupportedFormats(formats1);
+ TestVideoSurface surface2(false);
+ surface2.setSupportedFormats(formats2);
+
+ QMediaPlayer player;
+ player.setVideoOutput(QVector<QAbstractVideoSurface *>() << &surface1 << &surface2);
+ player.setMedia(localVideoFile);
+ player.play();
+ QTRY_VERIFY(player.position() >= 1000);
+ QVERIFY2(surface1.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface1.m_totalFrames)));
+ QVERIFY2(surface2.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface2.m_totalFrames)));
+ QCOMPARE(surface1.m_totalFrames, surface2.m_totalFrames);
+}
+
void tst_QMediaPlayerBackend::metadata()
{
if (localFileWithMetadata.isNull())
@@ -1444,6 +1473,25 @@ void tst_QMediaPlayerBackend::playerStateAtEOS()
QVERIFY(endOfMediaReceived);
}
+void tst_QMediaPlayerBackend::playFromBuffer()
+{
+ if (localVideoFile.isNull())
+ QSKIP("No supported video file");
+
+ TestVideoSurface surface(false);
+ QMediaPlayer player;
+ player.setVideoOutput(&surface);
+ QFile file(localVideoFile.request().url().toLocalFile());
+ if (!file.open(QIODevice::ReadOnly))
+ QSKIP("Could not open file");
+ player.setMedia(localVideoFile, &file);
+ player.play();
+ QTRY_VERIFY(player.position() >= 1000);
+ if (surface.error() == QAbstractVideoSurface::UnsupportedFormatError)
+ QSKIP("None of the pixel formats is supported by the backend");
+ QVERIFY2(surface.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface.m_totalFrames)));
+}
+
TestVideoSurface::TestVideoSurface(bool storeFrames):
m_totalFrames(0),
m_storeFrames(storeFrames)
diff --git a/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp b/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp
index 61299a964..b18dba5f7 100644
--- a/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp
+++ b/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp
@@ -58,7 +58,7 @@ private slots:
void supportedFormatsChanged();
};
-typedef QMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat> SupportedFormatMap;
+using SupportedFormatMap = QMultiMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat>;
Q_DECLARE_METATYPE(SupportedFormatMap)
@@ -86,7 +86,7 @@ public:
/* fun to generate supportedFormatsChanged signal */
QList<QVideoFrame::PixelFormat> supportedPixelFormatsChange(QList<QVideoFrame::PixelFormat> formats)
{
- supportedFormats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
+ supportedFormats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
QList<QVideoFrame::PixelFormat> supportedFormats = supportedPixelFormats();
if (supportedFormats.count() != formats.count()) {
emit supportedFormatsChanged();
@@ -189,10 +189,10 @@ void tst_QAbstractVideoSurface::isFormatSupported_data()
QAbstractVideoBuffer::GLTextureHandle)
<< false;
- formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
- formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
- formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444);
- formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32);
+ formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
+ formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
+ formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444);
+ formats.insert(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32);
QTest::newRow("supported: rgb32")
<< formats
@@ -228,8 +228,8 @@ void tst_QAbstractVideoSurface::isFormatSupported_data()
QAbstractVideoBuffer::GLTextureHandle)
<< false;
- formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12);
- formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24);
+ formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12);
+ formats.insert(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24);
QTest::newRow("supported: yv12")
<< formats
@@ -377,7 +377,7 @@ void tst_QAbstractVideoSurface::nativeResolution()
void tst_QAbstractVideoSurface::supportedFormatsChanged()
{
SupportedFormatMap formatMap;
- formatMap.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
+ formatMap.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
QtTestVideoSurface surface(formatMap);
QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
QList<QVideoFrame::PixelFormat> formats = surface.supportedPixelFormats();
diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp
index 4b6202173..643b552f9 100644
--- a/tests/auto/unit/qcamera/tst_qcamera.cpp
+++ b/tests/auto/unit/qcamera/tst_qcamera.cpp
@@ -2039,7 +2039,7 @@ void tst_QCamera::testErrorSignal()
QCamera camera;
- QSignalSpy spyError(&camera, SIGNAL(error(QCamera::Error)));
+ QSignalSpy spyError(&camera, SIGNAL(errorOccurred(QCamera::Error)));
/* Set the QCameraControl error and verify if the signal is emitted correctly in QCamera */
service.mockControl->setError(QCamera::CameraError,QString("Camera Error"));
diff --git a/tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro
index f59027bc2..6d8b3c215 100644
--- a/tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro
+++ b/tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro
@@ -1,7 +1,7 @@
CONFIG += testcase
TARGET = tst_qdeclarativeaudio
-QT += multimedia-private qml testlib
+QT += multimedia-private qml testlib qtmultimediaquicktools-private
HEADERS += \
../../../../src/imports/multimedia/qdeclarativeaudio_p.h \
diff --git a/tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
index 87c72521c..ded188d72 100644
--- a/tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
+++ b/tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
@@ -40,7 +40,9 @@
#include <qmediaplayercontrol.h>
#include <qmediaservice.h>
#include <private/qmediaserviceprovider_p.h>
+#include <private/qdeclarativevideooutput_p.h>
#include <qmetadatareadercontrol.h>
+#include <QAbstractVideoSurface>
#include <QtGui/qguiapplication.h>
#include <QtQml/qqmlengine.h>
@@ -75,6 +77,7 @@ private slots:
void loops();
void audioRole();
void customAudioRole();
+ void videoOutput();
private:
void enumerator(const QMetaObject *object, const char *name, QMetaEnum *result);
@@ -1201,6 +1204,52 @@ int tst_QDeclarativeAudio::keyToValue(const QMetaEnum &enumeration, const char *
return result;
}
+struct Surface : QAbstractVideoSurface
+{
+ Surface(QObject *parent = nullptr) : QAbstractVideoSurface(parent) { }
+ QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const override
+ {
+ return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB32;
+ }
+
+ bool present(const QVideoFrame &) override { return true; }
+};
+
+void tst_QDeclarativeAudio::videoOutput()
+{
+ QtTestMediaPlayerControl playerControl;
+ QtTestMediaServiceProvider provider(&playerControl, 0);
+
+ QDeclarativeAudio audio;
+ QSignalSpy spy(&audio, &QDeclarativeAudio::videoOutputChanged);
+
+ audio.classBegin();
+ audio.componentComplete();
+
+ QVERIFY(audio.videoOutput().isNull());
+
+ QVariant surface;
+ surface.setValue(new Surface(this));
+ audio.setVideoOutput(surface);
+ QCOMPARE(audio.videoOutput(), surface);
+ QCOMPARE(spy.count(), 1);
+
+ QQmlEngine engine;
+ QJSValue jsArray = engine.newArray(5);
+ jsArray.setProperty(0, engine.newQObject(new Surface(this)));
+ jsArray.setProperty(1, engine.newQObject(new Surface(this)));
+ QDeclarativeVideoOutput output;
+ jsArray.setProperty(2, engine.newQObject(&output));
+ jsArray.setProperty(3, 123);
+ jsArray.setProperty(4, QLatin1String("ignore this"));
+
+ QVariant surfaces;
+ surfaces.setValue(jsArray);
+ audio.setVideoOutput(surfaces);
+ QCOMPARE(audio.videoOutput(), surfaces);
+ QCOMPARE(spy.count(), 2);
+}
+
QTEST_MAIN(tst_QDeclarativeAudio)
#include "tst_qdeclarativeaudio.moc"
diff --git a/tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
index f4759bbf7..41805f49a 100644
--- a/tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
+++ b/tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
@@ -70,6 +70,7 @@ private slots:
void boundingRect();
void paint();
+ void paintSurface();
};
Q_DECLARE_METATYPE(const uchar *)
@@ -656,6 +657,48 @@ void tst_QGraphicsVideoItem::paint()
QCOMPARE(surface->isReady(), true);
}
+void tst_QGraphicsVideoItem::paintSurface()
+{
+ QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
+ QVERIFY(item->videoSurface());
+
+ QGraphicsScene graphicsScene;
+ graphicsScene.addItem(item);
+ QGraphicsView graphicsView(&graphicsScene);
+ graphicsView.show();
+ QVERIFY(item->waitForPaint(1));
+
+ QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>(
+ item->videoSurface());
+ if (!surface)
+ QSKIP("QGraphicsVideoItem is not QPainterVideoSurface based");
+
+ QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
+
+ QVERIFY(surface->start(format));
+ QCOMPARE(surface->isActive(), true);
+ QCOMPARE(surface->isReady(), true);
+
+ QVERIFY(item->waitForPaint(1));
+
+ QCOMPARE(surface->isActive(), true);
+ QCOMPARE(surface->isReady(), true);
+
+ QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32);
+
+ frame.map(QAbstractVideoBuffer::WriteOnly);
+ memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes());
+ frame.unmap();
+
+ QVERIFY(surface->present(frame));
+ QCOMPARE(surface->isActive(), true);
+ QCOMPARE(surface->isReady(), false);
+
+ QVERIFY(item->waitForPaint(1));
+
+ QCOMPARE(surface->isActive(), true);
+ QCOMPARE(surface->isReady(), true);
+}
QTEST_MAIN(tst_QGraphicsVideoItem)
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
index 66ace2045..4167b18ea 100644
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
@@ -75,10 +75,10 @@ public:
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
{
+ QMediaServiceProviderHint::Features result;
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
- return QMediaServiceProviderHint::LowLatencyPlayback;
- else
- return 0;
+ result |= QMediaServiceProviderHint::LowLatencyPlayback;
+ return result;
}
};
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp
index 92707169c..6a7725fee 100644
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp
@@ -75,10 +75,10 @@ public:
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
{
+ QMediaServiceProviderHint::Features result;
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
- return QMediaServiceProviderHint::StreamPlayback;
- else
- return 0;
+ result |= QMediaServiceProviderHint::StreamPlayback;
+ return result;
}
};
diff --git a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp b/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
index 7ba631e58..be5c85ab9 100644
--- a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
+++ b/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
@@ -35,9 +35,9 @@
#include <qvideosurfaceformat.h>
#if QT_CONFIG(opengl)
-#include <QtOpenGL/qgl.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <QtGui/qopenglfunctions.h>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+#include <QOpenGLWidget>
#endif
QT_USE_NAMESPACE
@@ -481,8 +481,7 @@ void tst_QPainterVideoSurface::present()
QCOMPARE(surface.isActive(), true);
QCOMPARE(surface.isReady(), false);
- // Not ready.
- QVERIFY(!surface.present(frameA));
+ QVERIFY(surface.present(frameA));
QCOMPARE(frameSpy.count(), 1);
surface.setReady(true);
@@ -560,20 +559,19 @@ void tst_QPainterVideoSurface::presentOpaqueFrame()
void tst_QPainterVideoSurface::shaderType()
{
QPainterVideoSurface surface;
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support OpenGLContext");
QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders);
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.glContext(), widget.context());
{
@@ -613,12 +611,14 @@ void tst_QPainterVideoSurface::shaderType()
{
QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.glContext(), widget.context());
QCOMPARE(spy.count(), 0);
}
- surface.setGLContext(0);
+ widget.doneCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders);
@@ -657,19 +657,18 @@ void tst_QPainterVideoSurface::shaderTypeStarted()
{
QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support OpenGLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");
@@ -713,7 +712,8 @@ void tst_QPainterVideoSurface::shaderTypeStarted()
QCOMPARE(surface.isActive(), true);
QCOMPARE(spy.count(), 0);
- surface.setGLContext(0);
+ widget.doneCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
QCOMPARE(surface.isActive(), false);
QCOMPARE(spy.count(), 1);
@@ -905,18 +905,17 @@ void tst_QPainterVideoSurface::shaderSupportedFormat()
QFETCH(bool, supportedPixelFormat);
QFETCH(bool, supportedFormat);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
@@ -1027,18 +1026,17 @@ void tst_QPainterVideoSurface::shaderPresent()
QFETCH(int, bytesB);
QFETCH(int, bytesPerLineB);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");
@@ -1093,8 +1091,9 @@ void tst_QPainterVideoSurface::shaderPresent()
QCOMPARE(surface.isActive(), true);
QCOMPARE(surface.isReady(), false);
- // Not ready.
- QVERIFY(!surface.present(frameA));
+ // If present() fails for any other reason the surface should immediately enter the stopped state
+ // and an error() value will be set.
+ QVERIFY(surface.present(frameA));
QCOMPARE(frameSpy.count(), 1);
surface.setReady(true);
@@ -1163,18 +1162,17 @@ void tst_QPainterVideoSurface::shaderPresentOpaqueFrame()
{
QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");
@@ -1217,18 +1215,17 @@ void tst_QPainterVideoSurface::shaderPresentGLFrame()
{
QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");
diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp
index 6be039108..943051435 100644
--- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp
+++ b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp
@@ -33,6 +33,7 @@
#include <qvideoframe.h>
#include <QtGui/QImage>
#include <QtCore/QPointer>
+#include <QtMultimedia/private/qtmultimedia-config_p.h>
// Adds an enum, and the stringized version
#define ADD_ENUM_TEST(x) \
@@ -85,6 +86,9 @@ private slots:
void isMapped();
void isReadable();
void isWritable();
+
+ void image_data();
+ void image();
};
Q_DECLARE_METATYPE(QImage::Format)
@@ -1128,6 +1132,173 @@ void tst_QVideoFrame::isWritable()
frame.unmap();
}
+void tst_QVideoFrame::image_data()
+{
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
+ QTest::addColumn<int>("bytes");
+ QTest::addColumn<int>("bytesPerLine");
+ QTest::addColumn<QImage::Format>("imageFormat");
+
+ QTest::newRow("64x64 ARGB32")
+ << QSize(64, 64)
+ << QVideoFrame::Format_ARGB32
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 ARGB32_Premultiplied")
+ << QSize(64, 64)
+ << QVideoFrame::Format_ARGB32_Premultiplied
+ << 16384
+ << 256
+ << QImage::Format_ARGB32_Premultiplied;
+
+ QTest::newRow("64x64 RGB32")
+ << QSize(64, 64)
+ << QVideoFrame::Format_RGB32
+ << 16384
+ << 256
+ << QImage::Format_RGB32;
+
+ QTest::newRow("64x64 RGB24")
+ << QSize(64, 64)
+ << QVideoFrame::Format_RGB24
+ << 16384
+ << 192
+ << QImage::Format_RGB888;
+
+ QTest::newRow("64x64 RGB565")
+ << QSize(64, 64)
+ << QVideoFrame::Format_RGB565
+ << 16384
+ << 128
+ << QImage::Format_RGB16;
+
+ QTest::newRow("64x64 RGB555")
+ << QSize(64, 64)
+ << QVideoFrame::Format_RGB555
+ << 16384
+ << 128
+ << QImage::Format_RGB555;
+
+ QTest::newRow("64x64 BGRA32")
+ << QSize(64, 64)
+ << QVideoFrame::Format_BGRA32
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 BGRA32_Premultiplied")
+ << QSize(64, 64)
+ << QVideoFrame::Format_BGRA32_Premultiplied
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 BGR32")
+ << QSize(64, 64)
+ << QVideoFrame::Format_BGR32
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 BGR24")
+ << QSize(64, 64)
+ << QVideoFrame::Format_BGR24
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 BGR565")
+ << QSize(64, 64)
+ << QVideoFrame::Format_BGR565
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 BGR555")
+ << QSize(64, 64)
+ << QVideoFrame::Format_BGR555
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+#if !QT_CONFIG(directshow)
+ QTest::newRow("64x64 AYUV444")
+ << QSize(64, 64)
+ << QVideoFrame::Format_AYUV444
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 YUV444")
+ << QSize(64, 64)
+ << QVideoFrame::Format_YUV444
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 YUV420P")
+ << QSize(64, 64)
+ << QVideoFrame::Format_YUV420P
+ << 13288
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 YV12")
+ << QSize(64, 64)
+ << QVideoFrame::Format_YV12
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 UYVY")
+ << QSize(64, 64)
+ << QVideoFrame::Format_UYVY
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 YUYV")
+ << QSize(64, 64)
+ << QVideoFrame::Format_YUYV
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 NV12")
+ << QSize(64, 64)
+ << QVideoFrame::Format_NV12
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+
+ QTest::newRow("64x64 NV21")
+ << QSize(64, 64)
+ << QVideoFrame::Format_NV21
+ << 16384
+ << 256
+ << QImage::Format_ARGB32;
+#endif
+}
+
+void tst_QVideoFrame::image()
+{
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrame::PixelFormat, pixelFormat);
+ QFETCH(int, bytes);
+ QFETCH(int, bytesPerLine);
+ QFETCH(QImage::Format, imageFormat);
+
+ QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat);
+ QImage img = frame.image();
+
+ QVERIFY(!img.isNull());
+ QCOMPARE(img.format(), imageFormat);
+ QCOMPARE(img.size(), size);
+ QCOMPARE(img.bytesPerLine(), bytesPerLine);
+}
+
QTEST_MAIN(tst_QVideoFrame)
#include "tst_qvideoframe.moc"
diff --git a/tests/auto/unit/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/qvideowidget/tst_qvideowidget.cpp
index 3baa72281..bcc4acb3a 100644
--- a/tests/auto/unit/qvideowidget/tst_qvideowidget.cpp
+++ b/tests/auto/unit/qvideowidget/tst_qvideowidget.cpp
@@ -100,6 +100,7 @@ private slots:
void saturationRendererControl();
void paintRendererControl();
+ void paintSurface();
private:
void sizeHint_data();
@@ -1609,6 +1610,34 @@ void tst_QVideoWidget::paintRendererControl()
QCOMPARE(surface->isReady(), true);
}
+void tst_QVideoWidget::paintSurface()
+{
+ QtTestVideoWidget widget;
+ widget.resize(640,480);
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ QVERIFY(widget.videoSurface());
+ auto surface = qobject_cast<QPainterVideoSurface *>(
+ widget.videoSurface());
+ QVERIFY(surface);
+
+ QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
+ QVERIFY(surface->start(format));
+ QCOMPARE(surface->isActive(), true);
+
+ QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32);
+ frame.map(QAbstractVideoBuffer::WriteOnly);
+ memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes());
+ frame.unmap();
+
+ QVERIFY(surface->present(frame));
+ QCOMPARE(surface->isReady(), false);
+ QTRY_COMPARE(surface->isReady(), true);
+ QCOMPARE(surface->isActive(), true);
+ QCOMPARE(surface->isReady(), true);
+}
+
QTEST_MAIN(tst_QVideoWidget)
#include "tst_qvideowidget.moc"