Skip to content

Commit

Permalink
Merge pull request #14 from julianoes/pr-usage-fixes
Browse files Browse the repository at this point in the history
Usage fixes
  • Loading branch information
julianoes authored Mar 7, 2024
2 parents 0a1c762 + 1e10963 commit a2736f2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
6 changes: 3 additions & 3 deletions camera-manager/camera_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ int main(int argc, char* argv[])
<< "\n"
<< "Usage: " << argv[0] << " <mavsdk connection url> <ground station connection url> <our ip>\n"
<< "\n"
<< "E.g. " << argv[0] << " serial:///dev/ttyUSB0:57600 udp://192.168.1.51:14550 192.168.1.45\n";
<< "E.g. " << argv[0] << " serial:///dev/ttyUSB0:57600 udp://192.168.1.51:14550 rtsp://192.168.1.45:8554/live\n";
return 1;
}

const std::string mavsdk_connection_url{argv[1]};
const std::string groundstation_connection_url{argv[2]};
const std::string our_ip{argv[3]};
const std::string rtsp_url{argv[3]};

// SIYI setup first
siyi::Messager siyi_messager;
Expand Down Expand Up @@ -155,7 +155,7 @@ int main(int argc, char* argv[])

ret = camera_server.set_video_streaming(mavsdk::CameraServer::VideoStreaming{
.has_rtsp_server = true,
.rtsp_uri = std::string{"rtsp://"} + our_ip + std::string{":8554/live"},
.rtsp_uri = rtsp_url,
});

if (ret != mavsdk::CameraServer::Result::Success) {
Expand Down
24 changes: 16 additions & 8 deletions camera-manager/siyi_camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Camera {
Res1280x720,
Res1920x1080,
Res2560x1440,
Res4096x2160,
Res3840x2160,
};

enum class Zoom {
Expand All @@ -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) {
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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<siyi::AckGetStreamResolution>(_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;
Expand Down
18 changes: 10 additions & 8 deletions camera-manager/siyi_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <option> Use zoom\n"
<< " Options:\n"
<< " - in (to start zooming in)\n"
<< " - out (to start zooming out)\n"
<< " - stop (to stop zooming)\n"
<< "\n"
<< " get <stream|recording> settings Show all settings for stream or recording\n\n"
<< "\n"
<< " set <stream|recording> resolution <option> Set stream resolution\n\n"
<< " Options:\n"
<< " - 720 (for 1280x720)\n"
<< " - 1080 (for 1920x1080)\n\n"
<< " - 1440 (for 2560x1440, recording only)\n\n"
<< " - 1080 (for 4096x1920, recording only)\n\n"
<< " - 1920 (for 3840x1920, recording only)\n\n"
<< " set <stream|recording> bitrate <option> Set stream bitrate\n"
<< " Options:\n"
<< " - 1m (for 1.5 Mbps, only available at 1280x720)\n"
Expand All @@ -29,11 +35,7 @@ void print_usage(const std::string_view& bin_name)
<< " Options:\n"
<< " - h264 (for H264)\n"
<< " - h265 (for H265/HVEC)\n"
<< " zoom <option> Use zoom\n"
<< " Options:\n"
<< " - in (to start zooming in)\n"
<< " - out (to start zooming out)\n"
<< " - stop (to stop zooming)\n";
<< "\n";
}

int main(int argc, char* argv[])
Expand Down Expand Up @@ -120,8 +122,8 @@ int main(int argc, char* argv[])

if (setting == "resolution") {
if (option == "1920") {
std::cout << "Set " << type_str << " resolution to 4096x2160..." << std::flush;
if (siyi_camera.set_resolution(type, siyi::Camera::Resolution::Res4096x2160)) {
std::cout << "Set " << type_str << " resolution to 3840x2160..." << std::flush;
if (siyi_camera.set_resolution(type, siyi::Camera::Resolution::Res3840x2160)) {
std::cout << "ok" << std::endl;
} else {
std::cout << "failed" << std::endl;
Expand Down

0 comments on commit a2736f2

Please sign in to comment.