rtci-media
Media samples and container readers and writers (IVF, Ogg Opus, H.264 / H.265 Annex B) for WebRTC. 16 public modules, 74 items at 0.5.0.
cargo add [email protected] · crates.io · docs.rs · README on GitHub· MSRV 1.89
README
Media samples and container I/O for WebRTC: a codec-agnostic Sample (one encoded frame with its duration and timestamp), readers and writers for IVF (VP8, VP9, AV1), Ogg (Opus) and H.264 / H.265 Annex B streams, and the audio and video helpers the examples use. It does not encode, decode, capture or play media.
Specifications
- RFC 6184 and RFC 7798, the H.264 and H.265 NAL unit structure the Annex B readers split on
- The IVF and Ogg container formats (not IETF payload formats)
Clause-by-clause status, with the test that proves each clause: rfc6184, rfc7798.
Use
Sample goes to a sample-based track of the root crate (rtci), whose packetizers in rtci-rtp make the RTP payloads. io has the readers and writers (io::ivf_reader::IVFReader, io::ogg_reader::OggReader, io::h26x_reader::H26xReader, and their writers); the root crate's play-from-disk-* and save-to-disk-* examples use them.
Sans-I/O
The readers and writers work on any std::io::Read / Write the caller gives them; the crate opens no file or socket itself and reads no clock.
Licence
Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.
This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.
rtci_media
Media samples and container I/O.
rtci_media::audio
Audio sample types and multi-channel buffers.
rtci_media::audio::buffer
Multi-channel audio buffers in interleaved or deinterleaved layout.
- mod
infoChannel and frame counts for a buffer. - mod
layoutThe interleaved and deinterleaved buffer layouts. - struct
BufferBuffer multi-channel interlaced Audio. - struct
BufferRefA borrowed view of multi-channel audio: samples of typeTin layoutL. - enum
ErrorErrors from converting between buffers and raw bytes. - trait
FromBytesDecodes a buffer from raw little- or big-endian bytes. - trait
ToByteBufferRefEncodes a buffer into raw bytes in a caller-chosen endianness. - use
BufferInfofrominfo::BufferInfoThe channel and frame counts of a buffer, tagged with its layoutL. - use
BufferLayoutfromlayout::BufferLayoutHow multi-channel samples are arranged in a flat buffer.
rtci_media::audio::buffer::info
Channel and frame counts for a buffer.
- struct
BufferInfoThe channel and frame counts of a buffer, tagged with its layoutL.
rtci_media::audio::buffer::layout
The interleaved and deinterleaved buffer layouts.
- enum
DeinterleavedChannels stored one after another: all of channel 0, then all of channel 1. - enum
InterleavedFrames stored one after another, each holding one sample per channel. - trait
BufferLayoutHow multi-channel samples are arranged in a flat buffer.
rtci_media::io
Container readers and writers, plus RTP sample reassembly.
- mod
h26x_readerReads H.264/H.265 Annex B byte streams into NAL units. - mod
h26x_writerWrites H.264/H.265 Annex B byte streams. - mod
ivf_readerReads IVF files, the simple container used for VP8, VP9 and AV1. - mod
ivf_writerWrites IVF files. - mod
ogg_readerReads Ogg files carrying Opus audio. - mod
ogg_writerWrites Ogg files carrying Opus audio. - mod
sample_builderReassembles inbound RTP packets into complete media samples. - trait
WriterA sink for RTP packets, such as a file in a container format. - type
ResetFnA callback that produces a fresh reader or writer, used to restart a stream.
rtci_media::io::h26x_reader
Reads H.264/H.265 Annex B byte streams into NAL units.
- mod
sample_readerReads Annex B streams as whole samples rather than individual NAL units. - struct
H264NALNAL H.264 Network Abstraction Layer - struct
H265NALNAL H.265/HEVC Network Abstraction Layer H.265 uses a 2-byte NAL unit header - struct
H26xReaderH26xReader reads data from stream and constructs H264 or H265 NAL units based on the is_hevc flag - enum
H264NalUnitTypeH264NalUnitType is the type of a NAL Enums for H264NalUnitType - enum
H265NalUnitTypeH265NalUnitType is the type of a NAL unit in H.265/HEVC Based on ITU-T H.265 (04/2013) Table 7-1 - enum
H26xNALH26xNAL represents either an H264 or H265 NAL unit - use
H26xSamplefromsample_reader::H26xSampleOne access unit read from an Annex B stream — the NAL units making up a single frame. - use
H26xSampleReaderfromsample_reader::H26xSampleReaderReads whole access units from an H.264 or H.265 Annex B stream.
rtci_media::io::h26x_reader::sample_reader
Reads Annex B streams as whole samples rather than individual NAL units.
- struct
H26xSampleOne access unit read from an Annex B stream — the NAL units making up a single frame. - struct
H26xSampleReaderReads whole access units from an H.264 or H.265 Annex B stream. - const
MAX_ACCESS_UNIT_BYTESThe most bytes one access unit may hold, start codes excluded. - const
MAX_ACCESS_UNIT_NALSThe most NAL units one access unit may hold.
rtci_media::io::h26x_writer
Writes H.264/H.265 Annex B byte streams.
- struct
H26xWriterH26xWriter is used to take RTP packets, parse them and write the data to an io.Writer. Supports both H264 and H265 codecs based on the is_hevc flag. - const
MAX_H265_FU_NALU_SIZELargest H.265 NAL unit reassembled from fragmentation units, as for H.264 FU-A (rtp::codec::h264::MAX_FUA_NALU_SIZE). The depacketizer enforces it (rtp::codec::h265::MAX_H265_FU_NALU_SIZE, the same value).
rtci_media::io::ivf_reader
Reads IVF files, the simple container used for VP8, VP9 and AV1.
- struct
IVFFileHeaderIVFFileHeader 32-byte header for IVF files <https://wiki.multimedia.cx/index.php/IVF> - struct
IVFFrameHeaderIVFFrameHeader 12-byte header for IVF frames <https://wiki.multimedia.cx/index.php/IVF> - struct
IVFReaderIVFReader is used to read IVF files and return frame payloads - const
IVF_FILE_HEADER_SIGNATUREThe four-byte signature every IVF file starts with. - const
IVF_FILE_HEADER_SIZEThe size of the IVF file header in bytes. - const
IVF_FRAME_HEADER_SIZEThe size of each IVF frame header in bytes.
rtci_media::io::ivf_writer
Writes IVF files.
- struct
IVFWriterIVFWriter is used to take RTP packets and write them to an IVF on disk - enum
IvfCodecCodec type for IVF writer - const
MAX_IVF_FRAME_SIZELargest frame assembled from RTP packets. Far above any real VP8/VP9/AV1 frame; a peer that never sets the marker bit must not grow the frame buffer without limit.
rtci_media::io::ogg_reader
Reads Ogg files carrying Opus audio.
- struct
OggHeaderOggHeader is the metadata from the first two pages in the file (ID and Comment) <https://tools.ietf.org/html/rfc7845.html#section-3> - struct
OggPageHeaderOggPageHeader is the metadata for a Page Pages are the fundamental unit of multiplexing in an Ogg stream <https://tools.ietf.org/html/rfc7845.html#section-1> - struct
OggReaderOggReader is used to read Ogg files and return page payloads, or the packets they carry - struct
OpusTagsOpusTags contains Vorbis comment metadata from an OpusTags page <https://www.xiph.org/vorbis/doc/v-comment.html> - struct
UserCommentA key-value pair from Vorbis comments - enum
OggHeaderTypeHeader type classification for Opus pages - fn
parse_opus_headParse an OpusHead from a page payload <https://tools.ietf.org/html/rfc7845.html#section-5.1> - fn
parse_opus_tagsParse OpusTags from a page payload <https://tools.ietf.org/html/rfc7845.html#section-5.2> - const
COMMENT_PAGE_SIGNATUREThe signature of the Opus comment header. - const
DEFAULT_PRE_SKIPThe recommended Opus pre-skip: 3840 samples (80 ms at 48 kHz) of decoder warm-up to discard. - const
ID_PAGE_PAYLOAD_SIZEThe size of theOpusHeadpayload in bytes. - const
ID_PAGE_SIGNATUREThe signature of the Opus identification header. - const
PAGE_HEADER_FLAG_CONTINUED_PACKETPage header flag bit: the page's first packet continues the previous page's last one. - const
PAGE_HEADER_SIGNATUREThe four-byte signature that begins every Ogg page. - const
PAGE_HEADER_SIZEThe fixed part of an Ogg page header, in bytes, before the segment table. - const
PAGE_HEADER_TYPE_BEGINNING_OF_STREAMPage header flag: the first page of a logical stream. - const
PAGE_HEADER_TYPE_CONTINUATION_OF_STREAMPage header flag: this page continues a packet from the previous page. - const
PAGE_HEADER_TYPE_END_OF_STREAMPage header flag: the last page of a logical stream.
rtci_media::io::ogg_writer
Writes Ogg files carrying Opus audio.
- struct
OggWriterOggWriter is used to take RTP packets and write them to an OGG on disk
rtci_media::io::sample_builder
Reassembles inbound RTP packets into complete media samples.
- mod
sample_sequence_locationTracks where a sample sits within the RTP sequence-number space. - struct
SampleBuilderSampleBuilder buffers packets until media frames are complete. - const
DEFAULT_MAX_GAP_WAITHow long aSampleBuilderof a format with key frames (Depacketizer::has_key_frames) waits for a missing packet unless told otherwise (SampleBuilder::with_max_gap_wait).
rtci_media::io::sample_builder::sample_sequence_location
Tracks where a sample sits within the RTP sequence-number space.
No public items at its top level.
rtci_media::video
Video frame helpers.
No public items at its top level.
Generated from the sources of rtci-media 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.