Skip to content

Commit 36cbb92

Browse files
committed
Fix restream frames feature
1 parent 7c39972 commit 36cbb92

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

include/web_video_server/web_video_server.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class WebVideoServer : public rclcpp::Node
9898
void restream_frames(std::chrono::duration<double> max_age);
9999
void cleanup_inactive_streams();
100100

101+
rclcpp::TimerBase::SharedPtr restream_timer_;
101102
rclcpp::TimerBase::SharedPtr cleanup_timer_;
102103

103104
// Parameters

src/web_video_server.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ WebVideoServer::WebVideoServer(const rclcpp::NodeOptions & options)
139139
RCLCPP_INFO(get_logger(), "Waiting For connections on %s:%d", address_.c_str(), port_);
140140

141141
if (publish_rate_ > 0) {
142-
create_wall_timer(1s / publish_rate_, [this]() {restream_frames(1s / publish_rate_);});
142+
restream_timer_ = create_wall_timer(1s / publish_rate_,
143+
[this]() {restream_frames(1s / publish_rate_);});
143144
}
144145

145146
cleanup_timer_ = create_wall_timer(500ms, [this]() {cleanup_inactive_streams();});
@@ -156,8 +157,8 @@ void WebVideoServer::restream_frames(std::chrono::duration<double> max_age)
156157
{
157158
std::scoped_lock lock(streamers_mutex_);
158159

159-
for (auto & subscriber : streamers_) {
160-
subscriber->restream_frame(max_age);
160+
for (auto & streamer : streamers_) {
161+
streamer->restream_frame(max_age);
161162
}
162163
}
163164

0 commit comments

Comments
 (0)