pub struct CodecConfigTracker { /* private fields */ }Expand description
Tracks H.264 and H.265 parameter sets across access units.
Implementations§
Source§impl CodecConfigTracker
impl CodecConfigTracker
Sourcepub fn inspect(
&mut self,
codec: VideoCodec,
data: &[u8],
) -> Result<(ConfigUpdate, bool), VideoError>
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.
Sourcepub fn observe(
&mut self,
codec: VideoCodec,
data: &[u8],
) -> Result<ConfigUpdate, VideoError>
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}Sourcepub fn config(&self, codec: VideoCodec) -> Option<&CodecConfig>
pub fn config(&self, codec: VideoCodec) -> Option<&CodecConfig>
Return the latest complete configuration for codec.
Sourcepub fn is_keyframe(codec: VideoCodec, data: &[u8]) -> Result<bool, VideoError>
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
impl Clone for CodecConfigTracker
Source§fn clone(&self) -> CodecConfigTracker
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CodecConfigTracker
impl Debug for CodecConfigTracker
Source§impl Default for CodecConfigTracker
impl Default for CodecConfigTracker
Source§fn default() -> CodecConfigTracker
fn default() -> CodecConfigTracker
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for CodecConfigTracker
impl RefUnwindSafe for CodecConfigTracker
impl Send for CodecConfigTracker
impl Sync for CodecConfigTracker
impl Unpin for CodecConfigTracker
impl UnsafeUnpin for CodecConfigTracker
impl UnwindSafe for CodecConfigTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more