TSDuck v3.39-3843
MPEG Transport Stream Toolkit
|
Generate and insert EIT sections based on an EPG content. More...
#include <tsEITGenerator.h>
Public Member Functions | |
EITGenerator (DuckContext &duck, PID pid=PID_EIT, EITOptions options=EITOptions::GEN_ALL|EITOptions::LOAD_INPUT, const EITRepetitionProfile &profile=EITRepetitionProfile::SatelliteCable) | |
Constructor. | |
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. | |
void | setCurrentTime (const Time ¤t_utc) |
Set the current time in the stream processing. | |
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().
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.
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.
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.
|
explicit |
|
inline |
Reset the EIT generator to default state.
The EPG content is deleted. The TS id and current time are forgotten.
void ts::EITGenerator::reset | ( | PID | pid | ) |
void ts::EITGenerator::setOptions | ( | EITOptions | options | ) |
|
inline |
void ts::EITGenerator::setTransportStreamId | ( | uint16_t | ts_id | ) |
Define the "actual" transport stream id for generated EIT's.
When this method is called, all events for the specified TS are stored in "EIT actual". All other events are stored in "EIT other". By default, when no explicit TS id is set, the first PAT or EIT actual which is seen by processPacket() defines the actual TS id.
[in] | ts_id | Actual transport stream id. |
|
inline |
Get the "actual" transport stream id for generated EIT's.
|
inline |
Set the maximum bitrate of the EIT PID.
If set to zero (the default), EIT's are injected according to their cycle time, within the limits of the input PID and the stuffing. The PID bitrate limitation is effective only if the transport stream bitrate is specified.
[in] | bitrate | Maximum bitrate of the EIT PID. |
void ts::EITGenerator::setCurrentTime | ( | const Time & | current_utc | ) |
Set the current time in the stream processing.
By default, the current time is synchronized on each input TDT or TOT. Calling this method is useful only when there is no TDT/TOT or to set a time reference before the first TDT or TOT.
[in] | current_utc | Current UTC time in the context of the stream. |
Time ts::EITGenerator::getCurrentTime | ( | ) |
Get the current time in the stream processing.
The current time starts from the last reference clock (TDT, TOT or setCurrentTime()) and is maintained from the declared bitrate and number of processed packets. If there is no declared bitrate, the last reference time is returned.
|
inline |
Set the current bitrate of the transport stream.
The bitrate is used to update the current time, packet after packet, from the last reference clock (TDT, TOT or setCurrentTime()).
[in] | bitrate | Current transport stream bitrate in bits per second. |
void ts::EITGenerator::processPacket | ( | TSPacket & | pkt | ) |
Process one packet from the stream.
[in,out] | pkt | A TS packet from the stream. If the packet belongs to the EIT PID or the null PID, it may be updated with new content. |
bool ts::EITGenerator::loadEvents | ( | const ServiceIdTriplet & | service, |
const uint8_t * | data, | ||
size_t | size | ||
) |
Load EPG data from binary events descriptions.
If the current clock is defined, events which are older (already terminated) are ignored. If the clock is not yet defined, all events are stored and obsolete events will be discarded when the clock is defined for the first time.
[in] | service | Service id triplet for all events in the binary data. |
[in] | data | Address of binary events data. Each event is described using the same format as in an EIT section, from the event_id field to the end of the descriptor list. Several events can be concatenated. All events are individually extracted. |
[in] | size | Size in bytes of the event binary data. |
bool ts::EITGenerator::loadEvents | ( | const Section & | section, |
bool | get_actual_ts = false |
||
) |
bool ts::EITGenerator::loadEvents | ( | const SectionPtrVector & | sections, |
bool | get_actual_ts = false |
||
) |
Load EPG data from a vector of EIT sections.
[in] | sections | A vector of sections. Non-EIT sections are ignored. |
[in] | get_actual_ts | If true and the actual transport stream id is not yet defined use the first EIT actual section to set the actual TS. |
|
inline |
Load EPG data from all EIT sections in a section file.
[in] | sections | A section file object. Non-EIT sections are ignored. |
[in] | get_actual_ts | If true and the actual transport stream id is not yet defined use the first EIT actual section to set the actual TS. |
void ts::EITGenerator::saveEITs | ( | SectionPtrVector & | sections | ) |
Save all current EIT sections.
If the current time is not set, the oldest event time in the EPG database is used. An EIT sections are regenerated when necessary. EIT p/f are saved first. Then EIT schedule.
[in,out] | sections | A vector of safe pointers to sections into which all current EIT sections are saved. |
void ts::EITGenerator::saveEITs | ( | SectionFile & | sections | ) |
Save all current EIT sections in a section file.
If the current time is not set, the oldest event time in the EPG database is used. An EIT sections are regenerated when necessary. EIT p/f are saved first. Then EIT schedule.
[in,out] | sections | A section file object into which all current EIT sections are saved. |
void ts::EITGenerator::dumpInternalState | ( | int | level | ) | const |
Dump the internal state of the EIT generator on the DuckContext Report object.
[in] | level | Severity level at which the state is dumped. |