Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
24
#
include
<
atomic
>
25
26
QT_BEGIN_NAMESPACE
27
28
namespace
QFFmpeg
{
29
30
class
RecordingEngine
;
31
32
class
EncoderThread
:
public
ConsumerThread
,
public
QMediaInputEncoderInterface
33
{
34
Q_OBJECT
35
public
:
36
EncoderThread
(
RecordingEngine
&
recordingEngine
);
37
38
void
setPaused
(
bool
paused);
39
40
void
setAutoStop
(
bool
autoStop);
41
42
void
setSource
(QObject *source) { m_source = source; }
43
44
QObject
*
source
()
const
{
return
m_source; }
45
46
bool
canPushFrame
()
const
override
{
return
m_canPushFrame.load(std::memory_order_relaxed); }
47
48
void
setEndOfSourceStream
();
49
50
bool
isEndOfSourceStream
()
const
{
return
m_endOfSourceStream.load(std::memory_order_acquire); }
51
52
bool
isInitialized
()
const
{
return
m_initialized
; }
53
54
QFuture
<
bool
>
resolvedFuture
()
const
{
return
m_resolvedPromise.future(); }
55
56
protected
:
57
bool
init
()
override
;
58
59
void
updateCanPushFrame
();
60
61
virtual
bool
checkIfCanPushFrame
()
const
= 0;
62
63
void
resetEndOfSourceStream
() { m_endOfSourceStream.store(
false
, std::memory_order_release); }
64
65
auto
lockLoopData
()
66
{
67
return
QScopeGuard([
this
, locker = ConsumerThread::lockLoopData()]()
mutable
{
68
const
bool
autoStopActivated = m_endOfSourceStream && m_autoStop;
69
const
bool
canPush = !autoStopActivated && !
m_paused
&&
checkIfCanPushFrame
(
)
;
70
locker.unlock();
71
if
(m_canPushFrame.exchange(canPush, std::memory_order_relaxed) != canPush)
72
Q_EMIT canPushFrameChanged();
73
});
74
}
75
76
void
markResolved
(
bool
succeeded);
77
78
virtual
void
handlePausedChanged
(
bool
/*paused*/
) { }
79
80
Q_SIGNALS
:
81
void
canPushFrameChanged
();
82
void
endOfSourceStream
();
83
84
protected
:
85
bool
m_paused
=
false
;
86
std
::atomic_bool
m_endOfSourceStream
=
false
;
87
bool
m_autoStop
=
false
;
88
bool
m_initialized
=
false
;
89
bool
m_encodingStarted
=
false
;
90
std
::atomic_bool
m_canPushFrame
=
false
;
91
RecordingEngine
&
m_recordingEngine
;
92
QPointer
<
QObject
>
m_source
;
93
QPromise
<
bool
>
m_resolvedPromise
;
94
};
95
96
}
// namespace QFFmpeg
97
98
QT_END_NAMESPACE
99
100
#
endif
QFFmpeg::EncoderThread
Definition
qffmpegencoderthread_p.h:33
QFFmpeg::EncoderThread::setEndOfSourceStream
void setEndOfSourceStream()
Definition
qffmpegencoderthread.cpp:30
QFFmpeg::EncoderThread::lockLoopData
auto lockLoopData()
Definition
qffmpegencoderthread_p.h:65
QFFmpeg::EncoderThread::m_initialized
bool m_initialized
Definition
qffmpegencoderthread_p.h:88
QFFmpeg::EncoderThread::markResolved
void markResolved(bool succeeded)
Definition
qffmpegencoderthread.cpp:56
QFFmpeg::EncoderThread::m_encodingStarted
bool m_encodingStarted
Definition
qffmpegencoderthread_p.h:89
QFFmpeg::EncoderThread::m_resolvedPromise
QPromise< bool > m_resolvedPromise
Definition
qffmpegencoderthread_p.h:93
QFFmpeg::EncoderThread::endOfSourceStream
void endOfSourceStream()
QFFmpeg::EncoderThread::source
QObject * source() const
Definition
qffmpegencoderthread_p.h:44
QFFmpeg::EncoderThread::m_paused
bool m_paused
Definition
qffmpegencoderthread_p.h:85
QFFmpeg::EncoderThread::setPaused
void setPaused(bool paused)
Definition
qffmpegencoderthread.cpp:17
QFFmpeg::EncoderThread::isInitialized
bool isInitialized() const
Definition
qffmpegencoderthread_p.h:52
QFFmpeg::EncoderThread::handlePausedChanged
virtual void handlePausedChanged(bool)
Definition
qffmpegencoderthread_p.h:78
QFFmpeg::EncoderThread::m_endOfSourceStream
std::atomic_bool m_endOfSourceStream
Definition
qffmpegencoderthread_p.h:86
QFFmpeg::EncoderThread::setSource
void setSource(QObject *source)
Definition
qffmpegencoderthread_p.h:42
QFFmpeg::EncoderThread::setAutoStop
void setAutoStop(bool autoStop)
Definition
qffmpegencoderthread.cpp:24
QFFmpeg::EncoderThread::resolvedFuture
QFuture< bool > resolvedFuture() const
Definition
qffmpegencoderthread_p.h:54
QFFmpeg::EncoderThread::m_source
QPointer< QObject > m_source
Definition
qffmpegencoderthread_p.h:92
QFFmpeg::EncoderThread::init
bool init() override
Called on this thread when thread starts.
Definition
qffmpegencoderthread.cpp:40
QFFmpeg::EncoderThread::canPushFrame
bool canPushFrame() const override
Definition
qffmpegencoderthread_p.h:46
QFFmpeg::EncoderThread::m_recordingEngine
RecordingEngine & m_recordingEngine
Definition
qffmpegencoderthread_p.h:91
QFFmpeg::EncoderThread::isEndOfSourceStream
bool isEndOfSourceStream() const
Definition
qffmpegencoderthread_p.h:50
QFFmpeg::EncoderThread::m_autoStop
bool m_autoStop
Definition
qffmpegencoderthread_p.h:87
QFFmpeg::EncoderThread::updateCanPushFrame
void updateCanPushFrame()
QFFmpeg::EncoderThread::checkIfCanPushFrame
virtual bool checkIfCanPushFrame() const =0
QFFmpeg::EncoderThread::resetEndOfSourceStream
void resetEndOfSourceStream()
Definition
qffmpegencoderthread_p.h:63
QFFmpeg::EncoderThread::m_canPushFrame
std::atomic_bool m_canPushFrame
Definition
qffmpegencoderthread_p.h:90
QFFmpeg::RecordingEngine
Definition
qffmpegrecordingengine_p.h:46
QFFmpeg
Definition
qandroidcacertificates.cpp:26
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtmultimedia
src
plugins
multimedia
ffmpeg
recordingengine
qffmpegencoderthread_p.h
Generated on
for Qt by
1.18.0