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
qffmpegrecordingengineutils.cpp
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
4
#
include
"recordingengine/qffmpegrecordingengineutils_p.h"
5
#
include
"recordingengine/qffmpegencoderthread_p.h"
6
#
include
"private/qplatformaudiobufferinput_p.h"
7
#
include
"private/qplatformvideoframeinput_p.h"
8
9
QT_BEGIN_NAMESPACE
10
11
namespace
QFFmpeg
{
12
13
template
<
typename
F>
14
static
void
doWithMediaFrameInput
(QObject *source, F &&f)
15
{
16
if
(
auto
videoFrameInput = qobject_cast<QPlatformVideoFrameInput *>(source))
17
f(videoFrameInput);
18
else
if
(
auto
audioBufferInput = qobject_cast<QPlatformAudioBufferInput *>(source))
19
f(audioBufferInput);
20
}
21
22
void
setEncoderInterface
(QObject *source, QMediaInputEncoderInterface *encoderInterface)
23
{
24
doWithMediaFrameInput(source, [&](
auto
source) {
25
using
Source = std::remove_pointer_t<
decltype
(source)>;
26
27
source->setEncoderInterface(encoderInterface);
28
if
(encoderInterface)
29
// Postpone emit 'encoderUpdated' as the encoding pipeline may be not
30
// completely ready at the moment. The case is calling QMediaRecorder::stop
31
// upon handling 'readyToSendFrame'
32
QMetaObject::invokeMethod(source, &Source::encoderUpdated, Qt::QueuedConnection);
33
else
34
Q_EMIT source->encoderUpdated();
35
});
36
}
37
38
void
setEncoderUpdateConnection
(QObject *source,
EncoderThread
*encoder)
39
{
40
doWithMediaFrameInput(source, [&](
auto
source) {
41
using
Source = std::remove_pointer_t<
decltype
(source)>;
42
QObject::connect(encoder, &EncoderThread::canPushFrameChanged, source,
43
&Source::encoderUpdated);
44
});
45
}
46
47
void
disconnectEncoderFromSource
(
EncoderThread
*encoder)
48
{
49
QObject *source = encoder
->
source
(
)
;
50
if
(!source)
51
return
;
52
53
// We should address the dependency AudioEncoder from QFFmpegAudioInput to
54
// set null source here.
55
// encoder->setSource(nullptr);
56
57
QObject::disconnect(source,
nullptr
, encoder,
nullptr
);
58
setEncoderInterface
(
source
,
nullptr
)
;
59
}
60
61
}
// namespace QFFmpeg
62
63
QT_END_NAMESPACE
QFFmpeg::EncoderThread
Definition
qffmpegencoderthread_p.h:33
QFFmpeg::EncoderThread::source
QObject * source() const
Definition
qffmpegencoderthread_p.h:44
QFFmpeg
Definition
qandroidcacertificates.cpp:26
QFFmpeg::doWithMediaFrameInput
static void doWithMediaFrameInput(QObject *source, F &&f)
Definition
qffmpegrecordingengineutils.cpp:14
QFFmpeg::setEncoderInterface
void setEncoderInterface(QObject *source, QMediaInputEncoderInterface *)
Definition
qffmpegrecordingengineutils.cpp:22
QFFmpeg::setEncoderUpdateConnection
void setEncoderUpdateConnection(QObject *source, EncoderThread *encoder)
Definition
qffmpegrecordingengineutils.cpp:38
QFFmpeg::disconnectEncoderFromSource
void disconnectEncoderFromSource(EncoderThread *encoder)
Definition
qffmpegrecordingengineutils.cpp:47
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
plugins
multimedia
ffmpeg
recordingengine
qffmpegrecordingengineutils.cpp
Generated on
for Qt by
1.18.0