From 17e3df7f3bd55967c4a5df711c32aa5e8a3e7e96 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 8 Mar 2024 06:30:05 +1300 Subject: [PATCH 1/2] camera-manager: usage fixes Signed-off-by: Julian Oes --- camera-manager/siyi_camera.hpp | 24 ++++++++++++++++-------- camera-manager/siyi_cli.cpp | 18 ++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/camera-manager/siyi_camera.hpp b/camera-manager/siyi_camera.hpp index c69f8c6..fb544a3 100644 --- a/camera-manager/siyi_camera.hpp +++ b/camera-manager/siyi_camera.hpp @@ -72,7 +72,7 @@ class Camera { Res1280x720, Res1920x1080, Res2560x1440, - Res4096x2160, + Res3840x2160, }; enum class Zoom { @@ -96,8 +96,8 @@ class Camera { } [[nodiscard]] Resolution resolution() const { - if (_stream_settings.resolution_h == 1920 && _stream_settings.resolution_l == 4096) { - return Resolution::Res4096x2160; + if (_stream_settings.resolution_h == 1920 && _stream_settings.resolution_l == 3840) { + return Resolution::Res3840x2160; } else if (_stream_settings.resolution_h == 1440 && _stream_settings.resolution_l == 2560) { return Resolution::Res2560x1440; } else if (_stream_settings.resolution_h == 1080 && _stream_settings.resolution_l == 1920) { @@ -133,8 +133,8 @@ class Camera { } else if (resolution == Resolution::Res2560x1440) { set_stream_settings.resolution_l = 2560; set_stream_settings.resolution_h = 1440; - } else if (resolution == Resolution::Res4096x2160) { - set_stream_settings.resolution_l = 4096; + } else if (resolution == Resolution::Res3840x2160) { + set_stream_settings.resolution_l = 3840; set_stream_settings.resolution_h = 2160; } else { std::cerr << "resolution invalid\n"; @@ -268,13 +268,21 @@ class Camera { return false; } - _messager.send(_serializer.assemble_message(siyi::GetStreamSettings{})); + auto get_stream_settings = siyi::GetStreamSettings{}; + get_stream_settings.stream_type = set_stream_settings.stream_type; + _messager.send(_serializer.assemble_message(get_stream_settings)); const auto maybe_stream_settings = _deserializer.disassemble_message(_messager.receive()); if (maybe_stream_settings) { - - _stream_settings = maybe_stream_settings.value(); + switch (type) { + case Type::Recording: + _recording_settings = maybe_stream_settings.value(); + break; + case Type::Stream: + _stream_settings = maybe_stream_settings.value(); + break; + } return true; } else { return false; diff --git a/camera-manager/siyi_cli.cpp b/camera-manager/siyi_cli.cpp index 895861e..a55f624 100644 --- a/camera-manager/siyi_cli.cpp +++ b/camera-manager/siyi_cli.cpp @@ -11,14 +11,20 @@ void print_usage(const std::string_view& bin_name) << " take_picture Take a picture to SD card\n\n" << " toggle_recording Toggle start/stop video recording to SD card\n\n" << " gimbal_forward Set gimbal forward\n\n" + << " zoom