From 012affe3194a48d8bb10d0a100f1d1bbb24ecf7e Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Tue, 27 Aug 2019 11:15:03 +0200 Subject: DirectShow: Fix crash when there is no surface on flush() When QDeclarativeRendererBackend is being destroyed, it clears the surface and postpones releasing IMediaControl, which is done on worker thread. It also calls flush() where null surface is used. Fixes: QTBUG-77829 Change-Id: I327583c1f8fb7585dbec3c3fb7e80d0155cc4819 Reviewed-by: Timur Pocheptsov --- src/plugins/common/evr/evrcustompresenter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/common/evr/evrcustompresenter.cpp') diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index 470f670e4..0265c431b 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -1143,7 +1143,7 @@ HRESULT EVRCustomPresenter::flush() sample->Release(); m_frameStep.samples.clear(); - if (m_renderState == RenderStopped && m_surface->isActive()) { + if (m_renderState == RenderStopped && m_surface && m_surface->isActive()) { // Repaint with black. presentSample(NULL); } -- cgit v1.2.3 From 94852a47c130c3dc265d900390bf0d7b53cbab3e Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Thu, 29 Aug 2019 12:46:33 +0200 Subject: DirectShow: Add startTime and endTime to QVideoFrame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the application seeks to a new position, the Media Session restarts the presentation clock at the specified seek time. The media source might deliver samples with a slightly earlier time stamp if the seek time does not fall on a key-frame boundary. And IMFSample->GetSampleTime will return time that is related to a position when the clock has been restarted, and can be also negative. So if it needs to have times from the beginning, it would require to add seeked position to times from IMFSample. It also reverts c4de056a6aa44567cdbf2ce91a464e597ad4af8f Fixes: QTBUG-77849 Change-Id: I1a7cb7bd18aee73087a61d2ed2c3d644ad0fbd50 Reviewed-by: Christian Strømme --- src/plugins/common/evr/evrcustompresenter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/plugins/common/evr/evrcustompresenter.cpp') diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index 0265c431b..ca4b26ded 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -557,6 +557,7 @@ EVRCustomPresenter::EVRCustomPresenter(QAbstractVideoSurface *surface) , m_mediaType(0) , m_surface(0) , m_canRenderToSurface(false) + , m_positionOffset(0) { // Initial source rectangle = (0,0,1,1) m_sourceRect.top = 0; @@ -1930,6 +1931,15 @@ void EVRCustomPresenter::presentSample(IMFSample *sample) QVideoFrame frame = m_presentEngine->makeVideoFrame(sample); + // Since start/end times are related to a position when the clock is started, + // to have times from the beginning, need to adjust it by adding seeked position. + if (m_positionOffset) { + if (frame.startTime()) + frame.setStartTime(frame.startTime() + m_positionOffset); + if (frame.endTime()) + frame.setEndTime(frame.endTime() + m_positionOffset); + } + if (!m_surface->isActive() || m_surface->surfaceFormat() != m_presentEngine->videoSurfaceFormat()) { m_surface->stop(); if (!m_surface->start(m_presentEngine->videoSurfaceFormat())) @@ -1939,6 +1949,11 @@ void EVRCustomPresenter::presentSample(IMFSample *sample) m_surface->present(frame); } +void EVRCustomPresenter::positionChanged(qint64 position) +{ + m_positionOffset = position * 1000; +} + HRESULT setDesiredSampleTime(IMFSample *sample, const LONGLONG &sampleTime, const LONGLONG &duration) { if (!sample) -- cgit v1.2.3