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
82 RenderingResult renderInternal(Frame frame) override;
83
84 RenderingResult pushFrameToOutput(const Frame &frame);
85
86 void pushFrameToBufferOutput(const Frame &frame);
87
89
90 std::chrono::milliseconds timerInterval() const override;
91
93
94 void freeOutput();
95
96 void updateOutputs(const Frame &frame);
97
98 void initAudioFrameConverter(const Frame &frame);
99
100 void onDeviceChanged();
101
102 void updateVolume();
103
104 void updateSynchronization(const SynchronizationStamp &stamp, const Frame &frame);
105
107
108 void onAudioSinkStateChanged(QAudio::State state);
109
110 Microseconds durationForBytes(qsizetype bytes) const;
111
112private:
113 QPointer<QAudioOutput> m_output;
114 QPointer<QAudioBufferOutput> m_bufferOutput;
115 std::unique_ptr<QAudioSink> m_sink;
116 AudioTimings m_timings;
117 BufferLoadingInfo m_bufferLoadingInfo;
118 std::unique_ptr<QFFmpegResampler> m_bufferOutputResampler;
119 QAudioFormat m_sinkFormat;
120
121 BufferedDataWithOffset m_bufferedData;
122 QPointer<QIODevice> m_ioDevice;
123
124 bool m_lastFramePushDone = true;
125
126 bool m_deviceChanged = false;
127 bool m_bufferOutputChanged = false;
128 bool m_drained = false;
129 bool m_firstFrameToSink = true;
130
131 // pitch compensation
132 bool m_pitchCompensation = false;
133 std::unique_ptr<AbstractAudioFrameConverter> m_audioFrameConverter;
134};
135
136} // namespace QFFmpeg
137
138QT_END_NAMESPACE
139
140#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)
std::chrono::milliseconds timerInterval() 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