blob: 4ab4ef1ca56ff760ca134db54ebaea661c3ead26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MEDIAGENERATOR_H
#define MEDIAGENERATOR_H
#include "settings.h"
#include <QAudioFormat>
#include <QSize>
#include <chrono>
#include <vector>
#include <optional>
QT_BEGIN_NAMESPACE
class QVideoFrame;
class QAudioBuffer;
QT_END_NAMESPACE
class AudioGenerator
{
public:
using Settings = AudioGeneratorSettings;
AudioGenerator(const Settings &settings);
QAudioBuffer generate();
std::chrono::microseconds interval() const { return m_settings.bufferDuration; }
private:
Settings m_settings;
QAudioFormat m_format;
uint32_t m_index = 0;
uint32_t m_sampleIndex = 0;
};
using AudioGeneratorSettingsOpt = std::optional<AudioGenerator::Settings>;
class VideoGenerator
{
public:
using Settings = VideoGeneratorSettings;
VideoGenerator(const Settings &settings);
QVideoFrame generate();
std::chrono::microseconds interval() const
{
return std::chrono::microseconds(std::chrono::seconds(1)) / m_settings.frameRate;
}
private:
Settings m_settings;
uint32_t m_index = 0;
};
#endif // MEDIAGENERATOR_H
|