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 QFFMPEGPLAYBACKENGINEOBJECT_P_H |
4 | #define QFFMPEGPLAYBACKENGINEOBJECT_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 "playbackengine/qffmpegplaybackenginedefs_p.h" |
18 | #include "qthread.h" |
19 | #include "qatomic.h" |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QTimer; |
24 | |
25 | namespace QFFmpeg { |
26 | |
27 | class PlaybackEngineObject : public QObject |
28 | { |
29 | Q_OBJECT |
30 | public: |
31 | using TimePoint = std::chrono::steady_clock::time_point; |
32 | using TimePointOpt = std::optional<TimePoint>; |
33 | using Id = quint64; |
34 | |
35 | PlaybackEngineObject(); |
36 | |
37 | ~PlaybackEngineObject(); |
38 | |
39 | bool isPaused() const; |
40 | |
41 | bool isAtEnd() const; |
42 | |
43 | void kill(); |
44 | |
45 | void setPaused(bool isPaused); |
46 | |
47 | Id id() const; |
48 | |
49 | signals: |
50 | void atEnd(); |
51 | |
52 | void error(int code, const QString &errorString); |
53 | |
54 | protected: |
55 | QTimer &timer(); |
56 | |
57 | void scheduleNextStep(bool allowDoImmediatelly = true); |
58 | |
59 | virtual void onPauseChanged(); |
60 | |
61 | virtual bool canDoNextStep() const; |
62 | |
63 | virtual int timerInterval() const; |
64 | |
65 | void setAtEnd(bool isAtEnd); |
66 | |
67 | virtual void doNextStep() { } |
68 | |
69 | private slots: |
70 | void onTimeout(); |
71 | |
72 | private: |
73 | std::unique_ptr<QTimer> m_timer; |
74 | |
75 | QAtomicInteger<bool> m_paused = true; |
76 | QAtomicInteger<bool> m_atEnd = false; |
77 | QAtomicInteger<bool> m_deleting = false; |
78 | const Id m_id; |
79 | }; |
80 | } // namespace QFFmpeg |
81 | |
82 | QT_END_NAMESPACE |
83 | |
84 | #endif // QFFMPEGPLAYBACKENGINEOBJECT_P_H |
85 | |