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
qffmpegaudiorenderer_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 QFFMPEGAUDIORENDERER_P_H
4#define QFFMPEGAUDIORENDERER_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/qffmpegrenderer_p.h>
18
19#include "qaudiobuffer.h"
20
21QT_BEGIN_NAMESPACE
22
23class QAudioOutput;
24class QAudioBufferOutput;
25class QAudioSink;
27
28namespace QFFmpeg {
29
31
32class AudioRenderer : public Renderer
33{
35public:
38
39 void setOutput(QAudioOutput *output);
40
41 void setOutput(QAudioBufferOutput *bufferOutput);
42
43 void setPitchCompensation(bool enabled);
44
46
47protected:
56
64
71
73 {
76
77 bool isValid() const { return buffer.isValid(); }
78 qsizetype size() const { return buffer.byteCount() - offset; }
79 const char *data() const { return buffer.constData<char>() + offset; }
80 };
81
83
84 RenderingResult renderInternal(Frame frame) override;
85
86 RenderingResult pushFrameToOutput(const Frame &frame);
87
88 void pushFrameToBufferOutput(const Frame &frame);
89
91
92 TimePoint nextTimePoint() const override;
93
95
96 void freeOutput();
97
98 void updateOutputs(const Frame &frame);
99
100 void initAudioFrameConverter(const Frame &frame);
101
102 void onDeviceChanged();
103
104 void updateVolume();
105
106 void updateSynchronization(const SynchronizationStamp &stamp, const Frame &frame);
107
109
110 void onAudioSinkStateChanged(QAudio::State state);
111
112 Microseconds durationForBytes(qsizetype bytes) const;
113
114private:
115 QPointer<QAudioOutput> m_output;
116 QPointer<QAudioBufferOutput> m_bufferOutput;
117 std::unique_ptr<QAudioSink> m_sink;
118 AudioTimings m_timings;
119 BufferLoadingInfo m_bufferLoadingInfo;
120 std::unique_ptr<QFFmpegResampler> m_bufferOutputResampler;
121 QAudioFormat m_sinkFormat;
122
123 QPointer<QIODevice> m_ioDevice;
124
125 bool m_deviceChanged = false;
126 bool m_bufferOutputChanged = false;
127
128 bool m_firstFrameToSink = true;
129
130 // pitch compensation
131 bool m_pitchCompensation = false;
132 std::unique_ptr<AbstractAudioFrameConverter> m_audioFrameConverter;
133
134 struct SessionContext
135 {
136 // TODO: add other members after clarifying the best session cleanup strategy
137 BufferedDataWithOffset bufferedData;
138 bool lastFramePushDone = true;
139 bool drained = false;
140 };
141
142 SessionContext m_sessionCtx;
143};
144
145} // namespace QFFmpeg
146
147QT_END_NAMESPACE
148
149#endif // QFFMPEGAUDIORENDERER_P_H
\inmodule QtMultimedia
The QAudioFormat class stores audio stream parameter information.
constexpr bool isValid() const noexcept
Returns true if all of the parameters are valid.
RenderingResult pushFrameToOutput(const Frame &frame)
Microseconds durationForBytes(qsizetype bytes) const
RenderingResult renderInternal(Frame frame) override
void updateOutputs(const Frame &frame)
void setPitchCompensation(bool enabled)
TimePoint nextTimePoint() const override
void setOutput(QAudioBufferOutput *bufferOutput)
void initAudioFrameConverter(const Frame &frame)
void updateSynchronization(const SynchronizationStamp &stamp, const Frame &frame)
void onAudioSinkStateChanged(QAudio::State state)
void setOutput(QAudioOutput *output)
void pushFrameToBufferOutput(const Frame &frame)
Microseconds bufferLoadingTime(const SynchronizationStamp &syncStamp) const
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
Combined button and popup list for selecting options.