Skip to content

Conversation

bjsowa
Copy link
Member

@bjsowa bjsowa commented Oct 10, 2025

This is PR includes quite a large refactor and multiple improvements.

Improvements

  • The largest improvement is using pluginlib to dynamically load streamers at runtime in a similar fashion as image_transport is loading it's subscriber and publisher plugins. This allows the user to extend the functionality without modifying the package, by writing plugins implementing StreamerFactoryInterface or SnapshotStreamerFactoryInterface.

  • Significantly improved the stream list page. The streamer factories provide a method for getting a list of supported topics. The node is utilizing this method to show supported streamers for a given topic. Here's how it looked before:

    image

    And here's after:

    image

    Notice that ros_compressed is shown even for topics that don't have raw topics. (Fixes Compressed image topic not accessible #94)

  • /snapshot request now support type parameter. This makes the snapshots not limited to jpeg. The user can specify png, ros_compressed or any format provided by a plugin implementing SnapshotStreamerFactoryInterface. (Fixes Snapshots only in JPEG ? #109)

Refactor

  • Split the library into web_video_server and web_video_server_streamers. The idea behind it is to not have to link against OpenCV and ffmpeg when developing custom streamer plugins.
  • Changed all method names to snake_case. There was a mix of snake_case and camelCase. I decided on sticking to snake_case as it's the naming convention used in core ROS packages.
  • Changed some of the class names:
    • ImageStreamer -> StreamerInterface - although this is the primary function of web_video_server, we don't have to limit ourselves to streaming images.
    • ImageStreamerType -> StreamerFactoryInterface - I felt like Type was a bit misleading as this class is actually a factory for creating streamers.
    • ImageTransportImageStreamer -> ImageTransportStreamerBase, LibavStreamer -> LibavStreamerBase - to better reflect that these are common base classes used by plugins.
  • Reorganized file structure to separate the core library and streamers.
  • Modified include directives to include only what's used.

@bjsowa bjsowa requested a review from Copilot October 10, 2025 14:14
Copilot

This comment was marked as outdated.

@bjsowa bjsowa marked this pull request as ready for review October 19, 2025 02:47
@bjsowa bjsowa requested a review from sea-bass October 19, 2025 02:47
Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really am not a fan of pluginlib, but I can definitely see the value or not loading every possible streamer type right away.

Code looks great, including all the cleanup on the wah. However, I think this needs some documentation on how to configure which plugins you want to load and how to launch a node properly. Can you add this in a README?

@bjsowa
Copy link
Member Author

bjsowa commented Oct 19, 2025

I really am not a fan of pluginlib, but I can definitely see the value or not loading every possible streamer type right away.

Well.. it still loads every streamer factory it can find. The pluginlib just allows declaring more streamers outside the package. image_transport declares a parameter for plugin whitelist but I don't see a sense of implementing it here as they don't pollute topics and overhead of loading them is negligible.

Now I'm curious why you dislike pluginlib and what alternative would you recommend instead.

Code looks great, including all the cleanup on the wah. However, I think this needs some documentation on how to configure which plugins you want to load and how to launch a node properly. Can you add this in a README?

I could add a section on how to create a package which adds another streamer type.

@sea-bass
Copy link
Contributor

sea-bass commented Oct 19, 2025

Now I'm curious why you dislike pluginlib and what alternative would you recommend instead.

I think pluginlib has a lot of weird behavior, and often exhibits memory leaks / failure to clean up on shutdown.

Plus, I'm generally of the belief that runtime configurability without compilation isn't worth forcing one to use a single abstract class and dealing with pluginlib idiosyncrasies. I prefer for people to have a flexible API and just recompile if needed.

No alternatives recommended --- I think this is just personal preference, but there is no real issue.

I could add a section on how to create a package which adds another streamer type.

Understood. I did think there was a path similar to image_transport as you described, where the node had a parameter listing out the plugins to load. If that's not the case, all good!

That would be great, though if you prefer to do that in a follow-on I can approve this now.

@bjsowa
Copy link
Member Author

bjsowa commented Oct 19, 2025

I'll add the documentation first to confirm whether this actually works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapshots only in JPEG ? Compressed image topic not accessible

2 participants