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
qffmpegvideoencoder_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 QFFMPEGVIDEOENCODER_P_H
4#define QFFMPEGVIDEOENCODER_P_H
5
7#include "qffmpeg_p.h"
8#include <qvideoframe.h>
9#include <queue>
10
12
15
16namespace QFFmpeg {
17class VideoFrameEncoder;
18
20{
21public:
23 const QVideoFrameFormat &format, std::optional<AVPixelFormat> hwFormat);
24 ~VideoEncoder() override;
25
26 bool isValid() const;
27
28 void addFrame(const QVideoFrame &frame);
29
30 void setPaused(bool b) override
31 {
33 if (b)
34 m_baseTime.storeRelease(-1);
35 }
36
37protected:
38 bool checkIfCanPushFrame() const override;
39
40private:
41 QVideoFrame takeFrame();
42 void retrievePackets();
43
44 void init() override;
45 void cleanup() override;
46 bool hasData() const override;
47 void processOne() override;
48
49private:
50 std::queue<QVideoFrame> m_videoFrameQueue;
51 const size_t m_maxQueueSize = 10; // Arbitrarily chosen to limit memory usage (332 MB @ 4K)
52
53 std::unique_ptr<VideoFrameEncoder> m_frameEncoder;
54 QAtomicInteger<qint64> m_baseTime = std::numeric_limits<qint64>::min();
55 qint64 m_lastFrameTime = 0;
56};
57
58} // namespace QFFmpeg
59
61
62#endif
void storeRelease(T newValue) noexcept
virtual void setPaused(bool paused)
void setPaused(bool b) override
bool checkIfCanPushFrame() const override
~VideoEncoder() override
void init() override
Called on this thread when thread starts.
void processOne() override
Process one work item.
void cleanup() override
Called on this thread before thread exits.
void addFrame(const QVideoFrame &frame)
bool hasData() const override
Must return true when data is available for processing.
VideoEncoder(RecordingEngine &recordingEngine, const QMediaEncoderSettings &settings, const QVideoFrameFormat &format, std::optional< AVPixelFormat > hwFormat)
The QVideoFrameFormat class specifies the stream format of a video presentation surface.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLint GLsizei GLsizei GLenum format
long long qint64
Definition qtypes.h:60
QSettings settings("MySoft", "Star Runner")
[0]
QFrame frame
[0]