Skip to main content

TSAnalyzer

Struct TSAnalyzer 

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

A !Send + !Sync owner of TSDuck’s version-matched TSAnalyzer adapter.

The native analyzer is destroyed before its retained DuckContext. All snapshots are fully owned Rust values; no TSDuck model references escape.

§Stability

TSDuck exposes no stable public API for analysis statistics: the public ts::TSAnalyzer surface only covers feeding, reset, options, and PID/service identifier lists. The per-PID and per-service statistics live in protected members that TSDuck documents as accessible to subclasses. This adapter reads that protected, version-matched state, so a TSDuck change to those fields can break the build or change reported values. Only TSDuck 3.44.x is supported.

Implementations§

Source§

impl TSAnalyzer

Source

pub fn new(context: Rc<DuckContext>) -> Result<Self>

Creates an analyzer retaining context for its full native lifetime.

Source

pub fn context(&self) -> &Rc<DuckContext>

Returns the execution context retained by this analyzer.

Source

pub fn set_bitrate_hint( &mut self, bitrate: f64, confidence: BitRateConfidence, ) -> Result<()>

Supplies a transport-stream bitrate hint used by analysis.

bitrate is in bits per second based on 188-byte packets. A value of 0.0 is accepted and means “derive the bitrate from PCR values”. The hint may be set at any time before Self::snapshot. confidence states how much the hint should be trusted; BitRateConfidence::Override makes it take precedence over TSDuck’s own estimate, which is useful for live streams whose PCR-derived bitrate is unreliable.

§Errors

Returns Error::InvalidArgument when bitrate is negative or not finite, Error::InvalidState when a previous reset failure made this analyzer unusable, or Error::NativeException when the hint is rejected at the native boundary.

Source

pub fn feed(&mut self, packets: &[u8]) -> Result<()>

Feeds an integral number of 188-byte transport packets.

§Errors

Returns an error for non-188-byte-aligned input or when native analysis fails. A native feed failure resets the analyzer, so it cannot leave a partial analysis window behind. If that reset itself fails, its TSAnalyzer::feed_reset error takes precedence over the original feed error, this analyzer becomes unusable, and all later analyzer operations return Error::InvalidState.

Source

pub fn snapshot(&mut self) -> Result<TSAnalyzerReport>

Copies the current native state into one complete owned snapshot.

§Errors

Returns a native error rather than a partial report when snapshot construction fails.

Source

pub fn reset(&mut self) -> Result<()>

Clears all state from the current analysis window.

§Errors

Returns a native error if reset fails. In that case, this analyzer is permanently unusable, and subsequent Self::feed, Self::snapshot, and reset calls return Error::InvalidState.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.