1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
diff --git a/src/rtsp.cpp b/src/rtsp.cpp
index 0180fbee..da20d134 100644
--- a/src/rtsp.cpp
+++ b/src/rtsp.cpp
@@ -90,8 +90,8 @@ namespace rtsp_stream {
class socket_t: public std::enable_shared_from_this<socket_t> {
public:
- socket_t(boost::asio::io_service &ios, std::function<void(tcp::socket &sock, launch_session_t &, msg_t &&)> &&handle_data_fn):
- handle_data_fn { std::move(handle_data_fn) }, sock { ios } {}
+ socket_t(boost::asio::io_context &io_context, std::function<void(tcp::socket &sock, launch_session_t &, msg_t &&)> &&handle_data_fn):
+ handle_data_fn { std::move(handle_data_fn) }, sock { io_context } {}
/**
* @brief Queues an asynchronous read to begin the next message.
@@ -440,7 +440,7 @@ namespace rtsp_stream {
return -1;
}
- next_socket = std::make_shared<socket_t>(ios, [this](tcp::socket &sock, launch_session_t &session, msg_t &&msg) {
+ next_socket = std::make_shared<socket_t>(io_context, [this](tcp::socket &sock, launch_session_t &session, msg_t &&msg) {
handle_msg(sock, session, std::move(msg));
});
@@ -454,7 +454,7 @@ namespace rtsp_stream {
template <class T, class X>
void
iterate(std::chrono::duration<T, X> timeout) {
- ios.run_one_for(timeout);
+ io_context.run_one_for(timeout);
}
void
@@ -499,7 +499,7 @@ namespace rtsp_stream {
}
// Queue another asynchronous accept for the next incoming connection
- next_socket = std::make_shared<socket_t>(ios, [this](tcp::socket &sock, launch_session_t &session, msg_t &&msg) {
+ next_socket = std::make_shared<socket_t>(io_context, [this](tcp::socket &sock, launch_session_t &session, msg_t &&msg) {
handle_msg(sock, session, std::move(msg));
});
acceptor.async_accept(next_socket->sock, [this](const auto &ec) {
@@ -591,8 +591,8 @@ namespace rtsp_stream {
}
}
- if (all && !ios.stopped()) {
- ios.stop();
+ if (all && !io_context.stopped()) {
+ io_context.stop();
}
}
@@ -627,8 +627,8 @@ namespace rtsp_stream {
std::chrono::steady_clock::time_point raised_timeout;
int _slot_count;
- boost::asio::io_service ios;
- tcp::acceptor acceptor { ios };
+ boost::asio::io_context io_context;
+ tcp::acceptor acceptor { io_context };
std::shared_ptr<socket_t> next_socket;
};
diff --git a/src/stream.cpp b/src/stream.cpp
index df5b3d96..0b304e23 100644
--- a/src/stream.cpp
+++ b/src/stream.cpp
@@ -340,10 +340,10 @@ namespace stream {
std::thread audio_thread;
std::thread control_thread;
- asio::io_service io;
+ asio::io_context io_context;
- udp::socket video_sock { io };
- udp::socket audio_sock { io };
+ udp::socket video_sock { io_context };
+ udp::socket audio_sock { io_context };
control_server_t control_server;
};
@@ -1159,7 +1159,7 @@ namespace stream {
auto &message_queue_queue = ctx.message_queue_queue;
auto broadcast_shutdown_event = mail::man->event<bool>(mail::broadcast_shutdown);
- auto &io = ctx.io;
+ auto &io = ctx.io_context;
udp::endpoint peer;
@@ -1664,7 +1664,7 @@ namespace stream {
audio_packets->stop();
ctx.message_queue_queue->stop();
- ctx.io.stop();
+ ctx.io_context.stop();
ctx.video_sock.close();
ctx.audio_sock.close();
|