#reader #parser #data

scte35-reader

Reader for data formatted according to SCTE-35

9 breaking releases

✓ Uses Rust 2018 edition

0.10.0 Apr 5, 2019
0.8.0 Feb 17, 2019
0.6.0 Dec 4, 2018
0.5.0 Nov 6, 2018
0.2.0 Mar 15, 2018

#11 in Video

Download history 5/week @ 2019-01-19 3/week @ 2019-01-26 1/week @ 2019-02-02 12/week @ 2019-02-16 2/week @ 2019-02-23 27/week @ 2019-03-02 2/week @ 2019-03-09 2/week @ 2019-03-16 32/week @ 2019-03-23 23/week @ 2019-03-30 20/week @ 2019-04-06 2/week @ 2019-04-13 15/week @ 2019-04-20 13/week @ 2019-04-27

71 downloads per month
Used in 1 crate

MIT/Apache

43KB
993 lines

scte35-reader

crates.io version

Parser data formatted according to SCTE-35.

For an example of usage, see the scte35dump tool.

Supported syntax

A subset of possible SCTE-35 syntax is currently handled:

Commands

  • splice_null()
  • splice_schedule()
  • splice_insert()
  • time_signal()
  • bandwidth_reservation()
  • private_command()

Descriptors

  • avail_descriptor
  • DTMF_descriptor
  • segmentation_descriptor
  • time_descriptor
  • Reserved - Descriptors with tags values that are 'reserved' in SCTE-35 are supported in the sense that the application gets access to the descriptor byte values, and can parse them with application-specific logic.

lib.rs:

Parser data formatted according to SCTE-35.

Intended to be used in conjunction with the mpeg2ts-reader crate's facilities for processing the Transport Stream structures within which SCTE-35 data is usually embedded.

Example

# use hex_literal::*;
# use scte35_reader::Scte35SectionProcessor;
# use mpeg2ts_reader::psi::WholeCompactSyntaxPayloadParser;
# use mpeg2ts_reader::{ psi, demultiplex };
# mpeg2ts_reader::demux_context!(
#        NullDemuxContext,
#        demultiplex::NullPacketFilter<NullDemuxContext>
#    );
# impl NullDemuxContext {
#    fn do_construct(
#        &mut self,
#        _req: demultiplex::FilterRequest<'_, '_>,
#    ) -> demultiplex::NullPacketFilter<NullDemuxContext> {
#        unimplemented!();
#    }
# }
pub struct DumpSpliceInfoProcessor;
impl scte35_reader::SpliceInfoProcessor for DumpSpliceInfoProcessor {
    fn process(
        &self,
        header: scte35_reader::SpliceInfoHeader<'_>,
        command: scte35_reader::SpliceCommand,
        descriptors: scte35_reader::SpliceDescriptors<'_>,
    ) {
        println!("{:?} {:#?}", header, command);
        for d in &descriptors {
            println!(" - {:?}", d);
        }
    }
}

let data = hex!(
            "fc302500000000000000fff01405000000017feffe2d142b00fe0123d3080001010100007f157a49"
        );
let mut parser = Scte35SectionProcessor::new(DumpSpliceInfoProcessor);
let header = psi::SectionCommonHeader::new(&data[..psi::SectionCommonHeader::SIZE]);
let mut ctx = NullDemuxContext::new();
parser.section(&mut ctx, &header, &data[..]);

Output:

SpliceInfoHeader { protocol_version: 0, encrypted_packet: false, encryption_algorithm: None, pts_adjustment: 0, cw_index: 0, tier: 4095 } SpliceInsert {
    splice_event_id: 1,
    reserved: 127,
    splice_detail: Insert {
        network_indicator: Out,
        splice_mode: Program(
            Timed(
                Some(
                    756296448
                )
            )
        ),
        duration: Some(
            SpliceDuration {
                return_mode: Automatic,
                duration: 19125000
            }
        ),
        unique_program_id: 1,
        avail_num: 1,
        avails_expected: 1
    }
}

Dependencies

~3.5MB
~61K SLoC