Skip to content

Commit 5a44cdd

Browse files
sfalexrogjihoonl
authored andcommitted
Add "default_stream_type" parameter (#84)
This allows users to specify default stream type in their .launch files. Using a "ros_compressed" stream type sometimes results in a much lower resource consumption, and having it set as a default is much nicer for end users.
1 parent c3d08d4 commit 5a44cdd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/web_video_server.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace web_video_server
1919

2020
static bool __verbose;
2121

22+
static std::string __default_stream_type;
23+
2224
static bool ros_connection_logger(async_web_server_cpp::HttpServerRequestHandler forward,
2325
const async_web_server_cpp::HttpRequest &request,
2426
async_web_server_cpp::HttpConnectionPtr connection, const char* begin,
@@ -61,6 +63,8 @@ WebVideoServer::WebVideoServer(ros::NodeHandle &nh, ros::NodeHandle &private_nh)
6163

6264
private_nh.param("ros_threads", ros_threads_, 2);
6365

66+
private_nh.param<std::string>("default_stream_type", __default_stream_type, "mjpeg");
67+
6468
stream_types_["mjpeg"] = boost::shared_ptr<ImageStreamerType>(new MjpegStreamerType());
6569
stream_types_["png"] = boost::shared_ptr<ImageStreamerType>(new PngStreamerType());
6670
stream_types_["ros_compressed"] = boost::shared_ptr<ImageStreamerType>(new RosCompressedStreamerType());
@@ -124,7 +128,7 @@ bool WebVideoServer::handle_stream(const async_web_server_cpp::HttpRequest &requ
124128
async_web_server_cpp::HttpConnectionPtr connection, const char* begin,
125129
const char* end)
126130
{
127-
std::string type = request.get_query_param_value_or_default("type", "mjpeg");
131+
std::string type = request.get_query_param_value_or_default("type", __default_stream_type);
128132
if (stream_types_.find(type) != stream_types_.end())
129133
{
130134
boost::shared_ptr<ImageStreamer> streamer = stream_types_[type]->create_streamer(request, connection, nh_);

0 commit comments

Comments
 (0)