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>
10#include <string>
11
12namespace srs::test
13{
15 {
16 public:
17 explicit SRSEmulator(std::string_view filename, int port, App& app)
18 : source_filename_{ filename }
20 , udp_writer_{ app, asio::ip::udp::endpoint{ asio::ip::udp::v4(), static_cast<asio::ip::port_type>(port) } }
21 {
22 }
23
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_;
47 };
48} // namespace srs::test
std::string source_filename_
auto get_remote_endpoint() -> const auto &
SRSEmulator(std::string_view filename, int port, App &app)
reader::RawFrame frame_reader_