feat: add streamer-owned recording control service
Introduce a dedicated streamer-side recording control plane instead of sharing the producer recorder API. - register streamer-owned recorder endpoints as a NATS micro service - add explicit MP4 and MCAP recorder control protobufs and subject helpers - wire recorder lifecycle handling into the pipeline runtime - add MP4 writer and depth-alignment support files used by the new recording flow
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include "cvmmap_streamer/config/runtime_config.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace cvmmap_streamer::record {
|
||||
|
||||
inline constexpr int kDefaultMp4Quality = 23;
|
||||
|
||||
enum class Mp4InputPixelFormat : std::uint8_t {
|
||||
Bgr24,
|
||||
Rgb24,
|
||||
Bgra32,
|
||||
Rgba32,
|
||||
Gray8,
|
||||
};
|
||||
|
||||
struct Mp4EncodeTuning {
|
||||
int quality{kDefaultMp4Quality};
|
||||
std::uint32_t gop{30};
|
||||
std::uint32_t b_frames{0};
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
std::string_view input_pixel_format_name(Mp4InputPixelFormat pixel_format);
|
||||
|
||||
class Mp4RecordWriter {
|
||||
public:
|
||||
Mp4RecordWriter();
|
||||
Mp4RecordWriter(const Mp4RecordWriter &) = delete;
|
||||
Mp4RecordWriter &operator=(const Mp4RecordWriter &) = delete;
|
||||
Mp4RecordWriter(Mp4RecordWriter &&) noexcept;
|
||||
Mp4RecordWriter &operator=(Mp4RecordWriter &&) noexcept;
|
||||
~Mp4RecordWriter();
|
||||
|
||||
[[nodiscard]]
|
||||
std::expected<void, std::string> open(
|
||||
const std::filesystem::path &output_path,
|
||||
CodecType codec,
|
||||
EncoderDeviceType encoder_device,
|
||||
std::uint32_t width,
|
||||
std::uint32_t height,
|
||||
float fps,
|
||||
const Mp4EncodeTuning &tuning,
|
||||
Mp4InputPixelFormat input_pixel_format);
|
||||
|
||||
[[nodiscard]]
|
||||
std::expected<void, std::string> write_frame(
|
||||
const std::uint8_t *data,
|
||||
std::size_t row_stride_bytes,
|
||||
std::uint64_t relative_timestamp_ns);
|
||||
|
||||
[[nodiscard]]
|
||||
std::expected<void, std::string> flush();
|
||||
|
||||
[[nodiscard]]
|
||||
bool using_hardware() const;
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl_{};
|
||||
};
|
||||
|
||||
} // namespace cvmmap_streamer::record
|
||||
Reference in New Issue
Block a user