- Fixed
DsmTrickMode::SlowMotionandDsmTrickMode::SlowReversereturning the 3-bittrick_mode_controlvalue instead of the 5-bitrep_cntrlfield from the DSM trick mode byte. - Fixed
PesParsedContents::copyright()returning inverted values: bit=1 now producesCopyright::Protectedand bit=0 producesCopyright::Undefined. - Fixed
Timestamp::from_u64()incorrectly accepting 34-bit values; now correctly limited to 33-bit range (Timestamp::MAX). - Fixed
StreamType::is_pes()incorrectly returningtruefor section-based stream types (MHEG,DSMCC_UN_MESSAGES,DSMCC_STREAM_DESCRIPTORS,DSMCC_SECTIONS,ISO_13818_6_MULTIPROTOCOL_ENCAPSULATION,FLEX_MUX_ISO_14496_SECTIONS,SYNCHRONIZED_DOWNLOAD_PROTOCOL,METADATA_IN_METADATA_SECTIONS,DSMCC_DATA_CAROUSEL_METADATA,DSMCC_OBJECT_CAROUSEL_METADATA,SYNCHRONIZED_DOWNLOAD_PROTOCOL_METADATA). - Raised PSI
section_lengthlimit from 1021 to 4093 in bothSectionSyntaxSectionProcessorandCompactSyntaxSectionProcessor, matching the maximum allowed by the spec for private sections. The PAT and PMT retain their spec-mandated 1021 limit. - Fixed
Timestamp::from_pts_bytes()rejecting valid PTS data when both PTS and DTS are present (prefix'0011'); it now accepts both'0010'and'0011'prefixes. - Fixed PSI section framing to handle multiple sections packed into a single TS packet payload. Previously, when a packet with
payload_unit_start_indicator=1carried a short section followed by the start of another section, the trailing section's leading bytes were silently dropped and every following continuation packet produced spuriousExtraDataAfterSectionCompletewarnings until the next PUSI resync. - Fixed PSI section parsing to buffer section headers that straddle TS packet boundaries. Previously, if the initial payload slice contained fewer than 8 header bytes (legal per the spec) the section was abandoned with a
SectionDataTooShortwarning (formerly logged as"TODO: implement buffering"); the newSectionSyntaxFrameraccumulates bytes until a full header is available before parsing.
- Breaking:
AdaptationField::splice_countdown()now returnsResult<i8, ..>instead ofResult<u8, ..>, since the spec defines this as a signed two's complement value. - Breaking:
PesHeader::from_bytes()now returnsResult<PesHeader, PesError>instead ofOption<PesHeader>. - Breaking:
PesParsedContents::from_bytes()now returnsResult<PesParsedContents, PesError>instead ofOption<PesParsedContents>. - Breaking:
PesContents::Parsednow wrapsResult<PesParsedContents, PesError>instead ofOption<PesParsedContents>. Pattern matches should change fromParsed(Some(content))/Parsed(None)toParsed(Ok(content))/Parsed(Err(_)). - Breaking:
Packet::try_new()now returnsResult<Packet, PacketError>instead ofOption<Packet>. - Breaking:
Packet::adaptation_field()now returnsResult<Option<AdaptationField>, PacketError>instead ofOption<AdaptationField>. - Breaking:
Packet::payload()now returnsResult<Option<&[u8]>, PacketError>instead ofOption<&[u8]>. - Breaking:
PatSection::programs()iterator now yieldsResult<ProgramDescriptor, PatError>instead ofProgramDescriptor. - Breaking:
DemuxErrorhas been renamed toPmtErrorand moved from thedemultiplexmodule topsi::pmt. - Breaking:
PmtSection::streams()iterator now yieldsResult<StreamInfo, PmtError>instead ofStreamInfo. - Replaced all
warn!()logging with the newErrorSink::error()callback. - Breaking:
DemuxContextnow requiresErrorSinkas a supertrait. Thedemux_context!macro automatically provides a no-opErrorSinkimpl. - Breaking: PSI section framing has been reworked. The previous pipeline of
SectionPacketConsumerwrappingBufferSectionSyntaxParserwrappingSectionSyntaxSectionProcessor(and the compact-syntax equivalents) is replaced by a singleSectionSyntaxFramer(orCompactSyntaxFramer) that wraps aWholeSectionSyntaxPayloadParserdirectly. Construction sites change from e.g.SectionPacketConsumer::new(BufferSectionSyntaxParser::new(CrcCheckWholeSectionSyntaxPayloadParser::new(proc)))toSectionSyntaxFramer::new(pid, CrcCheckWholeSectionSyntaxPayloadParser::new(pid, proc)). - Breaking: Removed
SectionPacketConsumer,BufferSectionSyntaxParser,BufferCompactSyntaxParser,SectionSyntaxSectionProcessor, andCompactSyntaxSectionProcessor- replaced bySectionSyntaxFramer/CompactSyntaxFramer. - Breaking: Removed the
SectionProcessor,SectionSyntaxPayloadParser, andCompactSyntaxPayloadParsertraits -WholeSectionSyntaxPayloadParser/WholeCompactSyntaxPayloadParserare now the only extension points.
ErrorSinktrait with a default no-operror()method. Override this to receive error reports about transport stream problems. When not overridden, monomorphization eliminates the calls entirely in release builds.DemuxErrorenum (in theerrormodule) for programmatic access to parsing problems (transport errors, scrambled packets, invalid table IDs, section length violations, PMT/PES parse errors).PmtErrorenum (in thepsi::pmtmodule) for PMT-specific parse errors (previouslyDemuxErrorin thedemultiplexmodule).CrcCheckWholeSectionSyntaxPayloadParser::new()now takes apidparameter so errors carry the originating PID.- New
SectionSyntaxFramerandCompactSyntaxFramertypes in thepsimodule that frame PSI sections out of TS packet payloads. These collapse the previous three-layer pipeline (SectionPacketConsumer→Buffer*SyntaxParser→*SyntaxSectionProcessor) into a single type. Both constructors take apidso errors carry the originating PID. PesErrorvariants:InvalidStartCode,InvalidCheckBits,HeaderLengthExceedsBuffer,HeaderDataLengthMismatch.- Updated
StreamTypeconstants andCoreDescriptors/AudioTypevariants to match the 2025 edition. - Added TSDT (Transport Stream Description Table) support:
psi::tsdt::TsdtSectionfor parsing,demultiplex::TsdtConsumertrait for receiving parsed sections, anddemultiplex::TsdtPacketFilterfor integration with the demuxer.
logdependency.
- Make
StreamType(u8)constructor public so that it can be used inconstcontexts in other crates
- Added
StreamType::from(u8)which was missing in release 1.18.0
- The
pes::StreamTypeandStreamIdtypes changed from enums to structs. These changes reduce the risk of silent breakage in future releases of this crate, if support for additionalStreamTypeorStreamIdvalues are added. descriptor::iso_639_language::Code::code()no longer takes any arguments, and now returnsCow<'_, str>rather thanResult<String, ..>(due to the switch from theencodingcrate to theencoding_rscrate).
- Removed the dependency on the unmaintained
encodingcreate and switched toencoding_rs. See RUSTSEC-2021-0153.
- Updated to Rust 2021 edition
packet::TransportScramblingControlchanged from an enum to a struct. Newis_scrambled()andscheme()methods onTransportScramblingControlreplace the functionality of the old enum variants. The changed type layout slightly improves performance.packet::AdaptationControlchanged from an enum to a struct. Itshas_payload()method now takesselfby reference, and a newhas_adaptation_field()method has been added. The changed type layout slightly improves performance.
FormatIdentifieris now re-exported from the smptera-format-identifiers-rust crate so that calling code can more easily use the same version of it as thempeg2ts-readercrate.
Iso639LanguageDescriptor::languages()now producesResult<Language>rather than justLanguage- Since we don't support decryption, scrambled TS packets (packets with values of
transport_scrambling_controlother than0) are now dropped, to prevent the application being passed bogus data AdaptationFieldExtension::new()changed to returnResult
- Fixed a panic when parsing truncated PMT data
- Fixed a panic when parsing a truncated descriptor value
- Fixed a panic when parsing a truncated language code in
iso_639_language_descriptor - Fixed a panic when reported PES header length does not fit within available space
- Fixed a panic due to a bug parsing PES header
ESCR_basefield - Fixes a panic when
PES_header_data_lengthis not long enough to accommodate all the headers actually present - Fixed so we accept very short but still syntactically valid PSI sections previously rejected in some cases
- Fixed a panic on TS packet with
adaptation_field_extension_flagset, butadaptation_field_extension_lengthis0
- The
pes::ElementaryStreamConsumertype and its methods are now parameterised to gain access to the context object you provided to the demultiplexer. Thanks @fkaa. RegistrationDescriptor::format_identifier()return type changed from u32 to a value of theFormatIdentifierenum from the smptera-format-identifiers-rust crate. AlsoRegistrationDescriptorfields are no longer public.Pid::new()is now aconstfunction. Other crates can now definePidconstants.- Definitions of constants for 'PAT' and 'stuffing' PIDs have been relocated, now that don't have to be in the same
module as the
Pidtype.
- Implementation of
TryFrom<u16>forPid
- The
descriptor_enum!{}macro no longer provides a default case (which used to produceError), so callers which don't define mappings for all possible descriptor tag values (0-255) will now get a compiler error.
- Fixed incorrect value of
Timestamp::MAX.
- Added
Timestamp::TIMEBASEconstant.
AVC_video_descriptor()parsing.maximum_bitrate_descriptor()parsing.Timestamp::likely_wrapped_since()utility for detecting wraparound, and supportingTimestamp::MAXconstant.
- Made
mpegts_crc::sum_32()public. - Added types to
psimodule for handling 'compact syntax' sections (mirroring existing types for handling 'section syntax' sections).
StreamType::is_pes()util function to identify those StreamType values that the spec expects to carry PES content.
- Made the methods of
descriptor::iso_639_language::Languagepublic (they were private by mistake) - Drop TS packets that have
transport_error_indicatorflag set, rather than passing known-bad data to the application.
- Some more descriptor-tag values in
CoreDescriptors(but not the descriptor definitions themselves yet).
- Removed the
StreamConstructortrait, and merged its previous responsibilities intoDemuxContext. This makes it much simpler for client code to gain access to any relevantDemuxContextstate when the demuxer requests a handler for a newly discovered stream within the TS. - Added a
StreamIdenum to replace theu8previously used as the return value forPesHeader::stream_id() - Removed single usage of
hex-slicecrate; resulting Debug impl is not quite so nice, but now there's one less dependency. - Avoid calling
start_stream()onElementaryStreamConsumerafter parsing errors. It was only intended to be called when the substream was first encountered in the multiplex.
- Avoid panics due to 0-length
adaptation_field, larger-than-expectedprogram_info_lengthand too smallsection_length. All found through fuzz testing.
- All public API members now have at least minimal documentation
- Removed the
demultiplex::UnhandledPidtype to try and simplify the API slightly. - Removed
PesPacketConsumer. The typesPesPacketFilterandPesPacketConsumerseem in hindsight to be redundant (the first just being a thin wrapper for the second).PesPacketFilternow implements the complete functionality. - Removed
PmtSection::program_info_length()andStreamInfo::es_info_length()from public API. - Changed
PmtSection::pcr_pid()to return aPid(got missed when others changed fromu16toPid) in version 0.7.0.
- Removed some unused dependencies
- Changed the representation of PID values in the API from plain
u16to a newPidwrapper, so that the API can't represent invalid PID values. FilterRequest::ByStreamchanges from tuple to struct variant, and gainsprogram_idof the program to which the stream belongs.- All uses of
println!()have been replaced with use ofwarn!()from thelogcrate.
- PES data is no longer truncated at the end of the TS packet with
payload_unit_start_indicator
- Many methods previously taking a
Packetby value now instead take it by reference. This breaks with the old API, but may deliver a small performance improvement for some workloads. - Many objects that previously offered a no-args
new()method have had this replaced with adefault()impl. - The
PCRtype has been renamedClockRef, since it's used to represent the values of both Prograem Clock Reference and Elementry Stream Clock Reference fields. descriptor::RegistrationDescriptorbecamedescriptor::registration::RegistrationDescriptor. New descriptor implementations will be added each in their own source file.- Moved PAT/PMT types from
demultiplexmodule intopsi::patandpsi::pmtmodules. - Refactored some methods returning custom
Iteratortypes to instead returnimpl Iterator, so that the actual iterator types can be hidden from the public API pes_packet_lengthis now represented asenum PesLength, rather than directly as au16, so that the special status of the length-value 0 can be made explicit (it's now mapped toPesLength::Unbounded)
- Added
iso_639_language_descriptorsupport