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
qffmpegencoderthread_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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 QFFMPEGENCODERTHREAD_P_H
4#define QFFMPEGENCODERTHREAD_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/qffmpegthread_p.h>
18
19#include <QtCore/qfuture.h>
20#include <QtCore/qpointer.h>
21#include <QtCore/qpromise.h>
22#include <QtMultimedia/private/qmediainputencoderinterface_p.h>
23
24QT_BEGIN_NAMESPACE
25
26namespace QFFmpeg {
27
28class RecordingEngine;
29
31{
33public:
35
36 void setPaused(bool paused);
37
38 void setAutoStop(bool autoStop);
39
40 void setSource(QObject *source) { m_source = source; }
41
42 QObject *source() const { return m_source; }
43
44 bool canPushFrame() const override { return m_canPushFrame.load(std::memory_order_relaxed); }
45
47
49
50 bool isInitialized() const { return m_initialized; }
51
52 QFuture<bool> resolvedFuture() const { return m_resolvedPromise.future(); }
53
54protected:
55 bool init() override;
56
58
59 virtual bool checkIfCanPushFrame() const = 0;
60
62
64 {
65 return QScopeGuard([this, locker = ConsumerThread::lockLoopData()]() mutable {
66 const bool autoStopActivated = m_endOfSourceStream && m_autoStop;
67 const bool canPush = !autoStopActivated && !m_paused && checkIfCanPushFrame();
68 locker.unlock();
69 if (m_canPushFrame.exchange(canPush, std::memory_order_relaxed) != canPush)
70 emit canPushFrameChanged();
71 });
72 }
73
74 void markResolved(bool succeeded);
75
79
80protected:
81 bool m_paused = false;
82 bool m_endOfSourceStream = false;
83 bool m_autoStop = false;
84 bool m_initialized = false;
85 bool m_encodingStarted = false;
90};
91
92} // namespace QFFmpeg
93
94QT_END_NAMESPACE
95
96#endif
void markResolved(bool succeeded)
void setSource(QObject *source)
void setAutoStop(bool autoStop)
QFuture< bool > resolvedFuture() const
bool init() override
Called on this thread when thread starts.
bool canPushFrame() const override
RecordingEngine & m_recordingEngine
virtual bool checkIfCanPushFrame() const =0
QT_MANGLE_NAMESPACE(QMacScreenCaptureStreamDelegate) QMacScreenCaptureStreamDelegate
Combined button and popup list for selecting options.