Overview
RtpPusher is a C++ library that delivers H.264 (RFC 6184), H.265 (RFC 7798) and JPEG (RFC 2435) video over UDP, in three transport modes selectable per send() call:
rtp(default) — codec-specific RTP framing (RFC 6184 / RFC 7798 / RFC 2435).
mpegts — MPEG-2 Transport Stream over UDP per STANAG 4609 / MISB ST 1402, 7×188-byte TS packets per UDP datagram, with optional KLV metadata (MISB ST 0601) on its own PID.
mpegts-rtp — MPEG-2 TS encapsulated in RTP per MISB ST 1403 (RFC 2250, payload type 33), 7 TS packets per RTP packet.
The library parses each input frame, splits it into RFC-conformant packets and emits them on a single shared UDP socket via a single internal pacing thread. The application calls only send(); everything else — Annex B start-code parsing, FU-A / FU fragmentation, JPEG segment extraction, MPEG-TS muxing (PAT/PMT/PCR/PES), KLV Tag 2 / Tag 1 auto-refresh, RTP header construction, sequence numbers, the 90 kHz timestamp clock, HEVC parameter-set replay on every IDR, drop-oldest-frame back-pressure — is handled internally. The library has no third-party runtime dependencies. The example application bundles the VSourceFile (source code included) library to read H.264 / H.265 / JPEG frames from files. Note: B-frames are not supported — input streams must contain I-frames and P-frames only.
Documentation
Documentation: GO TO DOCUMENTATION
Simple interface
class RtpPusher
{
public:
/// Get the library version string.
static std::string getVersion();
/// Send a coded video frame (with optional user-data).
int send(uint8_t* data,
size_t size,
const std::string& fourcc,
std::string ip,
uint16_t port,
uint16_t userDataPort,
float fps,
size_t maxPayloadSize = 1420,
int targetBitrateKbps = 5000,
uint8_t* userData = nullptr,
size_t userDataSize = 0,
const std::string& streamType = "rtp");
/// Tear down all resources.
void stop();
};
Simple example
#include <iostream>
#include <thread>
#include <chrono>
#include "VSourceFile.h"
#include "RtpPusher.h"
int main()
{
// Open the input file (default 1280x720, 30 fps).
cr::video::VSourceFile source;
if (!source.openVSource("test.h264;1280;720;30"))
return -1;
// No init() / open() — the pusher allocates resources lazily on first send().
cr::rtp::RtpPusher rtpPusher;
cr::video::Frame frame;
while (true)
{
if (!source.getFrame(frame, 1000))
continue;
// Map the source's fourcc enum to the string accepted by send().
// The library uses "H265" (not "HEVC") for H.265.
std::string codec;
switch (frame.fourcc)
{
case cr::video::Fourcc::H264: codec = "H264"; break;
case cr::video::Fourcc::HEVC: codec = "H265"; break;
case cr::video::Fourcc::JPEG: codec = "JPEG"; break;
default: continue;
}
const float fps = 30.0f;
const uint16_t port = 7032;
const uint16_t userDataPort = 0; // embed metadata as SEI
const int maxPayloadSize = 1420;
const int targetBitrateKbps = 5000; // ~5 Mbps token-bucket pacing
const int rc = rtpPusher.send(frame.data,
static_cast<size_t>(frame.size), codec,
"127.0.0.1", port, userDataPort,
fps, maxPayloadSize, targetBitrateKbps);
}
// rtpPusher.stop() is called automatically by the destructor.
return 0;
}

