From cb8f5067a2fdf73f4f5b71ab3c7bcc65dc13c387 Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Mon, 28 Oct 2019 12:23:15 +0100 Subject: Introduce rendering to multiple surfaces QAbstractVideoSurface is used to retrieve and render video frames in particular pixel format. I.e. a backend takes one video surface which asks to provide video frames in one of the supported formats returned from QAbstractVideoSurface::supportedPixelFormats(). So currently there is one source of the video frames and only one video output possible. Introducing QMediaPlayer::setVideoOutput(const QVector &) This func takes a list of surfaces, that support at least one shared pixel format, and presents video frames to all of them at the same time. Several surfaces, which do not have any shared pixel formats, will fail to work. Task-number: QTBUG-32939 Change-Id: Ifbdaf692755353fbd5bf3ad74baba1820e3d0237 Reviewed-by: Volker Hilsheimer --- .../tst_qmediaplayerbackend.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto/integration') diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index 9cd3b7fa9..f1be070e8 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -78,6 +78,7 @@ private slots: void playlistObject(); void surfaceTest_data(); void surfaceTest(); + void multipleSurfaces(); void metadata(); void playerStateAtEOS(); @@ -1393,6 +1394,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 formats1; + formats1 << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32; + QList 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() << &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()) -- cgit v1.2.3