SRS-control
0.1.4
Loading...
Searching...
No Matches
SRSEmulator.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <boost/asio.hpp>
4
#include <boost/thread/future.hpp>
5
#include <optional>
6
#include <print>
7
#include <
srs/readers/RawFrameReader.hpp
>
8
#include <
srs/utils/CommonAlias.hpp
>
9
#include <
srs/writers/UDPWriter.hpp
>
10
#include <string>
11
12
namespace
srs::test
13
{
14
class
SRSEmulator
15
{
16
public
:
17
explicit
SRSEmulator
(std::string_view filename,
int
port,
App
& app)
18
:
source_filename_
{ filename }
19
,
frame_reader_
{
source_filename_
}
20
,
udp_writer_
{ app, asio::ip::
udp
::endpoint{ asio::ip::
udp
::v4(), static_cast<asio::ip::port_type>(port) } }
21
{
22
}
23
24
void
start_send_data
()
25
{
26
spdlog::info(
"Starting to send data from emulator ..."
);
27
while
(
true
)
28
{
29
auto
read_str =
frame_reader_
.read_one_frame();
30
if
(read_str.empty())
31
{
32
return
;
33
}
34
auto
send_fut = boost::async([read_str]() {
return
std::optional<std::string_view>{ read_str }; });
35
auto
send_size =
udp_writer_
.write(std::move(send_fut)).get();
36
// spdlog::info("sent data size: {}", send_size.value());
37
}
38
}
39
40
// Getters
41
auto
get_remote_endpoint
() ->
const
auto
& {
return
udp_writer_
.get_remote_endpoint(); }
42
43
private
:
44
std::string
source_filename_
;
45
reader::RawFrame
frame_reader_
;
46
writer::UDP
udp_writer_
;
47
};
48
}
// namespace srs::test
CommonAlias.hpp
RawFrameReader.hpp
UDPWriter.hpp
srs::App
Definition
Application.hpp:47
srs::reader::RawFrame
Definition
RawFrameReader.hpp:12
srs::test::SRSEmulator::source_filename_
std::string source_filename_
Definition
SRSEmulator.hpp:44
srs::test::SRSEmulator::get_remote_endpoint
auto get_remote_endpoint() -> const auto &
Definition
SRSEmulator.hpp:41
srs::test::SRSEmulator::start_send_data
void start_send_data()
Definition
SRSEmulator.hpp:24
srs::test::SRSEmulator::SRSEmulator
SRSEmulator(std::string_view filename, int port, App &app)
Definition
SRSEmulator.hpp:17
srs::test::SRSEmulator::udp_writer_
writer::UDP udp_writer_
Definition
SRSEmulator.hpp:46
srs::test::SRSEmulator::frame_reader_
reader::RawFrame frame_reader_
Definition
SRSEmulator.hpp:45
srs::writer::UDP
Definition
UDPWriter.hpp:22
srs::test
Definition
SRSEmulator.hpp:13
srs::DataWriterOption::udp
@ udp
Definition
DataWriterOptions.hpp:16
test
backend
srs
SRSEmulator.hpp
Impressum
Datenschutzerklärung
Generated by
1.13.2