summaryrefslogtreecommitdiffstats
path: root/src/plugins/common/evr/evrd3dpresentengine.cpp
diff options
context:
space:
mode:
authorVal Doroshchuk <valentyn.doroshchuk@qt.io>2019-08-29 12:46:33 +0200
committerVal Doroshchuk <valentyn.doroshchuk@qt.io>2019-08-29 13:59:40 +0200
commit94852a47c130c3dc265d900390bf0d7b53cbab3e (patch)
tree8fcaa692de23e3f14dbb6bd21664c9cb750f7e7f /src/plugins/common/evr/evrd3dpresentengine.cpp
parent012affe3194a48d8bb10d0a100f1d1bbb24ecf7e (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/evrd3dpresentengine.cpp')
-rw-r--r--src/plugins/common/evr/evrd3dpresentengine.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/common/evr/evrd3dpresentengine.cpp b/src/plugins/common/evr/evrd3dpresentengine.cpp
index 4ce5a99d7..d8e2da6d3 100644
--- a/src/plugins/common/evr/evrd3dpresentengine.cpp
+++ b/src/plugins/common/evr/evrd3dpresentengine.cpp
@@ -593,6 +593,17 @@ QVideoFrame D3DPresentEngine::makeVideoFrame(IMFSample *sample)
m_surfaceFormat.frameSize(),
m_surfaceFormat.pixelFormat());
+ // WMF uses 100-nanosecond units, Qt uses microseconds
+ LONGLONG startTime = 0;
+ auto hr = sample->GetSampleTime(&startTime);
+ if (SUCCEEDED(hr)) {
+ frame.setStartTime(startTime * 0.1);
+
+ LONGLONG duration = -1;
+ if (SUCCEEDED(sample->GetSampleDuration(&duration)))
+ frame.setEndTime((startTime + duration) * 0.1);
+ }
+
return frame;
}