965b03c053
Preserve RTP/RTMP session continuity across upstream stream_reset events by forcing a keyframe on restart, remapping live timestamps, and keeping live outputs open when the runtime requests reset continuity. Disable idle auto-exit by default by changing ingest_idle_timeout_ms to 0, removing validation that rejected 0, and only enforcing idle shutdown when a positive timeout is configured in pipeline and ingest loops. Also suppress libavformat FLV trailer header backfill attempts on RTMP sockets and update the RTP output tester for the newer publisher create signature. Docs are updated to state that 0 disables the idle timeout.
145 lines
3.3 KiB
C++
145 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace cvmmap_streamer {
|
|
|
|
enum class CodecType {
|
|
H264,
|
|
H265,
|
|
};
|
|
|
|
enum class RunMode {
|
|
Pipeline,
|
|
Ingest,
|
|
};
|
|
|
|
enum class RtmpMode {
|
|
Enhanced,
|
|
};
|
|
|
|
enum class RtmpTransportType {
|
|
Libavformat,
|
|
FfmpegProcess,
|
|
};
|
|
|
|
enum class EncoderBackendType {
|
|
Auto,
|
|
FFmpeg,
|
|
};
|
|
|
|
enum class EncoderDeviceType {
|
|
Auto,
|
|
Nvidia,
|
|
Software,
|
|
};
|
|
|
|
enum class InputVideoSource {
|
|
Auto,
|
|
Raw,
|
|
Encoded,
|
|
};
|
|
|
|
enum class McapCompression {
|
|
None,
|
|
Lz4,
|
|
Zstd,
|
|
};
|
|
|
|
struct InputConfig {
|
|
std::string uri{"cvmmap://default"};
|
|
std::string nats_url{"nats://localhost:4222"};
|
|
InputVideoSource video_source{InputVideoSource::Auto};
|
|
};
|
|
|
|
struct EncoderConfig {
|
|
EncoderBackendType backend{EncoderBackendType::Auto};
|
|
EncoderDeviceType device{EncoderDeviceType::Auto};
|
|
CodecType codec{CodecType::H264};
|
|
std::uint32_t gop{30};
|
|
std::uint32_t b_frames{0};
|
|
};
|
|
|
|
struct RtmpOutputConfig {
|
|
bool enabled{false};
|
|
std::vector<std::string> urls{};
|
|
RtmpTransportType transport{RtmpTransportType::Libavformat};
|
|
std::string ffmpeg_path{"ffmpeg"};
|
|
};
|
|
|
|
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 McapRecordConfig {
|
|
bool enabled{false};
|
|
std::string path{"capture.mcap"};
|
|
std::string topic{"/camera/video"};
|
|
std::string depth_topic{"/camera/depth"};
|
|
std::string calibration_topic{"/camera/calibration"};
|
|
std::string depth_calibration_topic{"/camera/depth_calibration"};
|
|
std::string pose_topic{"/camera/pose"};
|
|
std::string body_topic{"/camera/body"};
|
|
std::string frame_id{"camera"};
|
|
McapCompression compression{McapCompression::Zstd};
|
|
};
|
|
|
|
struct RecordConfig {
|
|
McapRecordConfig mcap{};
|
|
};
|
|
|
|
struct LatencyConfig {
|
|
std::size_t queue_size{1};
|
|
bool realtime_sync{true};
|
|
bool force_idr_on_reset{true};
|
|
bool keep_stream_on_reset{false};
|
|
std::uint32_t ingest_max_frames{0};
|
|
std::uint32_t ingest_idle_timeout_ms{0};
|
|
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{};
|
|
RunMode run_mode{RunMode::Pipeline};
|
|
EncoderConfig encoder{};
|
|
OutputsConfig outputs{};
|
|
RecordConfig record{};
|
|
LatencyConfig latency{};
|
|
|
|
static RuntimeConfig defaults();
|
|
};
|
|
|
|
std::string_view to_string(CodecType codec);
|
|
std::string_view to_string(RunMode mode);
|
|
std::string_view to_string(RtmpMode mode);
|
|
std::string_view to_string(RtmpTransportType transport);
|
|
std::string_view to_string(EncoderBackendType backend);
|
|
std::string_view to_string(EncoderDeviceType device);
|
|
std::string_view to_string(InputVideoSource source);
|
|
std::string_view to_string(McapCompression compression);
|
|
std::expected<McapCompression, std::string> parse_mcap_compression(std::string_view raw);
|
|
|
|
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);
|
|
|
|
}
|