rtciv0.5.0

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.

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.

  • modaudioAudio sample types and multi-channel buffers.
  • modioContainer readers and writers, plus RTP sample reassembly.
  • modvideoVideo frame helpers.
  • structSampleA Sample contains encoded media and timing information

rtci_media::audio

Audio sample types and multi-channel buffers.

  • modbufferMulti-channel audio buffers in interleaved or deinterleaved layout.
  • structSamplefrom sample::SampleOne audio sample of raw type Raw (i16, f32, …).

rtci_media::audio::buffer

Multi-channel audio buffers in interleaved or deinterleaved layout.

  • modinfoChannel and frame counts for a buffer.
  • modlayoutThe interleaved and deinterleaved buffer layouts.
  • structBufferBuffer multi-channel interlaced Audio.
  • structBufferRefA borrowed view of multi-channel audio: samples of type T in layout L.
  • enumErrorErrors from converting between buffers and raw bytes.
  • traitFromBytesDecodes a buffer from raw little- or big-endian bytes.
  • traitToByteBufferRefEncodes a buffer into raw bytes in a caller-chosen endianness.
  • useBufferInfofrom info::BufferInfoThe channel and frame counts of a buffer, tagged with its layout L.
  • useBufferLayoutfrom layout::BufferLayoutHow multi-channel samples are arranged in a flat buffer.

rtci_media::audio::buffer::info

Channel and frame counts for a buffer.

  • structBufferInfoThe channel and frame counts of a buffer, tagged with its layout L.

rtci_media::audio::buffer::layout

The interleaved and deinterleaved buffer layouts.

  • enumDeinterleavedChannels stored one after another: all of channel 0, then all of channel 1.
  • enumInterleavedFrames stored one after another, each holding one sample per channel.
  • traitBufferLayoutHow multi-channel samples are arranged in a flat buffer.

rtci_media::io

Container readers and writers, plus RTP sample reassembly.

  • modh26x_readerReads H.264/H.265 Annex B byte streams into NAL units.
  • modh26x_writerWrites H.264/H.265 Annex B byte streams.
  • modivf_readerReads IVF files, the simple container used for VP8, VP9 and AV1.
  • modivf_writerWrites IVF files.
  • modogg_readerReads Ogg files carrying Opus audio.
  • modogg_writerWrites Ogg files carrying Opus audio.
  • modsample_builderReassembles inbound RTP packets into complete media samples.
  • traitWriterA sink for RTP packets, such as a file in a container format.
  • typeResetFnA 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.

  • modsample_readerReads Annex B streams as whole samples rather than individual NAL units.
  • structH264NALNAL H.264 Network Abstraction Layer
  • structH265NALNAL H.265/HEVC Network Abstraction Layer H.265 uses a 2-byte NAL unit header
  • structH26xReaderH26xReader reads data from stream and constructs H264 or H265 NAL units based on the is_hevc flag
  • enumH264NalUnitTypeH264NalUnitType is the type of a NAL Enums for H264NalUnitType
  • enumH265NalUnitTypeH265NalUnitType is the type of a NAL unit in H.265/HEVC Based on ITU-T H.265 (04/2013) Table 7-1
  • enumH26xNALH26xNAL represents either an H264 or H265 NAL unit
  • useH26xSamplefrom sample_reader::H26xSampleOne access unit read from an Annex B stream — the NAL units making up a single frame.
  • useH26xSampleReaderfrom sample_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.

  • structH26xSampleOne access unit read from an Annex B stream — the NAL units making up a single frame.
  • structH26xSampleReaderReads whole access units from an H.264 or H.265 Annex B stream.
  • constMAX_ACCESS_UNIT_BYTESThe most bytes one access unit may hold, start codes excluded.
  • constMAX_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.

  • structH26xWriterH26xWriter 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.
  • constMAX_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.

rtci_media::io::ivf_writer

Writes IVF files.

  • structIVFWriterIVFWriter is used to take RTP packets and write them to an IVF on disk
  • enumIvfCodecCodec type for IVF writer
  • constMAX_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.

  • structOggHeaderOggHeader is the metadata from the first two pages in the file (ID and Comment) <https://tools.ietf.org/html/rfc7845.html#section-3>
  • structOggPageHeaderOggPageHeader 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>
  • structOggReaderOggReader is used to read Ogg files and return page payloads, or the packets they carry
  • structOpusTagsOpusTags contains Vorbis comment metadata from an OpusTags page <https://www.xiph.org/vorbis/doc/v-comment.html>
  • structUserCommentA key-value pair from Vorbis comments
  • enumOggHeaderTypeHeader type classification for Opus pages
  • fnparse_opus_headParse an OpusHead from a page payload <https://tools.ietf.org/html/rfc7845.html#section-5.1>
  • fnparse_opus_tagsParse OpusTags from a page payload <https://tools.ietf.org/html/rfc7845.html#section-5.2>
  • constCOMMENT_PAGE_SIGNATUREThe signature of the Opus comment header.
  • constDEFAULT_PRE_SKIPThe recommended Opus pre-skip: 3840 samples (80 ms at 48 kHz) of decoder warm-up to discard.
  • constID_PAGE_PAYLOAD_SIZEThe size of the OpusHead payload in bytes.
  • constID_PAGE_SIGNATUREThe signature of the Opus identification header.
  • constPAGE_HEADER_FLAG_CONTINUED_PACKETPage header flag bit: the page's first packet continues the previous page's last one.
  • constPAGE_HEADER_SIGNATUREThe four-byte signature that begins every Ogg page.
  • constPAGE_HEADER_SIZEThe fixed part of an Ogg page header, in bytes, before the segment table.
  • constPAGE_HEADER_TYPE_BEGINNING_OF_STREAMPage header flag: the first page of a logical stream.
  • constPAGE_HEADER_TYPE_CONTINUATION_OF_STREAMPage header flag: this page continues a packet from the previous page.
  • constPAGE_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.

  • structOggWriterOggWriter 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.

  • modsample_sequence_locationTracks where a sample sits within the RTP sequence-number space.
  • structSampleBuilderSampleBuilder buffers packets until media frames are complete.
  • constDEFAULT_MAX_GAP_WAITHow long a SampleBuilder of 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.