|
| EITGenerator (DuckContext &duck, PID pid=PID_EIT, EITOptions options=EITOptions::GEN_ALL|EITOptions::LOAD_INPUT, const EITRepetitionProfile &profile=EITRepetitionProfile::SatelliteCable) |
| Constructor.
|
|
bool | deleteEvent (const ServiceIdTriplet &service, uint16_t event_id) |
| Delete an event, remove it from EIT generation.
|
|
bool | deleteEvents (const ServiceIdTriplet &service, const uint8_t *data, size_t size) |
| Delete events from binary events descriptions.
|
|
void | dumpInternalState (int level) const |
| Dump the internal state of the EIT generator on the DuckContext Report object.
|
|
Time | getCurrentTime () |
| Get the current time in the stream processing.
|
|
uint16_t | getTransportStreamId () |
| Get the "actual" transport stream id for generated EIT's.
|
|
bool | loadEvents (const Section §ion, bool get_actual_ts=false) |
| Load EPG data from an EIT section.
|
|
bool | loadEvents (const SectionFile §ions, bool get_actual_ts=false) |
| Load EPG data from all EIT sections in a section file.
|
|
bool | loadEvents (const SectionPtrVector §ions, bool get_actual_ts=false) |
| Load EPG data from a vector of EIT sections.
|
|
bool | loadEvents (const ServiceIdTriplet &service, const uint8_t *data, size_t size) |
| Load EPG data from binary events descriptions.
|
|
void | processPacket (TSPacket &pkt) |
| Process one packet from the stream.
|
|
void | reset () |
| Reset the EIT generator to default state.
|
|
void | reset (PID pid) |
| Reset the EIT generator to default state.
|
|
void | saveEITs (SectionFile §ions) |
| Save all current EIT sections in a section file.
|
|
void | saveEITs (SectionPtrVector §ions) |
| Save all current EIT sections.
|
|
template<class Rep , class Period > |
void | setApplicationEventOffset (cn::duration< Rep, Period > offset) |
| Define a time offset to apply on all events which are loaded from the application.
|
|
void | setCurrentTime (const Time ¤t_utc) |
| Set the current time in the stream processing.
|
|
template<class Rep , class Period > |
void | setInputEventOffset (cn::duration< Rep, Period > offset) |
| Define a time offset to apply on all events which are received from the input EIT PID.
|
|
void | setMaxBitRate (const BitRate &bitrate) |
| Set the maximum bitrate of the EIT PID.
|
|
void | setOptions (EITOptions options) |
| Set new EIT generation options.
|
|
void | setProfile (const EITRepetitionProfile &profile) |
| Set a new EIT repetition profile.
|
|
void | setTransportStreamBitRate (const BitRate &bitrate) |
| Set the current bitrate of the transport stream.
|
|
void | setTransportStreamId (uint16_t ts_id) |
| Define the "actual" transport stream id for generated EIT's.
|
|
Generate and insert EIT sections based on an EPG content.
To generate EIT sections, an instance of EITGenerator needs:
The current time is automatically updated packet after packet, based on the last UTC time, the number of packets since then and the transport stream bitrate (shall be set using EITGenerator::setTransportStreamBitRate()).
Generated EIT section can be saved in a SectionFile object (see EITGenerator::saveEITs()) or inserted in the transport stream using EITGenerator::processPacket(). In the latter case, input null packets and EIT packets are replaced with packets for the generated EIT's (or null packets when necessary).
EIT packet insertion is performed depending on cycle time of the various EIT sections (see EITGenerator::setProfile()). The maximum EIT bandwidth can be limited using EITGenerator::setMaxBitRate().
EPG database
The EPG database is entirely in memory. It is initially empty and emptied using EITGenerator::reset(). Events are loaded in EPG using EITGenerator::loadEvents() (various flavours exist).
The EPG can be saved in a SectionFile object using EITGenerator::saveEITs(). This object can later be saved in binary or XML format. It can be reloaded later in another instance of EITGenerator.
The EPG content is filled with generic EIT sections, either in binary or XML form. The structure of these EIT sections, p/f or schedule, the number and order of events, do not matter. The events are individually extracted and will be stored and sorted independently. These events will be used to fill the generated EIT sections. In short, EIT section is just a convenient storage format for EPG events.
Events can also be individually loaded, outside EIT sections but using the same binary format as in EIT, from field event_id to end of descriptor list.
Principle of operation
The EITGenerator object is continuously invoked for all packets in a TS. Packets from the EIT PID or the stuffing PID are replaced by EIT packets, when necessary.
It is important that the application passes all packets from the TS, not only the packets that the application wishes to replace. This is required so that the EITGenerator object can evaluate the bitrate and repetition rate of the generated EIT sections.
EIT sections from the input EIT PID can also be used to populate the EPG database if the option EITOption::INPUT is set. This is a convenient way to generate EIT p/f in addition to (or in replacement to) an input stream of EIT schedule.
Basic EIT generation rules
- Using a bit-mask of EITOption, the EITGenerator object can selectively generate any combination of EIT p/f (present/following) and/or EIT schedule, EIT actual and/or EIT other.
- We call "subtable" the collection of sections with same table id and same table id extension (the service id in the case of an EIT). This is a general MPEG/DVB definition.
- The EIT syntax and semantics are specified in ETSI EN 300 468, section 5.2.4. The usage guidelines are specified in ETSI TS 101 211, section 4.1.4.
- An EIT p/f, when present, must have two sections. The present event is in section 0. The next event is in section 1. If there is no event, the EIT section must be present but empty (no event).
- EIT schedule are structured as follow:
- The structure is based on a "reference midnight", typically the current day at 00:00:00.
- The total duration of an EPG is 64 days maximum, over 16 subtables per service.
- Each subtable covers a duration of 4 days. The first subtable starts at the reference midnight.
- Each subtable (4 days) is divided in 32 "segments" of 3 hours.
- A segment spans over 8 sections (sections 0-7, 8-15, 16-23, 24-31, etc.)
- In each subtable, all segments from 0 to the last used one shall be present. Unused segments after the last used one are optional.
- In each segment, all sections from 0 to the last non-empty one shall be present. Unused segments after the last used one are optional. Empty segment shall be represented with one empty section. The last section in each segment is set in the EIT field segment_last_section_number.
- The last EIT schedule table id is set in the field last_table_id in all EIT sections.
- As a consequence, an EIT schedule is not a complete table in MPEG terms since some sections are intentionally missing.
- EIT schedule are divided into two periods with potentially distinct repetition rates:
- The "prime" period extends over the next few days. The repetition rate of those EIT's is typically longer than EIT present/following but still reasonably fast. The duration in days of the prime period depends on the type of network.
- The "later" period includes all events after the prime period. The repetition rate of those EIT's is typically longer that in the prime period.
Implementation notes
The number and content of the EIT sections depend on the EPG data and the time.
The public methods which may trigger EIT sections modifications are:
The EIT regeneration takes time, so we need to limit the operations.
- Changing the options, the transport stream id and the repetition profile is not supposed to happen more than once and the processing time is not important.
- Setting the time to a completely new reference is not frequent either.
- Setting the time to a small increment is extremely frequent (each packet in fact). Impact:
- Update EIT p/f on some services.
- Remove a segment and associated EIT schedule sections when crossing a 3-hour segment. We do not remove obsolete events in EIT schedule sections inside the current segment unless the segment is forced to be regenerated.
- Midnight effect: When crossing 00:00:00, all EIT schedule sections must change. Affected fields: table_id, section_number, last_section_number, segment_last_section_number, last_table_id. These are only a few fields to patch "in place" (and recompute the CRC).
- Loading events is usually performed in batch (load files) or the same events are loaded again and again (input EIT sections). We use the following method:
- Existing events with same content are silently ignored.
- When a new event is loaded, the "regenerate" flag is set 1) globally, 2) on the service and 3) on the 3-hour segment.
- When an EIT section needs to be injected, we check the global "regenerate" flag. When set, all services and segments are inspected and regenerated when necessary. All "regenerate" flags are then cleared.
- See also
- ETSI EN 300 468, 5.2.4
-
ETSI TS 101 211, 4.1.4