Qt 6.x
The Qt SDK
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 <chrono>
22
24
25namespace QFFmpeg {
26
28{
30public:
33 Renderer(const TimeController &tc, const std::chrono::microseconds &seekPosTimeOffset = {});
34
35 void syncSoft(TimePoint tp, qint64 trackPos);
36
37 qint64 seekPosition() const;
38
39 qint64 lastPosition() const;
40
41 void setPlaybackRate(float rate);
42
43 void doForceStep();
44
45 bool isStepForced() const;
46
47public slots:
49
50 void render(Frame);
51
54
55 void synchronized(Id id, TimePoint tp, qint64 pos);
56
58
60
61protected:
62 bool setForceStepDone();
63
64 void onPauseChanged() override;
65
66 bool canDoNextStep() const override;
67
68 virtual void onPlaybackRateChanged() { }
69
71 {
72 bool done = true;
73 std::chrono::microseconds recheckInterval = std::chrono::microseconds(0);
74 };
75
77
78 float playbackRate() const;
79
80 std::chrono::microseconds frameDelay(const Frame &frame) const;
81
82 void changeRendererTime(std::chrono::microseconds offset);
83
84 template<typename Output, typename ChangeHandler>
85 void setOutputInternal(QPointer<Output> &actual, Output *desired, ChangeHandler &&changeHandler)
86 {
87 const auto connectionType = thread() == QThread::currentThread()
90 auto doer = [desired, changeHandler, &actual]() {
91 const auto prev = std::exchange(actual, desired);
92 if (prev != desired)
93 changeHandler(prev);
94 };
95 QMetaObject::invokeMethod(this, doer, connectionType);
96 }
97
98private:
99 void doNextStep() override;
100
101 int timerInterval() const override;
102
103private:
104 TimeController m_timeController;
105 std::atomic<qint64> m_lastPosition = 0;
106 std::atomic<qint64> m_seekPos = 0;
107 int m_loopIndex = 0;
108 QQueue<Frame> m_frames;
109
110 std::atomic_bool m_isStepForced = false;
111 std::optional<TimePoint> m_explicitNextFrameTime;
112};
113
114} // namespace QFFmpeg
115
117
118#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)
bool canDoNextStep() const override
TimeController::Clock Clock
void setPlaybackRate(float rate)
qint64 seekPosition() const
float playbackRate() const
std::chrono::microseconds frameDelay(const Frame &frame) const
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:1561
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore
Definition qqueue.h:14
static QThread * currentThread()
Definition qthread.cpp:966
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:55
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...