Generates test pattern frames, encodes them and sends them with a mediax::srt::SrtTransmitter.
More...
#include <srt_generator.h>
|
|
| SrtGenerator ()=default |
| | Construct a new SRT generator.
|
|
| ~SrtGenerator () |
| | Stop the stream.
|
|
| SrtGenerator (const SrtGenerator &)=delete |
|
SrtGenerator & | operator= (const SrtGenerator &)=delete |
|
| SrtGenerator (SrtGenerator &&)=delete |
|
SrtGenerator & | operator= (SrtGenerator &&)=delete |
| bool | start (const SrtTransmitConfig &config, std::string &error) |
| | Open the encoder and the SRT link and start generating frames.
|
|
void | stop () |
| | Stop generating frames and close the link.
|
| bool | isRunning () const |
| | Check if the generator is running.
|
| ::mediax::srt::SrtState | linkState () const |
| | The state of the SRT connection.
|
| std::string | lastError () const |
| | The description of the last error reported by the link.
|
| uint64_t | bytesSent () const |
| | Get the number of transport stream bytes handed to SRT.
|
| void | setPattern (int pattern) |
| | Change the test pattern while running.
|
| void | setSessionNameOverlay (bool enabled) |
| | Burn the session name into the video while running.
|
| void | setTimeOverlay (bool enabled) |
| | Burn the date and time into the video while running.
|
|
|
void | generateThread () |
| | The frame generation thread.
|
|
std::shared_ptr< mediax::rtp::RtpPayloader > | createEncoder (SrtCodec codec) const |
| | Create the encoder for a codec.
|
|
|
SrtTransmitConfig | m_config |
| | The stream configuration.
|
|
std::shared_ptr< mediax::rtp::RtpPayloader > | m_encoder |
| | The encoder, outlives the transmitter's use of it.
|
|
std::unique_ptr<::mediax::srt::SrtTransmitter > | m_transmitter |
| | The SRT sender.
|
|
std::thread | m_thread |
| | The frame generation thread.
|
|
std::atomic< bool > | m_running { false } |
| | True while the thread should run.
|
|
std::atomic< int > | m_pattern { 0 } |
| | The current test pattern.
|
|
FrameOverlay | m_overlay |
| | Paints the session name and date/time overlays into the frames.
|
|
std::mutex | m_mutex |
| | Guards m_last_error, which is written from the transmitter's worker thread.
|
|
std::string | m_last_error |
| | The last error reported by the link.
|
Generates test pattern frames, encodes them and sends them with a mediax::srt::SrtTransmitter.
The connection is made, and re-made if it drops, in the background by the transmitter. Frames are generated at the configured rate regardless and dropped until a peer is connected.
◆ bytesSent()
| uint64_t toolx::streams::SrtGenerator::bytesSent |
( |
| ) |
const |
Get the number of transport stream bytes handed to SRT.
- Returns
- uint64_t bytes sent
◆ codecAvailable()
| bool toolx::streams::SrtGenerator::codecAvailable |
( |
SrtCodec | codec | ) |
|
|
static |
Check if a codec can be encoded on this machine.
- Parameters
-
- Returns
- true if an encoder is available (H.264 (VAAPI) and H.265 need VA-API)
◆ isRunning()
| bool toolx::streams::SrtGenerator::isRunning |
( |
| ) |
const |
Check if the generator is running.
- Returns
- true between a successful start() and stop()
◆ lastError()
| std::string toolx::streams::SrtGenerator::lastError |
( |
| ) |
const |
The description of the last error reported by the link.
- Returns
- std::string the error, empty if there was none
◆ linkState()
| mediax::srt::SrtState toolx::streams::SrtGenerator::linkState |
( |
| ) |
const |
The state of the SRT connection.
- Returns
- mediax::srt::SrtState the connection state
◆ setPattern()
| void toolx::streams::SrtGenerator::setPattern |
( |
int | pattern | ) |
|
Change the test pattern while running.
- Parameters
-
◆ setSessionNameOverlay()
| void toolx::streams::SrtGenerator::setSessionNameOverlay |
( |
bool | enabled | ) |
|
Burn the session name into the video while running.
- Parameters
-
| enabled | true to paint the session name at the bottom centre of the frame |
◆ setTimeOverlay()
| void toolx::streams::SrtGenerator::setTimeOverlay |
( |
bool | enabled | ) |
|
Burn the date and time into the video while running.
- Parameters
-
| enabled | true to paint the date and time at the top right of the frame |
◆ start()
| bool toolx::streams::SrtGenerator::start |
( |
const SrtTransmitConfig & | config, |
|
|
std::string & | error ) |
Open the encoder and the SRT link and start generating frames.
Returns once the link is set up. The peer connects in the background, see linkState().
- Parameters
-
| config | the stream configuration |
| error | set to the reason when false is returned |
- Returns
- true if the stream was started
The documentation for this class was generated from the following files: