Expand description
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— theWritertrait plus concrete readers and writers for IVF (VP8/VP9), Ogg (Opus) and H.264/H.265 Annex B —IVFReader,OggReaderand friends — enough to play media from disk or record it to disk.SampleBuildergoes the other way, reassembling inbound RTP intoSamples.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.
Modules§
- audio
- Audio sample types and multi-channel buffers.
- io
- Container readers and writers, plus RTP sample reassembly.
- video
- Video frame helpers.
Structs§
- Sample
- A Sample contains encoded media and timing information