TSDuck v3.40-4033
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::PSIMerger Class Reference

This class merges PSI/SI tables from two TS, replacing TS packets. More...

#include <tsPSIMerger.h>

Inheritance diagram for ts::PSIMerger:
Collaboration diagram for ts::PSIMerger:

Public Types

enum  Options : uint32_t {
  NONE = 0x00000000 ,
  MERGE_PAT = 0x00000001 ,
  MERGE_CAT = 0x00000002 ,
  MERGE_NIT = 0x00000004 ,
  MERGE_SDT = 0x00000008 ,
  MERGE_BAT = 0x00000010 ,
  MERGE_EIT = 0x00000020 ,
  KEEP_MAIN_TDT = 0x00000040 ,
  KEEP_MERGE_TDT = 0x00000080 ,
  NULL_MERGED = 0x00000100 ,
  NULL_UNMERGED = 0x00000200 ,
  DEFAULT = MERGE_PAT | MERGE_CAT | MERGE_NIT | MERGE_SDT | MERGE_BAT | MERGE_EIT | NULL_MERGED | NULL_UNMERGED
}
 Merging options. More...
 

Public Member Functions

 PSIMerger (DuckContext &duck, Options options=DEFAULT)
 Constructor.
 
bool feedMainPacket (TSPacket &pkt)
 Feed a packet from the main stream.
 
bool feedMergedPacket (TSPacket &pkt)
 Feed a packet from the merged stream.
 
void reset ()
 Reset the PSI merger.
 
void reset (Options options)
 Reset the PSI merger with new options.
 

Detailed Description

This class merges PSI/SI tables from two TS, replacing TS packets.

Definitions:

  • Main stream: the main TS which will be modified.
  • Merged stream: the additional TS the PSI of which will be merged in the PSI of the main stream.

The packets from the two streams are passed using two distinct methods: feedMainPacket() and feedMergedPacket(). The packets from the main stream can be modified to overwrite PSI/SI packets. Packets from the merged stream may be overwritten when they carry EIT's, depending on settings.

The following tables can be merged: PAT, SDT, BAT, NIT. The EIT can also be merged, but in a different way. The PAT, SDT, BAT, NIT are fully merged. The two PAT, for instance, are merged into one single PAT containing all services from the two PAT's. The new PAT is cycled in replacement of the packets from the main stream containing the main PAT. All EIT's for the two streams are left unmodified but are mixed into one single PID. The mixed stream of EIT's is written in replacement of the EIT streams from the two streams.

Member Enumeration Documentation

◆ Options

enum ts::PSIMerger::Options : uint32_t

Merging options.

Can be used as bitmasks.

Enumerator
NONE 

Do not merge anything.

MERGE_PAT 

Merge the two PAT's into one.

MERGE_CAT 

Merge the two CAT's into one.

MERGE_NIT 

Merge the two NIT's Actual into one. The NIT Others are mixed in the NIT PID.

MERGE_SDT 

Merge the two SDT's Actual into one. The SDT Others are mixed in the SDT/BAT PID.

MERGE_BAT 

Merge the BAT's from the same bouquet into one.

MERGE_EIT 

Mix the EIT's from the two streams.

KEEP_MAIN_TDT 

Keep TDT/TOT from main stream.

KEEP_MERGE_TDT 

Keep TDT/TOT from merge stream. It is dangerous to use KEEP_MAIN_TDT and KEEP_MERGE_TDT at the same time.

NULL_MERGED 

Nullify packets from the merged stream when they carried merged PSI (PAT, NIT, SDT, BAT). EIT are merged, not nullified.

NULL_UNMERGED 

Nullify packets from the merged stream when they carry unmerged PSI (PAT, NIT, SDT, BAT, EIT).

DEFAULT 

Default options: merge all.

Constructor & Destructor Documentation

◆ PSIMerger()

ts::PSIMerger::PSIMerger ( DuckContext duck,
Options  options = DEFAULT 
)
explicit

Constructor.

Parameters
[in,out]duckTSDuck execution context. The reference is kept inside the demux. Contextual information (such as standards) are accumulated in the context from demuxed sections, from both streams.
[in]optionsBitmask of option values.

Member Function Documentation

◆ feedMainPacket()

bool ts::PSIMerger::feedMainPacket ( TSPacket pkt)

Feed a packet from the main stream.

Parameters
[in,out]pktA packet from the first stream. When the packet contains tables to merge, it is replaced.
Returns
True on success, false if an error was reported.

◆ feedMergedPacket()

bool ts::PSIMerger::feedMergedPacket ( TSPacket pkt)

Feed a packet from the merged stream.

Parameters
[in,out]pktA packet from the first stream. When the packet contains tables which can be merged, it can be replaced by null packets or EIT sections, depending on options.
Returns
True on success, false if an error was reported.

◆ reset() [1/2]

void ts::PSIMerger::reset ( )

Reset the PSI merger.

All contexts are erased. The options are left unchanged.

◆ reset() [2/2]

void ts::PSIMerger::reset ( Options  options)

Reset the PSI merger with new options.

All contexts are erased.

Parameters
[in]optionsBitmask of option values.

The documentation for this class was generated from the following file: