34 lines
813 B
C++
34 lines
813 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <span>
|
|
#include <vector>
|
|
|
|
namespace sc {
|
|
|
|
// Minimal RTP header (RFC 3550) without extensions.
|
|
struct RtpHeader {
|
|
uint8_t version = 2;
|
|
bool padding = false;
|
|
bool extension = false;
|
|
uint8_t csrc_count = 0;
|
|
bool marker = false;
|
|
uint7_t payload_type = 96; // dynamic
|
|
uint16_t sequence_number = 0;
|
|
uint32_t timestamp = 0;
|
|
uint32_t ssrc = 0;
|
|
|
|
bool serialize ( std::span<std::byte, 12> out ) const noexcept;
|
|
static std::optional<RtpHeader> parse ( std::span<const std::byte, 12> in ) noexcept;
|
|
};
|
|
|
|
struct RtpPacket {
|
|
RtpHeader header;
|
|
std::vector<std::byte> payload;
|
|
|
|
std::vector<std::byte> serialize () const;
|
|
static std::optional<RtpPacket> parse ( std::span<const std::byte> in ) noexcept;
|
|
};
|
|
|
|
} // namespace sc
|