From 140ff5392a23078490145869357f1b603b736b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Sowa?= Date: Thu, 3 Oct 2024 19:17:26 +0200 Subject: [PATCH] Reformat the code with uncrustify (#158) * Reformat using ament_uncrustify * Add ament_cmake_uncrustify test * Fix ament_uncrustify errors on humble --- include/web_video_server/h264_streamer.hpp | 15 +- include/web_video_server/image_streamer.hpp | 29 ++- include/web_video_server/jpeg_streamers.hpp | 26 +- include/web_video_server/libav_streamer.hpp | 41 +-- include/web_video_server/multipart_stream.hpp | 28 ++- include/web_video_server/png_streamers.hpp | 26 +- .../ros_compressed_streamer.hpp | 19 +- include/web_video_server/vp8_streamer.hpp | 16 +- include/web_video_server/vp9_streamer.hpp | 14 +- include/web_video_server/web_video_server.hpp | 36 ++- package.xml | 2 +- src/h264_streamer.cpp | 18 +- src/image_streamer.cpp | 99 +++----- src/jpeg_streamers.cpp | 53 ++-- src/libav_streamer.cpp | 218 ++++++++-------- src/multipart_stream.cpp | 76 +++--- src/png_streamers.cpp | 53 ++-- src/ros_compressed_streamer.cpp | 70 +++--- src/utils.cpp | 17 +- src/vp8_streamer.cpp | 21 +- src/vp9_streamer.cpp | 18 +- src/web_video_server.cpp | 235 +++++++++--------- 22 files changed, 598 insertions(+), 532 deletions(-) diff --git a/include/web_video_server/h264_streamer.hpp b/include/web_video_server/h264_streamer.hpp index 50ac4e8..b5661be 100644 --- a/include/web_video_server/h264_streamer.hpp +++ b/include/web_video_server/h264_streamer.hpp @@ -12,9 +12,12 @@ namespace web_video_server class H264Streamer : public LibavStreamer { public: - H264Streamer(const async_web_server_cpp::HttpRequest& request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + H264Streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); ~H264Streamer(); + protected: virtual void initializeEncoder(); std::string preset_; @@ -24,12 +27,12 @@ class H264StreamerType : public LibavStreamerType { public: H264StreamerType(); - virtual boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest& request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + virtual boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); }; } #endif - diff --git a/include/web_video_server/image_streamer.hpp b/include/web_video_server/image_streamer.hpp index 21a76e8..81c6029 100644 --- a/include/web_video_server/image_streamer.hpp +++ b/include/web_video_server/image_streamer.hpp @@ -15,9 +15,10 @@ namespace web_video_server class ImageStreamer { public: - ImageStreamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + ImageStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); virtual void start() = 0; virtual ~ImageStreamer(); @@ -26,7 +27,6 @@ class ImageStreamer { return inactive_; } - ; /** * Restreams the last received image frame if older than max_age. @@ -37,7 +37,7 @@ class ImageStreamer { return topic_; } - ; + protected: async_web_server_cpp::HttpConnectionPtr connection_; async_web_server_cpp::HttpRequest request_; @@ -51,14 +51,16 @@ class ImageStreamer class ImageTransportImageStreamer : public ImageStreamer { public: - ImageTransportImageStreamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + ImageTransportImageStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); virtual ~ImageTransportImageStreamer(); virtual void start(); protected: - virtual void sendImage(const cv::Mat &, const rclcpp::Time &time) = 0; + virtual void sendImage(const cv::Mat &, const rclcpp::Time & time) = 0; virtual void restreamFrame(double max_age); virtual void initialize(const cv::Mat &); @@ -77,17 +79,18 @@ class ImageTransportImageStreamer : public ImageStreamer image_transport::ImageTransport it_; bool initialized_; - void imageCallback(const sensor_msgs::msg::Image::ConstSharedPtr &msg); + void imageCallback(const sensor_msgs::msg::Image::ConstSharedPtr & msg); }; class ImageStreamerType { public: - virtual boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node) = 0; + virtual boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node) = 0; - virtual std::string create_viewer(const async_web_server_cpp::HttpRequest &request) = 0; + virtual std::string create_viewer(const async_web_server_cpp::HttpRequest & request) = 0; }; } diff --git a/include/web_video_server/jpeg_streamers.hpp b/include/web_video_server/jpeg_streamers.hpp index 416aa2d..ef1b025 100644 --- a/include/web_video_server/jpeg_streamers.hpp +++ b/include/web_video_server/jpeg_streamers.hpp @@ -13,11 +13,14 @@ namespace web_video_server class MjpegStreamer : public ImageTransportImageStreamer { public: - MjpegStreamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + MjpegStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); ~MjpegStreamer(); + protected: - virtual void sendImage(const cv::Mat &, const rclcpp::Time &time); + virtual void sendImage(const cv::Mat &, const rclcpp::Time & time); private: MultipartStream stream_; @@ -27,20 +30,23 @@ class MjpegStreamer : public ImageTransportImageStreamer class MjpegStreamerType : public ImageStreamerType { public: - boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); - std::string create_viewer(const async_web_server_cpp::HttpRequest &request); + boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); + std::string create_viewer(const async_web_server_cpp::HttpRequest & request); }; class JpegSnapshotStreamer : public ImageTransportImageStreamer { public: - JpegSnapshotStreamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node); + JpegSnapshotStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node); ~JpegSnapshotStreamer(); + protected: - virtual void sendImage(const cv::Mat &, const rclcpp::Time &time); + virtual void sendImage(const cv::Mat &, const rclcpp::Time & time); private: int quality_; diff --git a/include/web_video_server/libav_streamer.hpp b/include/web_video_server/libav_streamer.hpp index c856a7a..ca62ea3 100644 --- a/include/web_video_server/libav_streamer.hpp +++ b/include/web_video_server/libav_streamer.hpp @@ -24,26 +24,28 @@ namespace web_video_server class LibavStreamer : public ImageTransportImageStreamer { public: - LibavStreamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node, const std::string &format_name, const std::string &codec_name, - const std::string &content_type); + LibavStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node, const std::string & format_name, const std::string & codec_name, + const std::string & content_type); ~LibavStreamer(); protected: virtual void initializeEncoder(); - virtual void sendImage(const cv::Mat&, const rclcpp::Time& time); - virtual void initialize(const cv::Mat&); - AVFormatContext* format_context_; - const AVCodec* codec_; - AVCodecContext* codec_context_; - AVStream* video_stream_; + virtual void sendImage(const cv::Mat &, const rclcpp::Time & time); + virtual void initialize(const cv::Mat &); + AVFormatContext * format_context_; + const AVCodec * codec_; + AVCodecContext * codec_context_; + AVStream * video_stream_; - AVDictionary* opt_; // container format options + AVDictionary * opt_; // container format options private: - AVFrame* frame_; - struct SwsContext* sws_context_; + AVFrame * frame_; + struct SwsContext * sws_context_; rclcpp::Time first_image_timestamp_; boost::mutex encode_mutex_; @@ -55,19 +57,22 @@ class LibavStreamer : public ImageTransportImageStreamer int qmax_; int gop_; - uint8_t* io_buffer_; // custom IO buffer + uint8_t * io_buffer_; // custom IO buffer }; class LibavStreamerType : public ImageStreamerType { public: - LibavStreamerType(const std::string &format_name, const std::string &codec_name, const std::string &content_type); + LibavStreamerType( + const std::string & format_name, const std::string & codec_name, + const std::string & content_type); - boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); - std::string create_viewer(const async_web_server_cpp::HttpRequest &request); + std::string create_viewer(const async_web_server_cpp::HttpRequest & request); private: const std::string format_name_; diff --git a/include/web_video_server/multipart_stream.hpp b/include/web_video_server/multipart_stream.hpp index d6ea359..80489b2 100644 --- a/include/web_video_server/multipart_stream.hpp +++ b/include/web_video_server/multipart_stream.hpp @@ -9,24 +9,30 @@ namespace web_video_server { -struct PendingFooter { +struct PendingFooter +{ rclcpp::Time timestamp; std::weak_ptr contents; }; -class MultipartStream { +class MultipartStream +{ public: - MultipartStream(std::function get_now, - async_web_server_cpp::HttpConnectionPtr& connection, - const std::string& boundry="boundarydonotcross", - std::size_t max_queue_size=1); + MultipartStream( + std::function get_now, + async_web_server_cpp::HttpConnectionPtr & connection, + const std::string & boundry = "boundarydonotcross", + std::size_t max_queue_size = 1); void sendInitialHeader(); - void sendPartHeader(const rclcpp::Time &time, const std::string& type, size_t payload_size); - void sendPartFooter(const rclcpp::Time &time); - void sendPartAndClear(const rclcpp::Time &time, const std::string& type, std::vector &data); - void sendPart(const rclcpp::Time &time, const std::string& type, const boost::asio::const_buffer &buffer, - async_web_server_cpp::HttpConnection::ResourcePtr resource); + void sendPartHeader(const rclcpp::Time & time, const std::string & type, size_t payload_size); + void sendPartFooter(const rclcpp::Time & time); + void sendPartAndClear( + const rclcpp::Time & time, const std::string & type, + std::vector & data); + void sendPart( + const rclcpp::Time & time, const std::string & type, const boost::asio::const_buffer & buffer, + async_web_server_cpp::HttpConnection::ResourcePtr resource); private: bool isBusy(); diff --git a/include/web_video_server/png_streamers.hpp b/include/web_video_server/png_streamers.hpp index d3fdb8f..20cd569 100644 --- a/include/web_video_server/png_streamers.hpp +++ b/include/web_video_server/png_streamers.hpp @@ -13,11 +13,14 @@ namespace web_video_server class PngStreamer : public ImageTransportImageStreamer { public: - PngStreamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + PngStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); ~PngStreamer(); + protected: - virtual void sendImage(const cv::Mat &, const rclcpp::Time &time); + virtual void sendImage(const cv::Mat &, const rclcpp::Time & time); private: MultipartStream stream_; @@ -27,20 +30,23 @@ class PngStreamer : public ImageTransportImageStreamer class PngStreamerType : public ImageStreamerType { public: - boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); - std::string create_viewer(const async_web_server_cpp::HttpRequest &request); + boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); + std::string create_viewer(const async_web_server_cpp::HttpRequest & request); }; class PngSnapshotStreamer : public ImageTransportImageStreamer { public: - PngSnapshotStreamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node); + PngSnapshotStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node); ~PngSnapshotStreamer(); + protected: - virtual void sendImage(const cv::Mat &, const rclcpp::Time &time); + virtual void sendImage(const cv::Mat &, const rclcpp::Time & time); private: int quality_; diff --git a/include/web_video_server/ros_compressed_streamer.hpp b/include/web_video_server/ros_compressed_streamer.hpp index 9cbf6fe..db3886a 100644 --- a/include/web_video_server/ros_compressed_streamer.hpp +++ b/include/web_video_server/ros_compressed_streamer.hpp @@ -13,14 +13,18 @@ namespace web_video_server class RosCompressedStreamer : public ImageStreamer { public: - RosCompressedStreamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + RosCompressedStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); ~RosCompressedStreamer(); virtual void start(); virtual void restreamFrame(double max_age); protected: - virtual void sendImage(const sensor_msgs::msg::CompressedImage::ConstSharedPtr msg, const rclcpp::Time &time); + virtual void sendImage( + const sensor_msgs::msg::CompressedImage::ConstSharedPtr msg, + const rclcpp::Time & time); private: void imageCallback(const sensor_msgs::msg::CompressedImage::ConstSharedPtr msg); @@ -35,10 +39,11 @@ class RosCompressedStreamer : public ImageStreamer class RosCompressedStreamerType : public ImageStreamerType { public: - boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); - std::string create_viewer(const async_web_server_cpp::HttpRequest &request); + boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); + std::string create_viewer(const async_web_server_cpp::HttpRequest & request); }; } diff --git a/include/web_video_server/vp8_streamer.hpp b/include/web_video_server/vp8_streamer.hpp index 3fd0554..215fa75 100644 --- a/include/web_video_server/vp8_streamer.hpp +++ b/include/web_video_server/vp8_streamer.hpp @@ -48,11 +48,15 @@ namespace web_video_server class Vp8Streamer : public LibavStreamer { public: - Vp8Streamer(const async_web_server_cpp::HttpRequest& request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + Vp8Streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); ~Vp8Streamer(); + protected: virtual void initializeEncoder(); + private: std::string quality_; }; @@ -61,12 +65,12 @@ class Vp8StreamerType : public LibavStreamerType { public: Vp8StreamerType(); - virtual boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest& request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + virtual boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); }; } #endif - diff --git a/include/web_video_server/vp9_streamer.hpp b/include/web_video_server/vp9_streamer.hpp index 91c6ac2..19208cc 100644 --- a/include/web_video_server/vp9_streamer.hpp +++ b/include/web_video_server/vp9_streamer.hpp @@ -12,9 +12,12 @@ namespace web_video_server class Vp9Streamer : public LibavStreamer { public: - Vp9Streamer(const async_web_server_cpp::HttpRequest& request, async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + Vp9Streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); ~Vp9Streamer(); + protected: virtual void initializeEncoder(); }; @@ -23,9 +26,10 @@ class Vp9StreamerType : public LibavStreamerType { public: Vp9StreamerType(); - virtual boost::shared_ptr create_streamer(const async_web_server_cpp::HttpRequest& request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node); + virtual boost::shared_ptr create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node); }; } diff --git a/include/web_video_server/web_video_server.hpp b/include/web_video_server/web_video_server.hpp index 19c59ca..a0a5be9 100644 --- a/include/web_video_server/web_video_server.hpp +++ b/include/web_video_server/web_video_server.hpp @@ -29,7 +29,7 @@ class WebVideoServer * @brief Constructor * @return */ - WebVideoServer(rclcpp::Node::SharedPtr &node); + WebVideoServer(rclcpp::Node::SharedPtr & node); /** * @brief Destructor - Cleans up @@ -43,20 +43,30 @@ class WebVideoServer void setup_cleanup_inactive_streams(); - bool handle_request(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, const char* begin, const char* end); + bool handle_request( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + const char * begin, const char * end); - bool handle_stream(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, const char* begin, const char* end); + bool handle_stream( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + const char * begin, const char * end); - bool handle_stream_viewer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, const char* begin, const char* end); + bool handle_stream_viewer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + const char * begin, const char * end); - bool handle_snapshot(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, const char* begin, const char* end); + bool handle_snapshot( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + const char * begin, const char * end); - bool handle_list_streams(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, const char* begin, const char* end); + bool handle_list_streams( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + const char * begin, const char * end); private: void restreamFrames(double max_age); @@ -76,8 +86,8 @@ class WebVideoServer boost::shared_ptr server_; async_web_server_cpp::HttpRequestHandlerGroup handler_group_; - std::vector > image_subscribers_; - std::map > stream_types_; + std::vector> image_subscribers_; + std::map> stream_types_; boost::mutex subscriber_mutex_; }; diff --git a/package.xml b/package.xml index 59ad8c5..f4f6c1c 100644 --- a/package.xml +++ b/package.xml @@ -34,7 +34,7 @@ ament_lint_auto ament_cmake_lint_cmake ament_cmake_xmllint - + ament_cmake_uncrustify ament_cmake diff --git a/src/h264_streamer.cpp b/src/h264_streamer.cpp index 89affcc..7a889ec 100644 --- a/src/h264_streamer.cpp +++ b/src/h264_streamer.cpp @@ -3,9 +3,10 @@ namespace web_video_server { -H264Streamer::H264Streamer(const async_web_server_cpp::HttpRequest& request, - async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) : - LibavStreamer(request, connection, node, "mp4", "libx264", "video/mp4") +H264Streamer::H264Streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) +: LibavStreamer(request, connection, node, "mp4", "libx264", "video/mp4") { /* possible quality presets: * ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo @@ -34,14 +35,15 @@ void H264Streamer::initializeEncoder() } } -H264StreamerType::H264StreamerType() : - LibavStreamerType("mp4", "libx264", "video/mp4") +H264StreamerType::H264StreamerType() +: LibavStreamerType("mp4", "libx264", "video/mp4") { } -boost::shared_ptr H264StreamerType::create_streamer(const async_web_server_cpp::HttpRequest& request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node) +boost::shared_ptr H264StreamerType::create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node) { return boost::shared_ptr(new H264Streamer(request, connection, node)); } diff --git a/src/image_streamer.cpp b/src/image_streamer.cpp index c06f0a6..1347759 100644 --- a/src/image_streamer.cpp +++ b/src/image_streamer.cpp @@ -11,9 +11,10 @@ namespace web_video_server { -ImageStreamer::ImageStreamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) : - request_(request), connection_(connection), node_(node), inactive_(false) +ImageStreamer::ImageStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) +: request_(request), connection_(connection), node_(node), inactive_(false) { topic_ = request.get_query_param_value_or_default("topic", ""); } @@ -22,9 +23,10 @@ ImageStreamer::~ImageStreamer() { } -ImageTransportImageStreamer::ImageTransportImageStreamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) : - ImageStreamer(request, connection, node), it_(node), initialized_(false) +ImageTransportImageStreamer::ImageTransportImageStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) +: ImageStreamer(request, connection, node), it_(node), initialized_(false) { output_width_ = request.get_query_param_value_or_default("width", -1); output_height_ = request.get_query_param_value_or_default("height", -1); @@ -48,14 +50,16 @@ void ImageTransportImageStreamer::start() continue; } auto & topic_name = topic_and_types.first; - if(topic_name == topic_ || (topic_name.find("/") == 0 && topic_name.substr(1) == topic_)){ + if (topic_name == topic_ || (topic_name.find("/") == 0 && topic_name.substr(1) == topic_)) { inactive_ = false; break; } } // Get QoS profile from query parameter - RCLCPP_INFO(node_->get_logger(), "Streaming topic %s with QoS profile %s", topic_.c_str(), qos_profile_name_.c_str()); + RCLCPP_INFO( + node_->get_logger(), "Streaming topic %s with QoS profile %s", topic_.c_str(), + qos_profile_name_.c_str()); auto qos_profile = get_qos_profile_from_name(qos_profile_name_); if (!qos_profile) { qos_profile = rmw_qos_profile_default; @@ -67,8 +71,9 @@ void ImageTransportImageStreamer::start() // Create subscriber image_sub_ = image_transport::create_subscription( - node_.get(), topic_, std::bind(&ImageTransportImageStreamer::imageCallback, this, std::placeholders::_1), - default_transport_, qos_profile.value()); + node_.get(), topic_, + std::bind(&ImageTransportImageStreamer::imageCallback, this, std::placeholders::_1), + default_transport_, qos_profile.value()); } void ImageTransportImageStreamer::initialize(const cv::Mat &) @@ -77,30 +82,25 @@ void ImageTransportImageStreamer::initialize(const cv::Mat &) void ImageTransportImageStreamer::restreamFrame(double max_age) { - if (inactive_ || !initialized_ ) + if (inactive_ || !initialized_) { return; + } try { - if ( last_frame + rclcpp::Duration::from_seconds(max_age) < node_->now() ) { + if (last_frame + rclcpp::Duration::from_seconds(max_age) < node_->now() ) { boost::mutex::scoped_lock lock(send_mutex_); sendImage(output_size_image, node_->now() ); // don't update last_frame, it may remain an old value. } - } - catch (boost::system::system_error &e) - { + } catch (boost::system::system_error & e) { // happens when client disconnects RCLCPP_DEBUG(node_->get_logger(), "system_error exception: %s", e.what()); inactive_ = true; return; - } - catch (std::exception &e) - { + } catch (std::exception & e) { // TODO THROTTLE with 30 RCLCPP_ERROR(node_->get_logger(), "exception: %s", e.what()); inactive_ = true; return; - } - catch (...) - { + } catch (...) { // TODO THROTTLE with 30 RCLCPP_ERROR(node_->get_logger(), "exception"); inactive_ = true; @@ -108,30 +108,26 @@ void ImageTransportImageStreamer::restreamFrame(double max_age) } } -void ImageTransportImageStreamer::imageCallback(const sensor_msgs::msg::Image::ConstSharedPtr &msg) +void ImageTransportImageStreamer::imageCallback(const sensor_msgs::msg::Image::ConstSharedPtr & msg) { - if (inactive_) + if (inactive_) { return; + } cv::Mat img; - try - { - if (msg->encoding.find("F") != std::string::npos) - { + try { + if (msg->encoding.find("F") != std::string::npos) { // scale floating point images cv::Mat float_image_bridge = cv_bridge::toCvCopy(msg, msg->encoding)->image; cv::Mat_ float_image = float_image_bridge; double max_val; cv::minMaxIdx(float_image, 0, &max_val); - if (max_val > 0) - { + if (max_val > 0) { float_image *= (255 / max_val); } img = float_image; - } - else - { + } else { // Convert to OpenCV native BGR color img = cv_bridge::toCvCopy(msg, "bgr8")->image; } @@ -139,70 +135,57 @@ void ImageTransportImageStreamer::imageCallback(const sensor_msgs::msg::Image::C int input_width = img.cols; int input_height = img.rows; - if (output_width_ == -1) + if (output_width_ == -1) { output_width_ = input_width; - if (output_height_ == -1) + } + if (output_height_ == -1) { output_height_ = input_height; + } - if (invert_) - { + if (invert_) { // Rotate 180 degrees cv::flip(img, img, false); cv::flip(img, img, true); } boost::mutex::scoped_lock lock(send_mutex_); // protects output_size_image - if (output_width_ != input_width || output_height_ != input_height) - { + if (output_width_ != input_width || output_height_ != input_height) { cv::Mat img_resized; cv::Size new_size(output_width_, output_height_); cv::resize(img, img_resized, new_size); output_size_image = img_resized; - } - else - { + } else { output_size_image = img; } - if (!initialized_) - { + if (!initialized_) { initialize(output_size_image); initialized_ = true; } last_frame = node_->now(); sendImage(output_size_image, msg->header.stamp); - } - catch (cv_bridge::Exception &e) - { + } catch (cv_bridge::Exception & e) { // TODO THROTTLE with 30 RCLCPP_ERROR(node_->get_logger(), "cv_bridge exception: %s", e.what()); inactive_ = true; return; - } - catch (cv::Exception &e) - { + } catch (cv::Exception & e) { // TODO THROTTLE with 30 RCLCPP_ERROR(node_->get_logger(), "cv_bridge exception: %s", e.what()); inactive_ = true; return; - } - catch (boost::system::system_error &e) - { + } catch (boost::system::system_error & e) { // happens when client disconnects RCLCPP_DEBUG(node_->get_logger(), "system_error exception: %s", e.what()); inactive_ = true; return; - } - catch (std::exception &e) - { + } catch (std::exception & e) { // TODO THROTTLE with 30 RCLCPP_ERROR(node_->get_logger(), "exception: %s", e.what()); inactive_ = true; return; - } - catch (...) - { + } catch (...) { // TODO THROTTLE with 30 RCLCPP_ERROR(node_->get_logger(), "exception"); inactive_ = true; diff --git a/src/jpeg_streamers.cpp b/src/jpeg_streamers.cpp index d20adc5..0187991 100644 --- a/src/jpeg_streamers.cpp +++ b/src/jpeg_streamers.cpp @@ -4,9 +4,11 @@ namespace web_video_server { -MjpegStreamer::MjpegStreamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) : - ImageTransportImageStreamer(request, connection, node), stream_(std::bind(&rclcpp::Node::now, node), connection) +MjpegStreamer::MjpegStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) +: ImageTransportImageStreamer(request, connection, node), + stream_(std::bind(&rclcpp::Node::now, node), connection) { quality_ = request.get_query_param_value_or_default("quality", 95); stream_.sendInitialHeader(); @@ -18,7 +20,7 @@ MjpegStreamer::~MjpegStreamer() boost::mutex::scoped_lock lock(send_mutex_); // protects sendImage. } -void MjpegStreamer::sendImage(const cv::Mat &img, const rclcpp::Time &time) +void MjpegStreamer::sendImage(const cv::Mat & img, const rclcpp::Time & time) { std::vector encode_params; encode_params.push_back(cv::IMWRITE_JPEG_QUALITY); @@ -30,14 +32,15 @@ void MjpegStreamer::sendImage(const cv::Mat &img, const rclcpp::Time &time) stream_.sendPartAndClear(time, "image/jpeg", encoded_buffer); } -boost::shared_ptr MjpegStreamerType::create_streamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node) +boost::shared_ptr MjpegStreamerType::create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node) { return boost::shared_ptr(new MjpegStreamer(request, connection, node)); } -std::string MjpegStreamerType::create_viewer(const async_web_server_cpp::HttpRequest &request) +std::string MjpegStreamerType::create_viewer(const async_web_server_cpp::HttpRequest & request) { std::stringstream ss; ss << "("quality", 95); } @@ -60,7 +64,7 @@ JpegSnapshotStreamer::~JpegSnapshotStreamer() boost::mutex::scoped_lock lock(send_mutex_); // protects sendImage. } -void JpegSnapshotStreamer::sendImage(const cv::Mat &img, const rclcpp::Time &time) +void JpegSnapshotStreamer::sendImage(const cv::Mat & img, const rclcpp::Time & time) { std::vector encode_params; encode_params.push_back(cv::IMWRITE_JPEG_QUALITY); @@ -72,18 +76,17 @@ void JpegSnapshotStreamer::sendImage(const cv::Mat &img, const rclcpp::Time &tim char stamp[20]; sprintf(stamp, "%.06lf", time.seconds()); async_web_server_cpp::HttpReply::builder(async_web_server_cpp::HttpReply::ok) - .header("Connection", "close") - .header("Server", "web_video_server") - .header("Cache-Control", - "no-cache, no-store, must-revalidate, pre-check=0, post-check=0, " - "max-age=0") - .header("X-Timestamp", stamp) - .header("Pragma", "no-cache") - .header("Content-type", "image/jpeg") - .header("Access-Control-Allow-Origin", "*") - .header("Content-Length", - boost::lexical_cast(encoded_buffer.size())) - .write(connection_); + .header("Connection", "close") + .header("Server", "web_video_server") + .header( + "Cache-Control", + "no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0") + .header("X-Timestamp", stamp) + .header("Pragma", "no-cache") + .header("Content-type", "image/jpeg") + .header("Access-Control-Allow-Origin", "*") + .header("Content-Length", boost::lexical_cast(encoded_buffer.size())) + .write(connection_); connection_->write_and_clear(encoded_buffer); inactive_ = true; } diff --git a/src/libav_streamer.cpp b/src/libav_streamer.cpp index 52d348f..22fc2af 100644 --- a/src/libav_streamer.cpp +++ b/src/libav_streamer.cpp @@ -8,15 +8,16 @@ namespace web_video_server { -LibavStreamer::LibavStreamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node, - const std::string &format_name, const std::string &codec_name, - const std::string &content_type) : - ImageTransportImageStreamer(request, connection, node), format_context_(0), codec_(0), codec_context_(0), video_stream_( - 0), frame_(0), sws_context_(0), first_image_timestamp_(0), format_name_( - format_name), codec_name_(codec_name), content_type_(content_type), opt_(0), io_buffer_(0) +LibavStreamer::LibavStreamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node, + const std::string & format_name, const std::string & codec_name, + const std::string & content_type) +: ImageTransportImageStreamer(request, connection, node), format_context_(0), codec_(0), + codec_context_(0), video_stream_(0), frame_(0), sws_context_(0), first_image_timestamp_(0), + format_name_(format_name), codec_name_(codec_name), content_type_(content_type), opt_(0), + io_buffer_(0) { - bitrate_ = request.get_query_param_value_or_default("bitrate", 100000); qmin_ = request.get_query_param_value_or_default("qmin", 10); qmax_ = request.get_query_param_value_or_default("qmax", 42); @@ -25,65 +26,63 @@ LibavStreamer::LibavStreamer(const async_web_server_cpp::HttpRequest &request, LibavStreamer::~LibavStreamer() { - if (codec_context_) - { + if (codec_context_) { avcodec_free_context(&codec_context_); } - if (frame_) - { + if (frame_) { av_frame_free(&frame_); } - if (io_buffer_) + if (io_buffer_) { delete io_buffer_; + } if (format_context_) { - if (format_context_->pb) + if (format_context_->pb) { av_free(format_context_->pb); + } avformat_free_context(format_context_); } - if (sws_context_) + if (sws_context_) { sws_freeContext(sws_context_); + } } // output callback for ffmpeg IO context -static int dispatch_output_packet(void* opaque, uint8_t* buffer, int buffer_size) +static int dispatch_output_packet(void * opaque, uint8_t * buffer, int buffer_size) { - async_web_server_cpp::HttpConnectionPtr connection = *((async_web_server_cpp::HttpConnectionPtr*) opaque); + async_web_server_cpp::HttpConnectionPtr connection = + *((async_web_server_cpp::HttpConnectionPtr *) opaque); std::vector encoded_frame; encoded_frame.assign(buffer, buffer + buffer_size); connection->write_and_clear(encoded_frame); return 0; // TODO: can this fail? } -void LibavStreamer::initialize(const cv::Mat &img) +void LibavStreamer::initialize(const cv::Mat & img) { // Load format format_context_ = avformat_alloc_context(); - if (!format_context_) - { - async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::internal_server_error)(request_, - connection_, - NULL, NULL); + if (!format_context_) { + async_web_server_cpp::HttpReply::stock_reply( + async_web_server_cpp::HttpReply::internal_server_error)(request_, connection_, NULL, NULL); throw std::runtime_error("Error allocating ffmpeg format context"); } format_context_->oformat = av_guess_format(format_name_.c_str(), NULL, NULL); - if (!format_context_->oformat) - { - async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::internal_server_error)(request_, - connection_, - NULL, NULL); + if (!format_context_->oformat) { + async_web_server_cpp::HttpReply::stock_reply( + async_web_server_cpp::HttpReply::internal_server_error)(request_, connection_, NULL, NULL); throw std::runtime_error("Error looking up output format"); } // Set up custom IO callback. size_t io_buffer_size = 3 * 1024; // 3M seen elsewhere and adjudged good io_buffer_ = new unsigned char[io_buffer_size]; - AVIOContext* io_ctx = avio_alloc_context(io_buffer_, io_buffer_size, AVIO_FLAG_WRITE, &connection_, NULL, dispatch_output_packet, NULL); - if (!io_ctx) - { - async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::internal_server_error)(request_, - connection_, - NULL, NULL); + AVIOContext * io_ctx = avio_alloc_context( + io_buffer_, io_buffer_size, AVIO_FLAG_WRITE, + &connection_, NULL, dispatch_output_packet, NULL); + if (!io_ctx) { + async_web_server_cpp::HttpReply::stock_reply( + async_web_server_cpp::HttpReply::internal_server_error)(request_, connection_, NULL, NULL); throw std::runtime_error("Error setting up IO context"); } io_ctx->seekable = 0; // no seeking, it's a stream @@ -91,27 +90,24 @@ void LibavStreamer::initialize(const cv::Mat &img) format_context_->max_interleave_delta = 0; // Load codec - if (codec_name_.empty()) // use default codec if none specified + if (codec_name_.empty()) { // use default codec if none specified codec_ = avcodec_find_encoder(format_context_->oformat->video_codec); - else + } else { codec_ = avcodec_find_encoder_by_name(codec_name_.c_str()); - if (!codec_) - { - async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::internal_server_error)(request_, - connection_, - NULL, NULL); + } + if (!codec_) { + async_web_server_cpp::HttpReply::stock_reply( + async_web_server_cpp::HttpReply::internal_server_error)(request_, connection_, NULL, NULL); throw std::runtime_error("Error looking up codec"); } video_stream_ = avformat_new_stream(format_context_, codec_); - if (!video_stream_) - { - async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::internal_server_error)(request_, - connection_, - NULL, NULL); + if (!video_stream_) { + async_web_server_cpp::HttpReply::stock_reply( + async_web_server_cpp::HttpReply::internal_server_error)(request_, connection_, NULL, NULL); throw std::runtime_error("Error creating video stream"); } - codec_context_ = avcodec_alloc_context3(codec_); + codec_context_ = avcodec_alloc_context3(codec_); // Set options codec_context_->codec_id = codec_->id; @@ -141,19 +137,18 @@ void LibavStreamer::initialize(const cv::Mat &img) avcodec_parameters_from_context(video_stream_->codecpar, codec_context_); // Open Codec - if (avcodec_open2(codec_context_, codec_, NULL) < 0) - { - async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::internal_server_error)(request_, - connection_, - NULL, NULL); + if (avcodec_open2(codec_context_, codec_, NULL) < 0) { + async_web_server_cpp::HttpReply::stock_reply( + async_web_server_cpp::HttpReply::internal_server_error)(request_, connection_, NULL, NULL); throw std::runtime_error("Could not open video codec"); } // Allocate frame buffers frame_ = av_frame_alloc(); - av_image_alloc(frame_->data, frame_->linesize, output_width_, output_height_, - codec_context_->pix_fmt, 1); + av_image_alloc( + frame_->data, frame_->linesize, output_width_, output_height_, + codec_context_->pix_fmt, 1); frame_->width = output_width_; frame_->height = output_height_; @@ -164,18 +159,24 @@ void LibavStreamer::initialize(const cv::Mat &img) av_dict_set(&format_context_->metadata, "title", topic_.c_str(), 0); // Send response headers - async_web_server_cpp::HttpReply::builder(async_web_server_cpp::HttpReply::ok).header("Connection", "close").header( - "Server", "web_video_server").header("Cache-Control", - "no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0").header( - "Pragma", "no-cache").header("Expires", "0").header("Max-Age", "0").header("Trailer", "Expires").header( - "Content-type", content_type_).header("Access-Control-Allow-Origin", "*").write(connection_); + async_web_server_cpp::HttpReply::builder(async_web_server_cpp::HttpReply::ok) + .header("Connection", "close") + .header("Server", "web_video_server") + .header( + "Cache-Control", + "no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0") + .header("Pragma", "no-cache") + .header("Expires", "0") + .header("Max-Age", "0") + .header("Trailer", "Expires") + .header("Content-type", content_type_) + .header("Access-Control-Allow-Origin", "*") + .write(connection_); // Send video stream header - if (avformat_write_header(format_context_, &opt_) < 0) - { - async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::internal_server_error)(request_, - connection_, - NULL, NULL); + if (avformat_write_header(format_context_, &opt_) < 0) { + async_web_server_cpp::HttpReply::stock_reply( + async_web_server_cpp::HttpReply::internal_server_error)(request_, connection_, NULL, NULL); throw std::runtime_error("Error openning dynamic buffer"); } } @@ -184,87 +185,80 @@ void LibavStreamer::initializeEncoder() { } -void LibavStreamer::sendImage(const cv::Mat &img, const rclcpp::Time &time) +void LibavStreamer::sendImage(const cv::Mat & img, const rclcpp::Time & time) { boost::mutex::scoped_lock lock(encode_mutex_); - if (0 == first_image_timestamp_.nanoseconds()) - { + if (0 == first_image_timestamp_.nanoseconds()) { first_image_timestamp_ = time; } AVPixelFormat input_coding_format = AV_PIX_FMT_BGR24; - AVFrame *raw_frame = av_frame_alloc(); - av_image_fill_arrays(raw_frame->data, raw_frame->linesize, - img.data, input_coding_format, output_width_, output_height_, 1); + AVFrame * raw_frame = av_frame_alloc(); + av_image_fill_arrays( + raw_frame->data, raw_frame->linesize, + img.data, input_coding_format, output_width_, output_height_, 1); // Convert from opencv to libav - if (!sws_context_) - { + if (!sws_context_) { static int sws_flags = SWS_BICUBIC; - sws_context_ = sws_getContext(output_width_, output_height_, input_coding_format, output_width_, output_height_, - codec_context_->pix_fmt, sws_flags, NULL, NULL, NULL); - if (!sws_context_) - { + sws_context_ = sws_getContext( + output_width_, output_height_, input_coding_format, output_width_, + output_height_, codec_context_->pix_fmt, sws_flags, NULL, NULL, NULL); + if (!sws_context_) { throw std::runtime_error("Could not initialize the conversion context"); } } - int ret = sws_scale(sws_context_, - (const uint8_t * const *)raw_frame->data, raw_frame->linesize, 0, - output_height_, frame_->data, frame_->linesize); + int ret = sws_scale( + sws_context_, + (const uint8_t * const *)raw_frame->data, raw_frame->linesize, 0, + output_height_, frame_->data, frame_->linesize); av_frame_free(&raw_frame); // Encode the frame - AVPacket* pkt = av_packet_alloc(); + AVPacket * pkt = av_packet_alloc(); ret = avcodec_send_frame(codec_context_, frame_); - if (ret == AVERROR_EOF) - { - RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_send_frame() encoder flushed\n"); + if (ret == AVERROR_EOF) { + RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_send_frame() encoder flushed\n"); + } else if (ret == AVERROR(EAGAIN)) { + RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_send_frame() need output read out\n"); } - else if (ret == AVERROR(EAGAIN)) - { - RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_send_frame() need output read out\n"); - } - if (ret < 0) - { + if (ret < 0) { throw std::runtime_error("Error encoding video frame"); } ret = avcodec_receive_packet(codec_context_, pkt); bool got_packet = pkt->size > 0; - if (ret == AVERROR_EOF) - { - RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_receive_packet() encoder flushed\n"); - } - else if (ret == AVERROR(EAGAIN)) - { - RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_receive_packet() needs more input\n"); + if (ret == AVERROR_EOF) { + RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_receive_packet() encoder flushed\n"); + } else if (ret == AVERROR(EAGAIN)) { + RCLCPP_DEBUG_STREAM(node_->get_logger(), "avcodec_receive_packet() needs more input\n"); got_packet = false; } - if (got_packet) - { + if (got_packet) { std::size_t size; - uint8_t *output_buf; + uint8_t * output_buf; double seconds = (time - first_image_timestamp_).seconds(); // Encode video at 1/0.95 to minimize delay pkt->pts = (int64_t)(seconds / av_q2d(video_stream_->time_base) * 0.95); - if (pkt->pts <= 0) + if (pkt->pts <= 0) { pkt->pts = 1; + } pkt->dts = pkt->pts; - if (pkt->flags&AV_PKT_FLAG_KEY) + if (pkt->flags & AV_PKT_FLAG_KEY) { pkt->flags |= AV_PKT_FLAG_KEY; + } pkt->stream_index = video_stream_->index; - if (av_write_frame(format_context_, pkt)) - { + if (av_write_frame(format_context_, pkt)) { throw std::runtime_error("Error when writing frame"); } } @@ -272,21 +266,23 @@ void LibavStreamer::sendImage(const cv::Mat &img, const rclcpp::Time &time) av_packet_unref(pkt); } -LibavStreamerType::LibavStreamerType(const std::string &format_name, const std::string &codec_name, - const std::string &content_type) : - format_name_(format_name), codec_name_(codec_name), content_type_(content_type) +LibavStreamerType::LibavStreamerType( + const std::string & format_name, const std::string & codec_name, + const std::string & content_type) +: format_name_(format_name), codec_name_(codec_name), content_type_(content_type) { } -boost::shared_ptr LibavStreamerType::create_streamer(const async_web_server_cpp::HttpRequest &request, - async_web_server_cpp::HttpConnectionPtr connection, - rclcpp::Node::SharedPtr node) +boost::shared_ptr LibavStreamerType::create_streamer( + const async_web_server_cpp::HttpRequest & request, + async_web_server_cpp::HttpConnectionPtr connection, + rclcpp::Node::SharedPtr node) { return boost::shared_ptr( - new LibavStreamer(request, connection, node, format_name_, codec_name_, content_type_)); + new LibavStreamer(request, connection, node, format_name_, codec_name_, content_type_)); } -std::string LibavStreamerType::create_viewer(const async_web_server_cpp::HttpRequest &request) +std::string LibavStreamerType::create_viewer(const async_web_server_cpp::HttpRequest & request) { std::stringstream ss; ss << "