Uncompressed Video

Uncompressed video provides the lowest latency and highest quality at the cost of higher bandwidth requirements.

Colorspaces

RGB24

Standard 24-bit RGB color representation.

  • 8 bits per red, green, and blue channel
  • 3 bytes per pixel
  • Best for: Computer graphics, display output
#include "rtp/rtp.h"
#include "uncompressed/rtp_uncompressed_payloader.h"

mediax::rtp::uncompressed::RtpUncompressedPayloader payloader;

mediax::rtp::StreamInformation stream_info;
stream_info.session_name = "rgb-stream";
stream_info.hostname = "239.192.1.1";
stream_info.port = 5004;
stream_info.width = 1920;
stream_info.height = 1080;
stream_info.framerate = 30;
stream_info.encoding = mediax::rtp::ColourspaceType::kColourspaceRgb24;

payloader.SetStreamInfo(stream_info);
payloader.Open();

// RGB24 buffer: width * height * 3 bytes
std::vector<uint8_t> buffer(1920 * 1080 * 3);
payloader.Transmit(buffer.data(), true);

payloader.Close();

YUV422 (YCbCr 4:2:2)

Chroma-subsampled color format commonly used in video.

  • Luma (Y) at full resolution
  • Chroma (Cb, Cr) at half horizontal resolution
  • 2 bytes per pixel (UYVY packing)
  • Best for: Broadcast video, cameras
stream_info.encoding = mediax::rtp::ColourspaceType::kColourspaceYuv422;

// YUV422 buffer: width * height * 2 bytes
std::vector<uint8_t> buffer(1920 * 1080 * 2);

Mono8

8-bit grayscale.

  • 1 byte per pixel
  • 256 gray levels
  • Best for: Thermal cameras, infrared sensors
stream_info.encoding = mediax::rtp::ColourspaceType::kColourspaceMono8;

// Mono8 buffer: width * height bytes
std::vector<uint8_t> buffer(1920 * 1080);

Mono16

16-bit grayscale for high dynamic range.

  • 2 bytes per pixel
  • 65,536 gray levels
  • Best for: Scientific imaging, medical imaging
stream_info.encoding = mediax::rtp::ColourspaceType::kColourspaceMono16;

// Mono16 buffer: width * height * 2 bytes
std::vector<uint8_t> buffer(1920 * 1080 * 2);

Bandwidth Requirements

Format Resolution Framerate Bandwidth
RGB24 640x480 30 fps ~221 Mbps
RGB24 1920x1080 30 fps ~1.49 Gbps
YUV422 640x480 30 fps ~147 Mbps
YUV422 1920x1080 30 fps ~995 Mbps
Mono8 640x480 30 fps ~74 Mbps
Mono8 1920x1080 30 fps ~498 Mbps

Network Considerations

MTU Size

Default Ethernet MTU is 1500 bytes. For high-resolution video, consider:

  • Jumbo frames (9000 bytes) for local networks
  • RTP packetization handles fragmentation automatically

Multicast

For multiple receivers, use multicast addresses:

stream_info.hostname = "239.192.1.1";  // Multicast address

Multicast address ranges:

  • 239.192.0.0/16 - Organization-local scope (recommended)
  • 239.255.0.0/16 - Site-local scope

Receiving Uncompressed Video

#include "uncompressed/rtp_uncompressed_depayloader.h"

mediax::rtp::uncompressed::RtpUncompressedDepayloader depayloader;

mediax::rtp::StreamInformation stream_info;
stream_info.hostname = "239.192.1.1";
stream_info.port = 5004;
stream_info.width = 1920;
stream_info.height = 1080;
stream_info.encoding = mediax::rtp::ColourspaceType::kColourspaceRgb24;

depayloader.SetStreamInfo(stream_info);
depayloader.Open();
depayloader.Start();

// Receive with callback
depayloader.RegisterCallback([](const mediax::rtp::RtpFrameData& frame) {
    // Process frame.cpu_buffer
    std::cout << "Frame received: " 
              << frame.resolution.width << "x" 
              << frame.resolution.height << std::endl;
});

// Or poll for frames
std::vector<uint8_t> buffer(1920 * 1080 * 3);
depayloader.Receive(buffer.data(), 1000);  // 1 second timeout

depayloader.Stop();
depayloader.Close();

Support