110 lines
2.5 KiB
C++
110 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "cvmmap_streamer/ipc/contracts.hpp"
|
|
|
|
namespace cvmmap_streamer {
|
|
|
|
enum class CodecType {
|
|
H264,
|
|
H265,
|
|
};
|
|
|
|
enum class RunMode {
|
|
Pipeline,
|
|
Ingest,
|
|
};
|
|
|
|
enum class InputMode {
|
|
Real,
|
|
Dummy,
|
|
};
|
|
|
|
enum class RtmpMode {
|
|
Enhanced,
|
|
Domestic,
|
|
};
|
|
|
|
struct InputConfig {
|
|
std::string shm_name{"cvmmap_default"};
|
|
std::string zmq_endpoint{"ipc:///tmp/cvmmap_default"};
|
|
};
|
|
|
|
struct DummyInputConfig {
|
|
std::uint32_t frames{0};
|
|
std::uint32_t fps{60};
|
|
std::uint16_t width{64};
|
|
std::uint16_t height{48};
|
|
std::optional<std::uint32_t> emit_reset_at{};
|
|
std::optional<std::uint32_t> emit_reset_every{};
|
|
std::string label{"dummy"};
|
|
std::uint8_t channels{3};
|
|
ipc::Depth depth{ipc::Depth::U8};
|
|
ipc::PixelFormat pixel_format{ipc::PixelFormat::BGR};
|
|
std::uint64_t start_timestamp_ns{1'000'000'000ull};
|
|
std::uint32_t startup_delay_ms{100};
|
|
};
|
|
|
|
struct RtmpOutputConfig {
|
|
bool enabled{false};
|
|
std::vector<std::string> urls{};
|
|
RtmpMode mode{RtmpMode::Enhanced};
|
|
};
|
|
|
|
struct RtpOutputConfig {
|
|
bool enabled{false};
|
|
std::optional<std::string> endpoint{std::nullopt};
|
|
std::optional<std::string> host{std::nullopt};
|
|
std::optional<std::uint16_t> port{std::nullopt};
|
|
std::uint8_t payload_type{96};
|
|
std::optional<std::string> sdp_path{std::nullopt};
|
|
};
|
|
|
|
struct OutputsConfig {
|
|
RtmpOutputConfig rtmp{};
|
|
RtpOutputConfig rtp{};
|
|
};
|
|
|
|
struct LatencyConfig {
|
|
std::size_t queue_size{1};
|
|
std::uint32_t gop{30};
|
|
std::uint32_t b_frames{0};
|
|
bool realtime_sync{true};
|
|
bool force_idr_on_reset{true};
|
|
std::uint32_t ingest_max_frames{0};
|
|
std::uint32_t ingest_idle_timeout_ms{1000};
|
|
std::uint32_t ingest_consumer_delay_ms{0};
|
|
std::uint32_t snapshot_copy_delay_us{0};
|
|
std::uint32_t emit_stall_ms{0};
|
|
};
|
|
|
|
struct RuntimeConfig {
|
|
InputConfig input{};
|
|
DummyInputConfig dummy{};
|
|
InputMode input_mode{InputMode::Real};
|
|
RunMode run_mode{RunMode::Pipeline};
|
|
CodecType codec{CodecType::H264};
|
|
OutputsConfig outputs{};
|
|
LatencyConfig latency{};
|
|
|
|
static RuntimeConfig defaults();
|
|
};
|
|
|
|
std::string_view to_string(CodecType codec);
|
|
std::string_view to_string(RunMode mode);
|
|
std::string_view to_string(InputMode mode);
|
|
std::string_view to_string(RtmpMode mode);
|
|
|
|
std::expected<RuntimeConfig, std::string> parse_runtime_config(int argc, char **argv);
|
|
std::expected<void, std::string> validate_runtime_config(const RuntimeConfig &config);
|
|
std::string summarize_runtime_config(const RuntimeConfig &config);
|
|
|
|
}
|