Skip to main content

CodecConfigTracker

Struct CodecConfigTracker 

Source
pub struct CodecConfigTracker { /* private fields */ }
Expand description

Tracks H.264 and H.265 parameter sets across access units.

Implementations§

Source§

impl CodecConfigTracker

Source

pub fn inspect( &mut self, codec: VideoCodec, data: &[u8], ) -> Result<(ConfigUpdate, bool), VideoError>

Inspect one access unit for both parameter-set changes and keyframes.

Decoder backends should prefer this method over calling Self::observe and Self::is_keyframe separately because it scans Annex-B only once.

Source

pub fn observe( &mut self, codec: VideoCodec, data: &[u8], ) -> Result<ConfigUpdate, VideoError>

Inspect an Annex-B access unit and update cached parameter sets.

Examples found in repository?
examples/inspect_annex_b.rs (line 18)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let mut args = env::args().skip(1);
7    let codec = match args.next().as_deref() {
8        Some("h264") => VideoCodec::H264,
9        Some("h265") | Some("hevc") => VideoCodec::H265,
10        _ => return Err("usage: inspect_annex_b <h264|h265> <access-unit-file>".into()),
11    };
12    let path = args
13        .next()
14        .ok_or("usage: inspect_annex_b <h264|h265> <access-unit-file>")?;
15    let data = fs::read(path)?;
16    let units = annex_b::nal_units(&data)?;
17    let mut tracker = CodecConfigTracker::default();
18    let config = tracker.observe(codec, &data)?;
19
20    println!(
21        "codec={codec} bytes={} nal_units={}",
22        data.len(),
23        units.len()
24    );
25    println!(
26        "configuration={}",
27        match config {
28            ConfigUpdate::Incomplete => "incomplete",
29            ConfigUpdate::Unchanged => "unchanged",
30            ConfigUpdate::Changed(_) => "complete",
31        }
32    );
33    Ok(())
34}
Source

pub fn config(&self, codec: VideoCodec) -> Option<&CodecConfig>

Return the latest complete configuration for codec.

Source

pub fn reset(&mut self)

Clear all cached parameter sets and active configuration.

Source

pub fn is_keyframe(codec: VideoCodec, data: &[u8]) -> Result<bool, VideoError>

Return true when the access unit contains a random-access NAL unit.

Trait Implementations§

Source§

impl Clone for CodecConfigTracker

Source§

fn clone(&self) -> CodecConfigTracker

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodecConfigTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CodecConfigTracker

Source§

fn default() -> CodecConfigTracker

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.