ToolX 1.11.1 [e3f477f]
A GUI debug tool chain for diagnosing GVA systems
Loading...
Searching...
No Matches
stream_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//
13
14#ifndef STREAMS_STREAM_GENERATOR_H
15#define STREAMS_STREAM_GENERATOR_H
16
17#include <atomic>
18#include <memory>
19#include <thread>
20#include <mutex>
21#include <vector>
22#include <QSap>
23#include <QImage>
24#include <QPainter>
25#include <QFont>
26#include <QFontMetrics>
27
28#include "rtp/rtp.h"
29#include "frame_overlay.h"
30#include "webcam_capture.h"
31
33{
34public:
36 enum class EncoderType {
37 kvaapiH264,
38 kopenH264,
39 komxH264,
40 };
41
46 StreamGenerator(mediax::qt6::QtSapAnnouncer &announcer, EncoderType encoder);
47
53
61 void setEncoder(EncoderType encoder) { m_encoder = encoder; }
62
69 void setStreamInfo(mediax::rtp::StreamInformation &info, int testCard = 0);
70
76 bool start();
77
82 void stop();
83
88
89 bool started() const { return m_started; }
90
96 uint64_t bytesSent() const { return m_bytes_sent.load(std::memory_order_relaxed); }
97
103 const mediax::rtp::StreamInformation &streamInfo() const { return m_info; }
104
110 void setSapEnabled(bool enabled = true);
111
118 bool getSapEnabled() const;
119
125 void setTestPattern(int pattern);
126
132 void setSessionNameOverlay(bool enabled);
133
139 void setTimeOverlay(bool enabled);
140
150 static bool av1Available(EncoderType codec);
151
157 static bool vaapiAvailable();
158
159private:
165 static void GenerateStreamThread(StreamGenerator *stream);
166
173 std::shared_ptr<mediax::rtp::RtpPayloader> CreatePayloader(EncoderType m_encoder) const;
174
181 std::shared_ptr<mediax::rtp::RtpDepayloader> CreateDepayloader(EncoderType m_encoder) const;
182
184 bool m_started = false;
186 std::shared_ptr<mediax::rtp::RtpPayloader> m_stream;
188 mediax::rtp::StreamInformation m_info;
190 int m_testCard = 0;
192 std::thread m_thread;
194 bool m_running = false;
196 bool m_sapEnabled = false;
198 QString m_session_name = "";
200 mediax::qt6::QtSapAnnouncer &m_announcer;
204 std::atomic<uint64_t> m_bytes_sent{ 0 };
207};
208
209#endif // STREAMS_STREAM_GENERATOR_H
Definition stream_generator.h:33
const mediax::rtp::StreamInformation & streamInfo() const
Get the stream information.
Definition stream_generator.h:103
std::atomic< uint64_t > m_bytes_sent
Total bytes sent for monitoring.
Definition stream_generator.h:204
std::shared_ptr< mediax::rtp::RtpDepayloader > CreateDepayloader(EncoderType m_encoder) const
Create a Depayloader object.
Definition stream_generator.cpp:93
static bool vaapiAvailable()
Check whether the VAAPI hardware encoders (H.264, H.265, AV1) were built in.
Definition stream_generator.cpp:60
std::shared_ptr< mediax::rtp::RtpPayloader > CreatePayloader(EncoderType m_encoder) const
Create a Payloader object.
Definition stream_generator.cpp:70
void setSapEnabled(bool enabled=true)
Set the Sap Enabled object.
Definition stream_generator.cpp:305
bool m_running
Running bool.
Definition stream_generator.h:194
bool started() const
Status of the stream.
Definition stream_generator.h:89
std::thread m_thread
The video thread handle.
Definition stream_generator.h:192
void stop()
start the stream
Definition stream_generator.cpp:266
EncoderType
The encoder type.
Definition stream_generator.h:36
~StreamGenerator()
Destroy the Stream Generator object.
Definition stream_generator.cpp:39
bool getSapEnabled() const
Get the Sap Enabled object.
Definition stream_generator.cpp:323
void setTestPattern(int pattern)
Set the test pattern.
Definition stream_generator.cpp:328
bool m_started
Stream state.
Definition stream_generator.h:184
bool start()
stop the stream
Definition stream_generator.cpp:208
toolx::streams::FrameOverlay m_overlay
Paints the session name and date/time overlays into the frames.
Definition stream_generator.h:206
uint64_t bytesSent() const
Get the total bytes sent by this stream.
Definition stream_generator.h:96
void setEncoder(EncoderType encoder)
Set the H.264 encoder used by this stream.
Definition stream_generator.h:61
std::shared_ptr< mediax::rtp::RtpPayloader > m_stream
The video streams.
Definition stream_generator.h:186
QString m_session_name
Session name as QString.
Definition stream_generator.h:198
mediax::qt6::QtSapAnnouncer & m_announcer
The SAP/SDP announcer.
Definition stream_generator.h:200
StreamGenerator(mediax::qt6::QtSapAnnouncer &announcer, EncoderType encoder)
Construct a new Stream Generator object.
Definition stream_generator.cpp:34
EncoderType m_encoder
The encoder type.
Definition stream_generator.h:202
void setStreamInfo(mediax::rtp::StreamInformation &info, int testCard=0)
Set the Stream Info object.
Definition stream_generator.cpp:115
static bool av1Available(EncoderType codec)
Check whether AV1 can be used with the given H.264 codec selection.
Definition stream_generator.cpp:47
mediax::rtp::StreamInformation m_info
The stream information.
Definition stream_generator.h:188
void setTimeOverlay(bool enabled)
Set whether to overlay date/time on the video stream.
Definition stream_generator.cpp:338
int m_testCard
The test card to emit.
Definition stream_generator.h:190
static void GenerateStreamThread(StreamGenerator *stream)
The video generation thread.
Definition stream_generator.cpp:343
bool m_sapEnabled
Indicate if SAP announcment is required.
Definition stream_generator.h:196
void setSessionNameOverlay(bool enabled)
Set whether to overlay the session name on the video stream.
Definition stream_generator.cpp:333
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.
Webcam capture using Qt6 Multimedia. Provides a thread-safe frame buffer that can be consumed by Stre...