pub struct SectionStream<R> { /* private fields */ }Expand description
Async Stream of SectionEvents from a raw TS byte source.
Feed any tokio::io::AsyncRead byte source (file, TCP socket, UDP
socket) and receive one SectionEvent per changed complete SI section.
Internally the adapter:
- Reads bytes from
readerinto a fixed-size buffer. - Resyncs on the first
0x47sync byte (viacrate::resync::resync). - Feeds each aligned 188-byte packet into the owned
SiDemux. - Yields events from the demux’s output queue before reading more.
§Owned events
SectionEvent already owns its section bytes via bytes::Bytes and is
'static, Clone, and Send + Sync. No additional wrapping is needed.
§Cancellation
Drop the stream. No internal tasks are spawned.
Implementations§
Source§impl<R: AsyncRead + Unpin> SectionStream<R>
impl<R: AsyncRead + Unpin> SectionStream<R>
Sourcepub fn new(reader: R) -> Self
pub fn new(reader: R) -> Self
Create a SectionStream with the default SiDemux configuration
(all standard DVB/SI PIDs, PAT-follow enabled, version gating).
Sourcepub fn with_builder(reader: R, builder: SiDemuxBuilder) -> Self
pub fn with_builder(reader: R, builder: SiDemuxBuilder) -> Self
Create a SectionStream with a custom SiDemuxBuilder.
Sourcepub fn with_demux(reader: R, demux: SiDemux) -> Self
pub fn with_demux(reader: R, demux: SiDemux) -> Self
Create a SectionStream with an already-constructed SiDemux.
Sourcepub fn resync_stats(&self) -> ResyncStats
pub fn resync_stats(&self) -> ResyncStats
Access the resync statistics.
Source§impl SectionStream<UdpReader>
UDP/multicast convenience constructor — enabled by the udp feature.
impl SectionStream<UdpReader>
UDP/multicast convenience constructor — enabled by the udp feature.
Sourcepub async fn bind_multicast(
bind_addr: SocketAddrV4,
multicast_addr: Ipv4Addr,
) -> Result<Self>
pub async fn bind_multicast( bind_addr: SocketAddrV4, multicast_addr: Ipv4Addr, ) -> Result<Self>
Bind a UDP socket to bind_addr and join multicast_addr.
Typical DVB multicast delivery uses addresses like 239.0.0.1:5004.
The returned SectionStream reads one UDP datagram per poll_next
cycle from the socket (treated as a raw TS byte source).
§Errors
Returns a std::io::Error if binding or joining the multicast group
fails.