diff options
author | Val Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-08-29 12:46:33 +0200 |
---|---|---|
committer | Val Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-08-29 13:59:40 +0200 |
commit | 94852a47c130c3dc265d900390bf0d7b53cbab3e (patch) | |
tree | 8fcaa692de23e3f14dbb6bd21664c9cb750f7e7f /src/plugins/common/evr/evrcustompresenter.cpp | |
parent | 012affe3194a48d8bb10d0a100f1d1bbb24ecf7e (diff) |
DirectShow: Add startTime and endTime to QVideoFrame
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 <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/common/evr/evrcustompresenter.cpp')
-rw-r--r-- | src/plugins/common/evr/evrcustompresenter.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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) |