diff options
author | Val Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-09-11 15:00:03 +0200 |
---|---|---|
committer | Val Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-09-27 10:26:56 +0200 |
commit | 5323fcef6cfcaa14ff6a7f53c546020d523f8186 (patch) | |
tree | 2f78af5186c83707cc5a1efd3da90cac1e42caaa | |
parent | d34c71a67c9a30ab67da0b6ad11c198bfe2b242d (diff) | |
download | qtmultimedia-5323fcef6cfcaa14ff6a7f53c546020d523f8186.tar.gz |
DirectShow: Implement QMediaVideoProbeControl->flush
Need to flush when at least one frame is probed
and stop is called, EOS or QMediaPlayer is destroyed.
Fixes
BFAIL : tst_QMediaPlayerBackend::probes() '(probeHandler.isVideoFlushCalled)' returned FALSE. ()
Task-number: QTBUG-46368
Change-Id: I09ebd6608c9a1b8a0a0707d83200d75ddb435734
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
3 files changed, 23 insertions, 1 deletions
diff --git a/src/plugins/directshow/common/directshowvideoprobecontrol.cpp b/src/plugins/directshow/common/directshowvideoprobecontrol.cpp index 5ec1ff064..0e2e68864 100644 --- a/src/plugins/directshow/common/directshowvideoprobecontrol.cpp +++ b/src/plugins/directshow/common/directshowvideoprobecontrol.cpp @@ -54,4 +54,16 @@ DirectShowVideoProbeControl::~DirectShowVideoProbeControl() qCWarning(qtDirectShowPlugin, "QVideoProbe control destroyed while it's still being referenced!!!"); } +void DirectShowVideoProbeControl::probeVideoFrame(const QVideoFrame &frame) +{ + emit videoFrameProbed(frame); + m_frameProbed = true; +} + +void DirectShowVideoProbeControl::flushVideoFrame() +{ + if (m_frameProbed) + emit flush(); +} + QT_END_NAMESPACE diff --git a/src/plugins/directshow/common/directshowvideoprobecontrol.h b/src/plugins/directshow/common/directshowvideoprobecontrol.h index 458263234..57839f8d3 100644 --- a/src/plugins/directshow/common/directshowvideoprobecontrol.h +++ b/src/plugins/directshow/common/directshowvideoprobecontrol.h @@ -55,8 +55,11 @@ public: bool ref() { return m_ref.ref(); } bool deref() { return m_ref.deref(); } + void probeVideoFrame(const QVideoFrame &frame); + void flushVideoFrame(); private: QAtomicInt m_ref; + bool m_frameProbed = false; }; QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp index f5899cb6a..ed131f0bd 100644 --- a/src/plugins/directshow/player/directshowplayerservice.cpp +++ b/src/plugins/directshow/player/directshowplayerservice.cpp @@ -646,6 +646,9 @@ void DirectShowPlayerService::doFinalizeLoad(QMutexLocker *locker) void DirectShowPlayerService::releaseGraph() { + if (m_videoProbeControl) + m_videoProbeControl->flushVideoFrame(); + if (m_graph) { if (m_executingTask != 0) { // {8E1C39A1-DE53-11cf-AA63-0080C744528D} @@ -1023,6 +1026,8 @@ void DirectShowPlayerService::stop() if ((m_executingTask | m_executedTasks) & (Play | Pause | Seek)) { m_pendingTasks |= Stop; + if (m_videoProbeControl) + m_videoProbeControl->flushVideoFrame(); ::SetEvent(m_taskHandle); @@ -1455,6 +1460,8 @@ void DirectShowPlayerService::customEvent(QEvent *event) m_playerControl->updateState(QMediaPlayer::StoppedState); m_playerControl->updateStatus(QMediaPlayer::EndOfMedia); m_playerControl->updatePosition(m_position); + if (m_videoProbeControl) + m_videoProbeControl->flushVideoFrame(); } } else if (event->type() == QEvent::Type(PositionChange)) { QMutexLocker locker(&m_mutex); @@ -1563,7 +1570,7 @@ void DirectShowPlayerService::onVideoBufferAvailable(double time, const QByteArr size, format); - Q_EMIT m_videoProbeControl->videoFrameProbed(frame); + m_videoProbeControl->probeVideoFrame(frame); } QT_WARNING_POP |