From 36e5d154008e16f094cf0402f7ed35701a1c4824 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Sun, 31 Oct 2021 18:28:10 +0100 Subject: [PATCH] Clean up main() --- src/main.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 60a1b22..e74a35c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include "camera.hpp" #if !defined(NDEBUG) # include +# include #endif #include #include @@ -21,22 +22,30 @@ std::ostream& operator<< (std::ostream& stream, const FrameFormat& value) { } //namespace mgs #endif +namespace { +#if !defined(NDEBUG) +void print_supported_frame_formats (const mgs::Camera& cam) { + const auto curr_frame_size = cam.frame_size(); + + std::cout << "Supported frame formats:\n"; + int count = 0; + for (const auto& size : cam.supported_frame_sizes()) { + std::cout << std::setw(2) << ++count << " - " << size; + + if (curr_frame_size == size) + std::cout << " *"; + std::cout << '\n'; + } +} +#endif +} //unnamed namespace + int main() { try { mgs::Camera cam("/dev/video0", {}, false); cam.set_frame_size({1280, 720, MjpegFormat}); - std::cout << mgs::FrameFormat{1280, 720, MjpegFormat} << '\n'; -#if !defined(NDEBUG) - const auto curr_frame_size = cam.frame_size(); - - for (const auto& size : cam.supported_frame_sizes()) { - std::cout << size; - if (curr_frame_size == size) - std::cout << " *"; - std::cout << '\n'; - } -#endif + print_supported_frame_formats(cam); cam.start_streaming(); std::vector my_frame;