srs-control
0.2.2
Toggle main menu visibility
Loading...
Searching...
No Matches
DataSocket.cpp
Go to the documentation of this file.
1
#include "
DataSocket.hpp
"
2
#include "
SpecialSocketBase.hpp
"
3
#include "
srs/Application.hpp
"
4
#include "
srs/connections/ConnectionTypeDef.hpp
"
5
#include "
srs/utils/CommonAlias.hpp
"
6
#include "
srs/utils/ExitLogger.hpp
"
7
#include "
srs/workflow/AnalysisHandle.hpp
"
8
#include <asio/awaitable.hpp>
9
#include <asio/detached.hpp>
10
#include <asio/impl/co_spawn.hpp>
11
#include <cstddef>
12
#include <fmt/format.h>
13
#include <memory>
14
15
namespace
srs::connection
16
{
17
DataSocket::DataSocket
(
int
port_number,
18
io_context_type
& io_context,
19
std::size_t buffer_size,
20
workflow::AnalysisHandle
&
workflow
)
21
:
SpecialSocket
(port_number, io_context)
22
,
buffer_size_
{ buffer_size }
23
,
read_msg_buffer_
{
buffer_size_
}
24
,
io_context_
{ &io_context }
25
,
workflow_handler_
{ &
workflow
}
26
,
token_
{
workflow
.get_queue_producer_token() }
27
{
28
}
29
30
// WARN: is it really needed?
31
void
DataSocket::register_send_action_imp
(asio::awaitable<void>
/* action */
,
32
const
std::shared_ptr<ConnectionType>&
/*connection*/
)
33
{
34
// asio::co_spawn(*io_context_, std::move(action), asio::detached);
35
}
36
37
void
DataSocket::response_handler
(
const
UDPEndpoint
&
/*endpoint*/
, std::size_t read_size)
38
{
39
read_msg_buffer_
.resize(read_size);
40
workflow_handler_
->read_data_once(
read_msg_buffer_
,
token_
);
41
read_msg_buffer_
.resize(
buffer_size_
);
42
}
43
44
void
DataSocket::cancel
()
45
{
46
const
auto
_ =
ExitLogger
{};
47
auto
& timer =
get_cancel_timer
();
48
timer.cancel();
49
}
50
51
void
DataSocket::before_socket_close
()
52
{
53
if
(
auto
* report =
get_report
(); report !=
nullptr
)
54
{
55
auto
stat =
AppReport::FrameReadingStat
{};
56
stat.
n_frames
=
get_n_records
();
57
stat.total_bytes_read =
get_n_bytes
();
58
stat.total_time_ns =
get_total_time_ns
();
59
report->register_frame_reading_result(fmt::format(
"{}"
,
get_socket
().local_endpoint()), stat);
60
}
61
}
62
}
// namespace srs::connection
AnalysisHandle.hpp
Application.hpp
CommonAlias.hpp
ConnectionTypeDef.hpp
DataSocket.hpp
ExitLogger.hpp
SpecialSocketBase.hpp
srs::ExitLogger
Definition
ExitLogger.hpp:12
srs::connection::DataSocket::token_
BufferQueue::Token token_
Definition
DataSocket.hpp:39
srs::connection::DataSocket::read_msg_buffer_
LargeBuffer read_msg_buffer_
Definition
DataSocket.hpp:36
srs::connection::DataSocket::DataSocket
DataSocket(int port_number, io_context_type &io_context, std::size_t buffer_size, workflow::AnalysisHandle &workflow)
Definition
DataSocket.cpp:17
srs::connection::DataSocket::SpecialSocket
friend SpecialSocket
Definition
DataSocket.hpp:34
srs::connection::DataSocket::io_context_
gsl::not_null< io_context_type * > io_context_
Definition
DataSocket.hpp:37
srs::connection::DataSocket::before_socket_close
void before_socket_close()
Definition
DataSocket.cpp:51
srs::connection::DataSocket::register_send_action_imp
void register_send_action_imp(asio::awaitable< void > action, const std::shared_ptr< ConnectionType > &connection)
Definition
DataSocket.cpp:31
srs::connection::DataSocket::response_handler
void response_handler(const UDPEndpoint &endpoint, std::size_t read_size)
Definition
DataSocket.cpp:37
srs::connection::DataSocket::workflow_handler_
gsl::not_null< workflow::AnalysisHandle * > workflow_handler_
Definition
DataSocket.hpp:38
srs::connection::DataSocket::cancel
void cancel()
Cancel reading the data from the UDP socket.
Definition
DataSocket.cpp:44
srs::connection::DataSocket::buffer_size_
std::size_t buffer_size_
Definition
DataSocket.hpp:35
srs::connection::SpecialSocket::get_cancel_timer
auto get_cancel_timer() -> auto &
Definition
SpecialSocketBase.hpp:164
srs::connection::SpecialSocket::get_total_time_ns
auto get_total_time_ns() const -> std::uint64_t
Getter for the total listening time in nano seconds.
Definition
SpecialSocketBase.hpp:152
srs::connection::SpecialSocket::get_n_records
auto get_n_records() const -> std::size_t
Getter for the number of frames read.
Definition
SpecialSocketBase.hpp:138
srs::connection::SpecialSocket::get_n_bytes
auto get_n_bytes() const -> std::size_t
Getter for the number of bytes read.
Definition
SpecialSocketBase.hpp:145
srs::connection::SpecialSocket::get_report
auto get_report() -> auto *
Definition
SpecialSocketBase.hpp:154
srs::connection::SpecialSocket::get_socket
auto get_socket() const -> udp::socket &
Getter for the asio udp socket object.
Definition
SpecialSocketBase.hpp:117
srs::workflow::AnalysisHandle
Definition
AnalysisHandle.hpp:30
srs::connection
Definition
Application.hpp:34
srs::connection::UDPEndpoint
asio::ip::basic_endpoint< asio::ip::udp > UDPEndpoint
Definition
ConnectionTypeDef.hpp:17
srs::workflow
Definition
Application.hpp:29
srs::io_context_type
asio::thread_pool io_context_type
Definition
CommonAlias.hpp:12
srs::AppReport::FrameReadingStat
Definition
AppReport.hpp:34
srs::AppReport::FrameReadingStat::n_frames
std::size_t n_frames
Definition
AppReport.hpp:35
backend
srs
connections
DataSocket.cpp
Impressum
Datenschutzerklärung
Generated by
1.17.0