ToolX 1.11.1 [e3f477f]
A GUI debug tool chain for diagnosing GVA systems
Loading...
Searching...
No Matches
cast_generator.h
Go to the documentation of this file.
1//
2// Copyright (c) 2026, Astute Systems PTY LTD
3//
4// This file is part of the VivoeX project developed by Astute Systems.
5//
6// License. See the LICENSE file in the project root for full license details.
7//
12
13#ifndef STREAMS_CAST_GENERATOR_H
14#define STREAMS_CAST_GENERATOR_H
15
16#include <atomic>
17#include <cstdint>
18#include <memory>
19#include <string>
20#include <thread>
21
22#include <QObject>
23#include <QString>
24#include <QVariantMap>
25
26#include "h264/openh264/rtp_h264_openh264_payloader.h"
27#include "qt6/QtCastSender.h"
29
30namespace toolx::streams {
31
34{
36 QVariantMap device;
38 std::string name = "ToolX";
40 uint32_t width = 1280;
42 uint32_t height = 720;
44 uint32_t framerate = 25;
46 int pattern = 0;
47};
48
57class CastGenerator : public QObject
58{
59 Q_OBJECT
60
61public:
67 explicit CastGenerator(QObject *parent = nullptr);
68
72 ~CastGenerator() final;
73
74 CastGenerator(const CastGenerator &) = delete;
75 CastGenerator &operator=(const CastGenerator &) = delete;
76 CastGenerator(CastGenerator &&) = delete;
77 CastGenerator &operator=(CastGenerator &&) = delete;
78
88 bool start(const CastStreamConfig &config, QString &error);
89
93 void stop();
94
100 bool isRunning() const;
101
107 mediax::qt6::QtCastSender::State state() const;
108
114 QString lastError() const;
115
121 void setPattern(int pattern);
122
128 void setSessionNameOverlay(bool enabled);
129
135 void setTimeOverlay(bool enabled);
136
137private:
139 void generateThread();
140
144 std::shared_ptr<mediax::rtp::h264::openh264::RtpH264OpenH264Payloader> m_encoder;
146 mediax::qt6::QtCastSender *m_sender = nullptr;
148 std::thread m_thread;
150 std::atomic<bool> m_running{ false };
152 std::atomic<int> m_pattern{ 0 };
157};
158
159} // namespace toolx::streams
160
161#endif // STREAMS_CAST_GENERATOR_H
~CastGenerator() final
Stop casting.
Definition cast_generator.cpp:29
std::shared_ptr< mediax::rtp::h264::openh264::RtpH264OpenH264Payloader > m_encoder
The encoder, outlives the sender's use of it.
Definition cast_generator.h:144
CastStreamConfig m_config
The cast configuration.
Definition cast_generator.h:142
CastGenerator(QObject *parent=nullptr)
Construct a new cast generator.
Definition cast_generator.cpp:27
void stop()
Stop generating frames and stop the application on the device.
Definition cast_generator.cpp:113
std::thread m_thread
The frame generation thread.
Definition cast_generator.h:148
bool isRunning() const
Check if the generator is running.
Definition cast_generator.cpp:137
mediax::qt6::QtCastSender::State state() const
The state of the connection to the device.
Definition cast_generator.cpp:142
QString lastError() const
The description of the last error reported by the sender.
Definition cast_generator.cpp:150
void setTimeOverlay(bool enabled)
Burn the date and time into the video while running.
Definition cast_generator.cpp:165
void setPattern(int pattern)
Change the test card while running.
Definition cast_generator.cpp:155
std::atomic< int > m_pattern
The current test pattern.
Definition cast_generator.h:152
void setSessionNameOverlay(bool enabled)
Burn the session name into the video while running.
Definition cast_generator.cpp:160
mediax::qt6::QtCastSender * m_sender
The sender, owned by this object.
Definition cast_generator.h:146
void generateThread()
The frame generation thread.
Definition cast_generator.cpp:170
std::atomic< bool > m_running
True while the thread should run.
Definition cast_generator.h:150
FrameOverlay m_overlay
Paints the session name and date/time overlays into the frames.
Definition cast_generator.h:154
QString m_last_error
The last error reported by the sender.
Definition cast_generator.h:156
bool start(const CastStreamConfig &config, QString &error)
Open the encoder, start connecting to the device and start generating frames.
Definition cast_generator.cpp:34
Burns the session name (bottom centre) and the date/time (top right) into frames.
Definition frame_overlay.h:41
Paints the session name and date/time overlays into raw video frames.
The configuration of one cast.
Definition cast_generator.h:34
uint32_t height
Image height in pixels.
Definition cast_generator.h:42
std::string name
Title shown on the device, also the session name overlay.
Definition cast_generator.h:38
QVariantMap device
The device, as made by mediax::qt6::QtCastDiscovery.
Definition cast_generator.h:36
uint32_t width
Image width in pixels.
Definition cast_generator.h:40
uint32_t framerate
Frames per second.
Definition cast_generator.h:44
int pattern
Test pattern index (see testPatternNames()).
Definition cast_generator.h:46