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
qffmpegplaybackengineobject.cpp
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
4#include "playbackengine/qffmpegplaybackengineobject_p.h"
5
6#include "qtimer.h"
7#include "qdebug.h"
8
10
11namespace QFFmpeg {
12
14
16
18{
19 if (!thread()->isCurrentThread())
20 qWarning() << "The playback engine object is being removed in an unexpected thread";
21}
22
24{
25 return m_paused;
26}
27
28void PlaybackEngineObject::setAtEnd(bool isAtEnd)
29{
30 if (m_atEnd.testAndSetRelease(!isAtEnd, isAtEnd) && isAtEnd)
31 emit atEnd();
32}
33
35{
36 return m_atEnd;
37}
38
40{
41 return m_id;
42}
43
44void PlaybackEngineObject::setPaused(bool isPaused)
45{
46 if (m_paused.testAndSetRelease(!isPaused, isPaused))
47 QMetaObject::invokeMethod(this, &PlaybackEngineObject::onPauseChanged);
48}
49
51{
52 m_deleting.storeRelease(true);
53
54 disconnect();
55 deleteLater();
56}
57
59{
60 return !m_paused;
61}
62
64{
65 if (!m_timer) {
66 m_timer = std::make_unique<QTimer>();
67 m_timer->setTimerType(Qt::PreciseTimer);
68 m_timer->setSingleShot(true);
69 connect(m_timer.get(), &QTimer::timeout, this, &PlaybackEngineObject::onTimeout);
70 }
71
72 return *m_timer;
73}
74
75void PlaybackEngineObject::onTimeout()
76{
77 if (!m_deleting && canDoNextStep())
79}
80
81std::chrono::milliseconds PlaybackEngineObject::timerInterval() const
82{
83 using namespace std::chrono_literals;
84 return 0ms;
85}
86
91
92void PlaybackEngineObject::scheduleNextStep(bool allowDoImmediatelly)
93{
94 using std::chrono::milliseconds;
95 using namespace std::chrono_literals;
96
97 if (!m_deleting && canDoNextStep()) {
98 const milliseconds interval = timerInterval();
99 if (interval == 0ms && allowDoImmediatelly) {
100 timer().stop();
102 } else {
103 timer().start(static_cast<int>(interval.count()));
104 }
105 } else {
106 timer().stop();
107 }
108}
109} // namespace QFFmpeg
110
111QT_END_NAMESPACE
112
113#include "moc_qffmpegplaybackengineobject_p.cpp"
void scheduleNextStep(bool allowDoImmediatelly=true)
virtual std::chrono::milliseconds timerInterval() const
static QAtomicInteger< PlaybackEngineObject::Id > PersistentId
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType