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
qffmpegthread_p.h
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
#
ifndef
QFFMPEGTHREAD_P_H
4
#
define
QFFMPEGTHREAD_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
<
QtMultimedia
/
private
/
qtmultimediaglobal_p
.
h
>
18
19
#
include
<
qmutex
.
h
>
20
#
include
<
qwaitcondition
.
h
>
21
#
include
<
qthread
.
h
>
22
23
QT_BEGIN_NAMESPACE
24
25
class
QAudioSink;
26
27
namespace
QFFmpeg
28
{
29
30
/*!
31
FFmpeg thread that is used to implement a consumer pattern.
32
33
This thread processes work items until no more data is available.
34
When no more data is available, it sleeps until it is notified about
35
more available data.
36
*/
37
class
ConsumerThread
:
public
QThread
38
{
39
public
:
40
struct
Deleter
41
{
42
void
operator
()(
ConsumerThread
*thread)
const
{ thread
->
stopAndDelete
(
)
; }
43
};
44
45
protected
:
46
/*!
47
Stops the thread and deletes this object
48
*/
49
void
stopAndDelete
();
50
51
/*!
52
Called on this thread when thread starts
53
*/
54
virtual
bool
init
() = 0;
55
56
/*!
57
Called on this thread before thread exits
58
*/
59
virtual
void
cleanup
() = 0;
60
61
/*!
62
Process one work item. Called repeatedly until hasData() returns
63
false, in which case the thread sleeps until the next dataReady()
64
notification.
65
66
Note: processOne() should never block.
67
*/
68
virtual
void
processOne
() = 0;
69
70
/*!
71
Wake thread from sleep and process data until
72
hasData() returns false. The method is supposed to be invoked
73
right after the scope of QMutexLocker that lockLoopData returns.
74
*/
75
void
dataReady
();
76
77
/*!
78
Must return true when data is available for processing
79
*/
80
virtual
bool
hasData
()
const
= 0;
81
82
/*!
83
Locks the loop data mutex. It must be used to protect loop data
84
like a queue of video frames.
85
*/
86
QMutexLocker
<QMutex>
lockLoopData
()
const
;
87
88
private
:
89
void
run
()
final
;
90
91
mutable
QMutex m_loopDataMutex;
92
QWaitCondition m_condition;
93
bool
m_exit =
false
;
94
};
95
96
template
<
typename
T>
97
using
ConsumerThreadUPtr
=
std
::unique_ptr<T,
ConsumerThread
::
Deleter
>;
98
}
// namespace QFFmpeg
99
100
QT_END_NAMESPACE
101
102
#
endif
QFFmpeg::ConsumerThread
FFmpeg thread that is used to implement a consumer pattern.
Definition
qffmpegthread_p.h:38
QFFmpeg::ConsumerThread::init
virtual bool init()=0
Called on this thread when thread starts.
QFFmpeg::ConsumerThread::hasData
virtual bool hasData() const =0
Must return true when data is available for processing.
QFFmpeg::ConsumerThread::stopAndDelete
void stopAndDelete()
Stops the thread and deletes this object.
Definition
qffmpegthread.cpp:11
QFFmpeg::ConsumerThread::lockLoopData
QMutexLocker< QMutex > lockLoopData() const
Locks the loop data mutex.
Definition
qffmpegthread.cpp:49
QFFmpeg::ConsumerThread::dataReady
void dataReady()
Wake thread from sleep and process data until hasData() returns false.
Definition
qffmpegthread.cpp:22
QFFmpeg::ConsumerThread::cleanup
virtual void cleanup()=0
Called on this thread before thread exits.
QFFmpeg::ConsumerThread::processOne
virtual void processOne()=0
Process one work item.
QFFmpeg::ConsumerThread::run
void run() final
Definition
qffmpegthread.cpp:27
QMutexLocker
\inmodule QtCore
Definition
qmutex.h:347
QFFmpeg
Definition
qandroidcacertificates.cpp:26
QFFmpeg::ConsumerThreadUPtr
std::unique_ptr< T, ConsumerThread::Deleter > ConsumerThreadUPtr
Definition
qffmpegthread_p.h:97
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QFFmpeg::ConsumerThread::Deleter
Definition
qffmpegthread_p.h:41
QFFmpeg::ConsumerThread::Deleter::operator()
void operator()(ConsumerThread *thread) const
Definition
qffmpegthread_p.h:42
qtmultimedia
src
plugins
multimedia
ffmpeg
qffmpegthread_p.h
Generated on
for Qt by
1.18.0