Add encoded SHM passthrough support

This commit is contained in:
2026-03-27 10:43:34 +08:00
parent 0c9f0a944f
commit bb3ace43b7
8 changed files with 480 additions and 98 deletions
@@ -40,6 +40,12 @@ enum class EncoderDeviceType {
Software,
};
enum class InputVideoSource {
Auto,
Raw,
Encoded,
};
enum class McapCompression {
None,
Lz4,
@@ -49,6 +55,7 @@ enum class McapCompression {
struct InputConfig {
std::string uri{"cvmmap://default"};
std::string nats_url{"nats://localhost:4222"};
InputVideoSource video_source{InputVideoSource::Auto};
};
struct EncoderConfig {
@@ -125,6 +132,7 @@ 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);
+27
View File
@@ -51,6 +51,19 @@ enum class DepthUnit : std::uint8_t {
Meter = 2,
};
enum class EncodedCodec : std::uint8_t {
Unknown = 0,
H264 = 1,
H265 = 2,
};
enum class EncodedBitstreamFormat : std::uint8_t {
Unknown = 0,
AnnexB = 1,
};
constexpr std::uint16_t kEncodedFlagKeyframe = 0x0001u;
enum class ModuleStatus : std::int32_t {
Online = 0xa1,
Offline = 0xa0,
@@ -163,22 +176,36 @@ struct ControlResponseMessage {
struct ValidatedShmView {
FrameMetadata metadata;
DepthUnit depth_unit{DepthUnit::Unknown};
EncodedCodec encoded_codec{EncodedCodec::Unknown};
EncodedBitstreamFormat encoded_bitstream_format{EncodedBitstreamFormat::Unknown};
std::uint16_t encoded_flags{0};
std::uint16_t encoded_frame_rate_num{0};
std::uint16_t encoded_frame_rate_den{0};
std::uint64_t encoded_stream_pts_ns{0};
std::span<const std::uint8_t> payload;
std::span<const std::uint8_t> left;
std::optional<FrameInfo> depth_info{};
std::span<const std::uint8_t> depth{};
std::optional<FrameInfo> confidence_info{};
std::span<const std::uint8_t> confidence{};
std::span<const std::uint8_t> encoded_access_unit{};
};
struct CoherentSnapshot {
FrameMetadata metadata;
DepthUnit depth_unit{DepthUnit::Unknown};
EncodedCodec encoded_codec{EncodedCodec::Unknown};
EncodedBitstreamFormat encoded_bitstream_format{EncodedBitstreamFormat::Unknown};
std::uint16_t encoded_flags{0};
std::uint16_t encoded_frame_rate_num{0};
std::uint16_t encoded_frame_rate_den{0};
std::uint64_t encoded_stream_pts_ns{0};
std::span<const std::uint8_t> left;
std::optional<FrameInfo> depth_info{};
std::span<const std::uint8_t> depth{};
std::optional<FrameInfo> confidence_info{};
std::span<const std::uint8_t> confidence{};
std::span<const std::uint8_t> encoded_access_unit{};
std::size_t bytes_copied;
};