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
qffmpegrenderer_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 QFFMPEGRENDERER_P_H
4#define QFFMPEGRENDERER_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
20
21#include <QtCore/qpointer.h>
22
23#include <chrono>
24
26
27namespace QFFmpeg {
28
30{
32public:
35 Renderer(const TimeController &tc, const std::chrono::microseconds &seekPosTimeOffset = {});
36
37 void syncSoft(TimePoint tp, qint64 trackPos);
38
39 qint64 seekPosition() const;
40
41 qint64 lastPosition() const;
42
43 void setPlaybackRate(float rate);
44
45 void doForceStep();
46
47 bool isStepForced() const;
48
49public slots:
50 void setInitialPosition(TimePoint tp, qint64 trackPos);
51
53
54 void render(Frame);
55
58
59 void synchronized(Id id, TimePoint tp, qint64 pos);
60
62
64
65protected:
66 bool setForceStepDone();
67
68 void onPauseChanged() override;
69
70 bool canDoNextStep() const override;
71
72 int timerInterval() const override;
73
74 virtual void onPlaybackRateChanged() { }
75
77 {
78 bool done = true;
79 std::chrono::microseconds recheckInterval = std::chrono::microseconds(0);
80 };
81
83
84 float playbackRate() const;
85
86 std::chrono::microseconds frameDelay(const Frame &frame,
87 TimePoint timePoint = Clock::now()) const;
88
89 void changeRendererTime(std::chrono::microseconds offset);
90
91 template<typename Output, typename ChangeHandler>
92 void setOutputInternal(QPointer<Output> &actual, Output *desired, ChangeHandler &&changeHandler)
93 {
94 const auto connectionType = thread() == QThread::currentThread()
97 auto doer = [desired, changeHandler, &actual]() {
98 const auto prev = std::exchange(actual, desired);
99 if (prev != desired)
100 changeHandler(prev);
101 };
102 QMetaObject::invokeMethod(this, doer, connectionType);
103 }
104
105private:
106 void doNextStep() override;
107
108private:
109 TimeController m_timeController;
110 qint64 m_lastFrameEnd = 0;
111 QAtomicInteger<qint64> m_lastPosition = 0;
112 QAtomicInteger<qint64> m_seekPos = 0;
113
114 int m_loopIndex = 0;
115 QQueue<Frame> m_frames;
116
117 QAtomicInteger<bool> m_isStepForced = false;
118 std::optional<TimePoint> m_explicitNextFrameTime;
119};
120
121} // namespace QFFmpeg
122
124
125#endif // QFFMPEGRENDERER_P_H
int timerInterval() const override
void onPauseChanged() override
void syncSoft(TimePoint tp, qint64 trackPos)
void doNextStep() override
TimeController::TimePoint TimePoint
virtual RenderingResult renderInternal(Frame frame)=0
void frameProcessed(Frame)
void setInitialPosition(TimePoint tp, qint64 trackPos)
bool canDoNextStep() const override
TimeController::Clock Clock
void setPlaybackRate(float rate)
qint64 seekPosition() const
float playbackRate() const
std::chrono::microseconds frameDelay(const Frame &frame, TimePoint timePoint=Clock::now()) const
Renderer(const TimeController &tc, const std::chrono::microseconds &seekPosTimeOffset={})
virtual void onPlaybackRateChanged()
void setOutputInternal(QPointer< Output > &actual, Output *desired, ChangeHandler &&changeHandler)
void changeRendererTime(std::chrono::microseconds offset)
void loopChanged(Id id, qint64 offset, int index)
qint64 lastPosition() const
bool isStepForced() const
std::chrono::steady_clock Clock
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1598
static QThread * currentThread()
Definition qthread.cpp:1039
Combined button and popup list for selecting options.
@ AutoConnection
@ BlockingQueuedConnection
GLuint index
[2]
GLenum GLuint GLintptr offset
GLuint GLenum * rate
const GLfloat * tc
#define Q_OBJECT
#define slots
#define signals
long long qint64
Definition qtypes.h:60
QFrame frame
[0]
std::chrono::microseconds recheckInterval
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
\threadsafe This is an overloaded member function, provided for convenience. It differs from the abov...