Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qffmpegtimecontroller_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QFFMPEGTIMECONTROLLER_P_H
4#define QFFMPEGTIMECONTROLLER_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include "qglobal.h"
18
19#include <chrono>
20#include <optional>
21
23
24namespace QFFmpeg {
25
27{
28 using TrackTime = std::chrono::microseconds;
29
30public:
31 using Clock = std::chrono::steady_clock;
32 using TimePoint = Clock::time_point;
33 using PlaybackRate = float;
34
36
38
40
41 void sync(qint64 trackPos = 0);
42
43 void sync(const TimePoint &tp, qint64 pos);
44
45 void syncSoft(const TimePoint &tp, qint64 pos,
46 const Clock::duration &fixingTime = std::chrono::seconds(4));
47
48 qint64 currentPosition(const Clock::duration &offset = Clock::duration{ 0 }) const;
49
50 void setPaused(bool paused);
51
52 qint64 positionFromTime(TimePoint tp, bool ignorePause = false) const;
53
54 TimePoint timeFromPosition(qint64 pos, bool ignorePause = false) const;
55
56private:
57 struct SoftSyncData
58 {
59 TimePoint srcTimePoint;
60 TrackTime srcPosition;
61 TimePoint dstTimePoint;
62 TrackTime srcPosOffest;
63 TrackTime dstPosition;
64 PlaybackRate internalRate = 1;
65 };
66
67 SoftSyncData makeSoftSyncData(const TimePoint &srcTp, const TrackTime &srcPos,
68 const TimePoint &dstTp) const;
69
70 TrackTime positionFromTimeInternal(const TimePoint &tp) const;
71
72 TimePoint timeFromPositionInternal(const TrackTime &pos) const;
73
74 void scrollTimeTillNow();
75
76 template<typename T>
77 static Clock::duration toClockTime(const T &t);
78
79 template<typename T>
80 static TrackTime toTrackTime(const T &t);
81
82private:
83 bool m_paused = true;
84 PlaybackRate m_playbackRate = 1;
85 TrackTime m_position;
86 TimePoint m_timePoint = {};
87 std::optional<SoftSyncData> m_softSyncData;
88};
89
90} // namespace QFFmpeg
91
93
94#endif // QFFMPEGTIMECONTROLLER_P_H
PlaybackRate playbackRate() const
void sync(qint64 trackPos=0)
qint64 positionFromTime(TimePoint tp, bool ignorePause=false) const
std::chrono::steady_clock Clock
TimePoint timeFromPosition(qint64 pos, bool ignorePause=false) const
void setPlaybackRate(PlaybackRate playbackRate)
qint64 currentPosition(const Clock::duration &offset=Clock::duration{ 0 }) const
void syncSoft(const TimePoint &tp, qint64 pos, const Clock::duration &fixingTime=std::chrono::seconds(4))
Combined button and popup list for selecting options.
GLenum GLuint GLintptr offset
GLdouble GLdouble t
Definition qopenglext.h:243
long long qint64
Definition qtypes.h:60