rtc-media 0.20.0

RTC Media in Rust
Documentation

Media samples and container I/O.

The bridge between encoded media and RTP: a codec-agnostic [Sample] type, and readers and writers for the container formats the examples and tests use.

Structure

  • [Sample] — one encoded unit of media (a video frame, an audio frame) with its duration, timestamp and packet metadata. Hand these to a sample-based local track and the RTP packetizer does the rest.
  • [io] — the Writer trait plus concrete readers and writers for IVF (VP8/VP9), Ogg (Opus) and H.264/H.265 Annex B — IVFReader, OggReader and friends — enough to play media from disk or record it to disk. SampleBuilder goes the other way, reassembling inbound RTP into [Sample]s.
  • [audio], [video] — per-codec helpers, including audio buffering and frame inspection.

Example

use bytes::Bytes;
use rtc_media::Sample;
use shared::time::SystemInstant;
use std::time::Duration;

// One encoded frame, ready to hand to a sample-based local track.
let sample = Sample {
    data: Bytes::from_static(&[0u8; 128]),
    timestamp: SystemInstant::now(),
    duration: Duration::from_millis(33), // ~30 fps
    ..Default::default()
};
assert_eq!(sample.data.len(), 128);

Most applications do not depend on this crate directly — the rtc crate re-exports it as rtc::media.