4242namespace web_video_server
4343{
4444
45+ /* *
46+ * @brief A common interface for all streaming plugins.
47+ */
4548class StreamerInterface
4649{
4750public:
4851 StreamerInterface (
4952 const async_web_server_cpp::HttpRequest & request,
5053 async_web_server_cpp::HttpConnectionPtr connection,
5154 rclcpp::Node::SharedPtr node);
55+ virtual ~StreamerInterface ();
5256
57+ /* *
58+ * @brief Starts the streaming process.
59+ */
5360 virtual void start () = 0;
54- virtual ~StreamerInterface ();
5561
62+ /* *
63+ * @brief Returns true if the streamer is inactive and should be deleted.
64+ *
65+ * This could be because the connection was closed or snapshot was successfully sent (in case
66+ * of snapshot streamers).
67+ */
5668 bool isInactive ()
5769 {
5870 return inactive_;
5971 }
6072
6173 /* *
62- * Restreams the last received image frame if older than max_age.
74+ * @brief Restreams the last received image frame if older than max_age.
6375 */
6476 virtual void restreamFrame (std::chrono::duration<double > max_age) = 0;
6577
78+ /* *
79+ * @brief Returns the topic being streamed.
80+ */
6681 std::string getTopic ()
6782 {
6883 return topic_;
@@ -76,21 +91,48 @@ class StreamerInterface
7691 std::string topic_;
7792};
7893
94+ /* *
95+ * @brief A factory interface for creating Streamer instances.
96+ */
7997class StreamerFactoryInterface
8098{
8199public:
100+ /* *
101+ * @brief Returns the type of streamer created by this factory.
102+ *
103+ * This should match the "type" query parameter used to select the streamer.
104+ */
82105 virtual std::string get_type () = 0;
83106
107+ /* *
108+ * @brief Creates a new Streamer instance.
109+ * @param request The HTTP request that initiated the streamer.
110+ * @param connection The HTTP connection to use for streaming.
111+ * @param node The ROS2 node to use for subscribing to topics.
112+ * @return A shared pointer to the created Streamer instance.
113+ */
84114 virtual std::shared_ptr<StreamerInterface> create_streamer (
85115 const async_web_server_cpp::HttpRequest & request,
86116 async_web_server_cpp::HttpConnectionPtr connection,
87117 rclcpp::Node::SharedPtr node) = 0;
88118
119+ /* *
120+ * @brief Creates HTML code for embedding a viewer for this streamer.
121+ * @param request The HTTP request that initiated the viewer.
122+ */
89123 virtual std::string create_viewer (const async_web_server_cpp::HttpRequest & request);
90124
125+ /* *
126+ * @brief Returns a list of available topics that can be streamed by this streamer.
127+ * @param node The ROS2 node to use for discovering topics.
128+ * @return A vector of topic names.
129+ */
91130 virtual std::vector<std::string> get_available_topics (rclcpp::Node::SharedPtr node);
92131};
93132
133+ /* *
134+ * @brief A factory interface for creating snapshot Streamer instances.
135+ */
94136class SnapshotStreamerFactoryInterface : public StreamerFactoryInterface {};
95137
96138} // namespace web_video_server
0 commit comments