68 lines
1.5 KiB
C++
68 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "cvmmap_streamer/config/runtime_config.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <span>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
namespace cvmmap_streamer::protocol {
|
|
|
|
struct RtpPublisherStats {
|
|
std::uint64_t access_units{0};
|
|
std::uint64_t access_unit_bytes{0};
|
|
std::uint64_t packets_sent{0};
|
|
std::uint64_t packets_dropped{0};
|
|
std::uint64_t bytes_sent{0};
|
|
std::uint64_t send_errors{0};
|
|
};
|
|
|
|
class UdpRtpPublisher {
|
|
public:
|
|
UdpRtpPublisher() = default;
|
|
~UdpRtpPublisher();
|
|
|
|
UdpRtpPublisher(const UdpRtpPublisher &) = delete;
|
|
UdpRtpPublisher &operator=(const UdpRtpPublisher &) = delete;
|
|
|
|
UdpRtpPublisher(UdpRtpPublisher &&other) noexcept;
|
|
UdpRtpPublisher &operator=(UdpRtpPublisher &&other) noexcept;
|
|
|
|
[[nodiscard]]
|
|
static std::expected<UdpRtpPublisher, std::string> create(const RuntimeConfig &config, CodecType codec);
|
|
|
|
void publish_access_unit(std::span<const std::uint8_t> access_unit, std::uint64_t pts_ns);
|
|
|
|
[[nodiscard]]
|
|
const RtpPublisherStats &stats() const;
|
|
|
|
[[nodiscard]]
|
|
std::string_view sdp_path() const;
|
|
|
|
[[nodiscard]]
|
|
std::string_view destination() const;
|
|
|
|
void log_metrics() const;
|
|
|
|
private:
|
|
int socket_fd_{-1};
|
|
std::string destination_host_{};
|
|
std::string destination_ip_{};
|
|
std::uint16_t destination_port_{0};
|
|
std::uint8_t payload_type_{96};
|
|
CodecType codec_{CodecType::H264};
|
|
std::uint16_t sequence_{0};
|
|
std::uint32_t ssrc_{0};
|
|
std::string sdp_path_{};
|
|
RtpPublisherStats stats_{};
|
|
|
|
sockaddr_storage endpoint_addr_{};
|
|
socklen_t endpoint_addr_len_{0};
|
|
};
|
|
|
|
}
|