Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
17#include <QtFFmpegMediaPluginImpl/private/qffmpegplaybackengineobject_p.h>
18#include <QtFFmpegMediaPluginImpl/private/qffmpegtimecontroller_p.h>
19#include <QtFFmpegMediaPluginImpl/private/qffmpegframe_p.h>
20
21#include <QtCore/qpointer.h>
22#include <QtCore/qqueue.h>
23
24#include <chrono>
25
26QT_BEGIN_NAMESPACE
27
28namespace QFFmpeg {
29
31{
33public:
35
36 Renderer(const TimeController &tc);
37
38 void syncSoft(TimePoint tp, TrackPosition trackPos);
39
41
43
44 void setPlaybackRate(float rate);
45
46 void doForceStep();
47
48 bool isStepForced() const;
49
50 void start(const TimeController &tc);
51
52public slots:
53
55
56 void render(Frame);
57
60
61 void synchronized(Id id, TimePoint tp, TrackPosition pos);
62
64
65 void loopChanged(Id id, TrackPosition offset, int index);
66
67protected:
68 bool setForceStepDone();
69
71
72 bool canDoNextStep() const override;
73
74 std::chrono::milliseconds timerInterval() const override;
75
76 virtual void onPlaybackRateChanged() { }
77
79 {
80 bool done = true;
81 std::chrono::microseconds recheckInterval = std::chrono::microseconds(0);
82 };
83
84 virtual RenderingResult renderInternal(Frame frame) = 0;
85
86 float playbackRate() const;
87
88 std::chrono::microseconds frameDelay(const Frame &frame,
89 TimePoint timePoint = SteadyClock::now()) const;
90
91 void changeRendererTime(std::chrono::microseconds offset);
92
93 template<typename Output, typename ChangeHandler>
94 void setOutputInternal(QPointer<Output> &actual, Output *desired, ChangeHandler &&changeHandler)
95 {
96 const auto connectionType =
97 thread()->isCurrentThread() ? Qt::AutoConnection : Qt::BlockingQueuedConnection;
98 auto doer = [desired, changeHandler, &actual]() {
99 const auto prev = std::exchange(actual, desired);
100 if (prev != desired)
101 changeHandler(prev);
102 };
103 QMetaObject::invokeMethod(this, doer, connectionType);
104 }
105
106private:
107 void doNextStep() override;
108
109private:
110 TimeController m_timeController;
111 TrackPosition m_lastFrameEnd = TrackPosition(0);
112 QAtomicInteger<qint64> m_lastPosition = 0;
113 QAtomicInteger<qint64> m_seekPos = 0;
114
115 int m_loopIndex = 0;
116 QQueue<Frame> m_frames;
117
118 QAtomicInteger<bool> m_isStepForced = false;
119 bool m_started = false;
120 std::optional<TimePoint> m_explicitNextFrameTime;
121};
122
123} // namespace QFFmpeg
124
125QT_END_NAMESPACE
126
127#endif // QFFMPEGRENDERER_P_H
void syncSoft(TimePoint tp, TrackPosition trackPos)
void onPauseChanged() override
std::chrono::microseconds frameDelay(const Frame &frame, TimePoint timePoint=SteadyClock::now()) const
void doNextStep() override
virtual RenderingResult renderInternal(Frame frame)=0
bool canDoNextStep() const override
void start(const TimeController &tc)
void setPlaybackRate(float rate)
float playbackRate() const
void loopChanged(Id id, TrackPosition offset, int index)
Renderer(const TimeController &tc)
void synchronized(Id id, TimePoint tp, TrackPosition pos)
TrackPosition lastPosition() const
virtual void onPlaybackRateChanged()
void setOutputInternal(QPointer< Output > &actual, Output *desired, ChangeHandler &&changeHandler)
std::chrono::milliseconds timerInterval() const override
void changeRendererTime(std::chrono::microseconds offset)
bool isStepForced() const
TrackPosition seekPosition() const
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
std::chrono::microseconds recheckInterval