Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add "default_stream_type" parameter #84

Merged
merged 2 commits into from
Jan 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/web_video_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace web_video_server

static bool __verbose;

static std::string __default_stream_type;

static bool ros_connection_logger(async_web_server_cpp::HttpServerRequestHandler forward,
const async_web_server_cpp::HttpRequest &request,
async_web_server_cpp::HttpConnectionPtr connection, const char* begin,
Expand Down Expand Up @@ -61,6 +63,8 @@ WebVideoServer::WebVideoServer(ros::NodeHandle &nh, ros::NodeHandle &private_nh)

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

private_nh.param<std::string>("default_stream_type", __default_stream_type, "mjpeg");

stream_types_["mjpeg"] = boost::shared_ptr<ImageStreamerType>(new MjpegStreamerType());
stream_types_["png"] = boost::shared_ptr<ImageStreamerType>(new PngStreamerType());
stream_types_["ros_compressed"] = boost::shared_ptr<ImageStreamerType>(new RosCompressedStreamerType());
Expand Down Expand Up @@ -124,7 +128,7 @@ bool WebVideoServer::handle_stream(const async_web_server_cpp::HttpRequest &requ
async_web_server_cpp::HttpConnectionPtr connection, const char* begin,
const char* end)
{
std::string type = request.get_query_param_value_or_default("type", "mjpeg");
std::string type = request.get_query_param_value_or_default("type", __default_stream_type);
if (stream_types_.find(type) != stream_types_.end())
{
boost::shared_ptr<ImageStreamer> streamer = stream_types_[type]->create_streamer(request, connection, nh_);
Expand Down