Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qffmpegaudioencoder_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 QFFMPEGAUDIOENCODER_P_H
4#define QFFMPEGAUDIOENCODER_P_H
5
6#include "qffmpeg_p.h"
8#include "private/qplatformmediarecorder_p.h"
9#include <qaudiobuffer.h>
10#include <queue>
11#include <chrono>
12
14
17
18namespace QFFmpeg {
19
21{
22public:
25
26 void open();
27 void addBuffer(const QAudioBuffer &buffer);
28
29 QFFmpegAudioInput *audioInput() const { return m_input; }
30
31protected:
32 bool checkIfCanPushFrame() const override;
33
34private:
35 QAudioBuffer takeBuffer();
36 void retrievePackets();
37
38 void init() override;
39 void cleanup() override;
40 bool hasData() const override;
41 void processOne() override;
42
43private:
44 std::queue<QAudioBuffer> m_audioBufferQueue;
45
46 // Arbitrarily chosen to limit audio queue duration
47 const std::chrono::microseconds m_maxQueueDuration = std::chrono::seconds(5);
48
49 std::chrono::microseconds m_queueDuration{ 0 };
50
51 AVStream *m_stream = nullptr;
52 AVCodecContextUPtr m_codecContext;
53 QFFmpegAudioInput *m_input = nullptr;
54 QAudioFormat m_format;
55
56 SwrContextUPtr m_resampler;
57 qint64 m_samplesWritten = 0;
58 const AVCodec *m_avCodec = nullptr;
59 QMediaEncoderSettings m_settings;
60};
61
62
63} // namespace QFFmpeg
64
66
67#endif
\inmodule QtMultimedia
The QAudioFormat class stores audio stream parameter information.
void addBuffer(const QAudioBuffer &buffer)
void cleanup() override
Called on this thread before thread exits.
bool hasData() const override
Must return true when data is available for processing.
QFFmpegAudioInput * audioInput() const
void processOne() override
Process one work item.
AudioEncoder(RecordingEngine &recordingEngine, QFFmpegAudioInput *input, const QMediaEncoderSettings &settings)
bool checkIfCanPushFrame() const override
void init() override
Called on this thread when thread starts.
std::unique_ptr< AVCodecContext, AVDeleter< decltype(&avcodec_free_context), &avcodec_free_context > > AVCodecContextUPtr
Definition qffmpeg_p.h:144
std::unique_ptr< SwrContext, AVDeleter< decltype(&swr_free), &swr_free > > SwrContextUPtr
Definition qffmpeg_p.h:155
Combined button and popup list for selecting options.
GLenum GLuint buffer
GLenum GLenum GLenum input
long long qint64
Definition qtypes.h:60
QSettings settings("MySoft", "Star Runner")
[0]