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
16
17namespace QFFmpeg {
18
20{
21public:
22 AudioEncoder(RecordingEngine &recordingEngine, const QAudioFormat &sourceFormat,
24
25 void addBuffer(const QAudioBuffer &buffer);
26
27protected:
28 bool checkIfCanPushFrame() const override;
29
30private:
31 void open();
32
33 QAudioBuffer takeBuffer();
34 void retrievePackets();
35
36 void init() override;
37 void cleanup() override;
38 bool hasData() const override;
39 void processOne() override;
40
41private:
42 std::queue<QAudioBuffer> m_audioBufferQueue;
43
44 // Arbitrarily chosen to limit audio queue duration
45 const std::chrono::microseconds m_maxQueueDuration = std::chrono::seconds(5);
46
47 std::chrono::microseconds m_queueDuration{ 0 };
48
49 AVStream *m_stream = nullptr;
50 AVCodecContextUPtr m_codecContext;
51 QAudioFormat m_format;
52
53 SwrContextUPtr m_resampler;
54 qint64 m_samplesWritten = 0;
55 const AVCodec *m_avCodec = nullptr;
56 QMediaEncoderSettings m_settings;
57};
58
59
60} // namespace QFFmpeg
61
63
64#endif
\inmodule QtMultimedia
The QAudioFormat class stores audio stream parameter information.
AudioEncoder(RecordingEngine &recordingEngine, const QAudioFormat &sourceFormat, const QMediaEncoderSettings &settings)
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.
void processOne() override
Process one work item.
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
long long qint64
Definition qtypes.h:60
QSettings settings("MySoft", "Star Runner")
[0]