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
impl TSAnalyzer
Sourcepub fn new(context: Rc<DuckContext>) -> Result<Self>
pub fn new(context: Rc<DuckContext>) -> Result<Self>
Creates an analyzer retaining context for its full native lifetime.
Sourcepub fn context(&self) -> &Rc<DuckContext>
pub fn context(&self) -> &Rc<DuckContext>
Returns the execution context retained by this analyzer.
Sourcepub fn set_bitrate_hint(
&mut self,
bitrate: f64,
confidence: BitRateConfidence,
) -> Result<()>
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.
Sourcepub fn feed(&mut self, packets: &[u8]) -> Result<()>
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.
Sourcepub fn snapshot(&mut self) -> Result<TSAnalyzerReport>
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.
Sourcepub fn reset(&mut self) -> Result<()>
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.