Skip to content

Commit

Permalink
replace streaming operator with function to avoid conflicting definition
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Dec 31, 2024
1 parent 5ca1a08 commit ee98bdf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/CameraNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ CameraNode::CameraNode(const rclcpp::NodeOptions &options) : Node("camera", opti

const libcamera::Size size(get_parameter("width").as_int(), get_parameter("height").as_int());
if (size.isNull()) {
RCLCPP_INFO_STREAM(get_logger(), scfg);
RCLCPP_INFO_STREAM(get_logger(), list_format_sizes(scfg));
RCLCPP_WARN_STREAM(get_logger(),
"no dimensions selected, auto-selecting: \"" << scfg.size << "\"");
RCLCPP_WARN_STREAM(get_logger(), "set parameter 'width' or 'height' to silence this warning");
Expand All @@ -350,7 +350,7 @@ CameraNode::CameraNode(const rclcpp::NodeOptions &options) : Node("camera", opti
if (selected_scfg.pixelFormat != scfg.pixelFormat)
RCLCPP_INFO_STREAM(get_logger(), stream_formats);
if (selected_scfg.size != scfg.size)
RCLCPP_INFO_STREAM(get_logger(), scfg);
RCLCPP_INFO_STREAM(get_logger(), list_format_sizes(scfg));
RCLCPP_WARN_STREAM(get_logger(), "stream configuration adjusted from \""
<< selected_scfg.toString() << "\" to \"" << scfg.toString()
<< "\"");
Expand Down
8 changes: 5 additions & 3 deletions src/pretty_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <libcamera/stream.h>
#include <memory>
#include <optional>
#include <sstream>
#include <string>
#include <vector>

Expand Down Expand Up @@ -43,13 +44,14 @@ operator<<(std::ostream &out, const libcamera::StreamFormats &formats)
return out;
}

std::ostream &
operator<<(std::ostream &out, const libcamera::StreamConfiguration &configuration)
std::string
list_format_sizes(const libcamera::StreamConfiguration &configuration)
{
std::ostringstream out;
out << std::endl
<< ">> " << configuration.pixelFormat << " format sizes:";
for (const libcamera::Size &size : configuration.formats().sizes(configuration.pixelFormat))
out << std::endl
<< " - " << size.toString();
return out;
return out.str();
}
4 changes: 2 additions & 2 deletions src/pretty_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ operator<<(std::ostream &out, const libcamera::CameraManager &camera_manager);
std::ostream &
operator<<(std::ostream &out, const libcamera::StreamFormats &formats);

std::ostream &
operator<<(std::ostream &out, const libcamera::StreamConfiguration &configuration);
std::string
list_format_sizes(const libcamera::StreamConfiguration &configuration);

0 comments on commit ee98bdf

Please sign in to comment.