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#include "qpointer.h"
19#include "qsemaphore.h"
20
21#include <QtMultimedia/private/qmediainputencoderinterface_p.h>
22
24
25namespace QFFmpeg {
26
27class RecordingEngine;
28
30{
32public:
34
35 void setPaused(bool paused);
36
37 void setAutoStop(bool autoStop);
38
39 void setSource(QObject *source) { m_source = source; }
40
41 QObject *source() const { return m_source; }
42
43 bool canPushFrame() const override { return m_canPushFrame.load(std::memory_order_relaxed); }
44
46
48
49 void startEncoding(bool noError);
50
51 bool isInitialized() const { return m_initialized; }
52
53protected:
54 bool init() override;
55
57
58 virtual bool checkIfCanPushFrame() const = 0;
59
61
63 {
64 return QScopeGuard([this, locker = ConsumerThread::lockLoopData()]() mutable {
65 const bool autoStopActivated = m_endOfSourceStream && m_autoStop;
66 const bool canPush = !autoStopActivated && !m_paused && checkIfCanPushFrame();
67 locker.unlock();
68 if (m_canPushFrame.exchange(canPush, std::memory_order_relaxed) != canPush)
69 emit canPushFrameChanged();
70 });
71 }
72
77
78protected:
79 bool m_paused = false;
80 bool m_endOfSourceStream = false;
81 bool m_autoStop = false;
82 bool m_initialized = false;
83 bool m_encodingStarted = false;
88};
89
90} // namespace QFFmpeg
91
92QT_END_NAMESPACE
93
94#endif
void setSource(QObject *source)
void setAutoStop(bool autoStop)
void startEncoding(bool noError)
bool init() override
Called on this thread when thread starts.
bool canPushFrame() const override
RecordingEngine & m_recordingEngine
virtual bool checkIfCanPushFrame() const =0
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType