macro_rules! demux_context {
    ($name:ident, $ctor:ty) => { ... };
}
Expand description

Creates the boilerplate needed for a filter-implementation-specific DemuxContext.

This macro takes two arguments; the name for the new type, and the name of an existing implementation of PacketFilter. It then..

  1. creates a struct with the given name, wrapping an instance of FilterChangeset
  2. provides an implementation of default() for that struct
  3. provides an implementation of DemuxContext

Example

// Create an enum that implements PacketFilter as required by your application.
packet_filter_switch!{
    MyFilterSwitch<MyDemuxContext> {
        Pat: mpeg2ts_reader::demultiplex::PatPacketFilter<MyDemuxContext>,
        Pmt: mpeg2ts_reader::demultiplex::PmtPacketFilter<MyDemuxContext>,
        Nul: mpeg2ts_reader::demultiplex::NullPacketFilter<MyDemuxContext>,
    }
};

// Create an implementation of the DemuxContext trait for the PacketFilter implementation
// created above.
demux_context!(MyDemuxContext, MyStreamConstructor);

pub struct MyStreamConstructor;
impl StreamConstructor for MyStreamConstructor {
    /// ...
}

let mut ctx = MyDemuxContext::new(MyStreamConstructor);
// .. use the ctx value while demultiplexing some data ..