From ccde3b75e4ff53e711439e82e1c5640fac225d8e Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Tue, 11 Feb 2020 17:34:32 +0100 Subject: AVF: Introduce adoption of AVAssetResourceLoaderDelegate protocol AVAssetResourceLoaderDelegate allows to load custom resources. Implemented resourceLoader:shouldWaitForLoadingOfRequestedResource to read data from QIODevice. The device should be seekable, and already should have all data available. Since there is a need to know total size of the stream. So the media player will wait for QIODevice::readyRead before loading the resource. Also it requires to have url together with the stream: QMediaPlayer->setMedia(QUrl("does_not_matter.mp3"), buffer); Since the backend uses extension to determine type of the stream. Fixes: QTBUG-69101 Change-Id: I8ab0b69f668ccd67c42a8e5d5c1ad518d3306cce Reviewed-by: Timur Pocheptsov --- .../qmediaplayerbackend/tst_qmediaplayerbackend.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index f1be070e8..a2217afc8 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -81,6 +81,7 @@ private slots: void multipleSurfaces(); void metadata(); void playerStateAtEOS(); + void playFromBuffer(); private: QMediaContent selectVideoFile(const QStringList& mediaCandidates); @@ -1476,6 +1477,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) -- cgit v1.2.3