TSDuck Version 3.29-2562 (TSDuck - The MPEG Transport Stream Toolkit)
tsduck.SectionFile Class Reference

A wrapper class for C++ SectionFile. More...

Inheritance diagram for tsduck.SectionFile:
Collaboration diagram for tsduck.SectionFile:

Public Member Functions

def __init__ (self, duck)
 Constructor. More...
 
def binarySize (self)
 Get the size in bytes of all sections. More...
 
def clear (self)
 Clear the content of the SectionFile, erase all sections. More...
 
def delete (self)
 Explicitly free the underlying C++ object. More...
 
def fromBinary (self, data)
 Load a binary section file from a memory buffer. More...
 
def loadBinary (self, file)
 Load a binary section file. More...
 
def loadXML (self, file)
 Load an XML file. More...
 
def reorganizeEITs (self, year=0, month=0, day=0)
 Reorganize all EIT sections according to ETSI TS 101 211. More...
 
def saveBinary (self, file)
 Save a binary section file. More...
 
def saveJSON (self, file)
 Save a JSON file after automated XML-to-JSON conversion. More...
 
def saveXML (self, file)
 Save an XML file. More...
 
def sectionsCount (self)
 Get the total number of sections in the file. More...
 
def setCRCValidation (self, mode)
 Set the CRC32 processing mode when loading binary sections. More...
 
def tablesCount (self)
 Get the total number of full tables in the file. More...
 
def toBinary (self)
 Get the binary content of a section file. More...
 
def toJSON (self)
 Serialize as JSON text. More...
 
def toXML (self)
 Serialize as XML text. More...
 

Static Public Attributes

int CRC32_CHECK = 1
 Check that the value of the CRC32 of the section is correct and fail if it isn't.
 
int CRC32_COMPUTE = 2
 Recompute a fresh new CRC32 value based on the content of the section.
 
int CRC32_IGNORE = 0
 Ignore the section CRC32 when loading a binary section. More...
 

Detailed Description

A wrapper class for C++ SectionFile.

Constructor & Destructor Documentation

◆ __init__()

def tsduck.SectionFile.__init__ (   self,
  duck 
)

Constructor.

Parameters
duckThe tsduck.DuckContext object to use.

Member Function Documentation

◆ delete()

def tsduck.SectionFile.delete (   self)

Explicitly free the underlying C++ object.

After this call, the object becomes unusable. Most usages are unpredictable but most likely will do nothing.

Returns
None.

Reimplemented from tsduck.NativeObject.

◆ clear()

def tsduck.SectionFile.clear (   self)

Clear the content of the SectionFile, erase all sections.

Returns
None.

◆ binarySize()

def tsduck.SectionFile.binarySize (   self)

Get the size in bytes of all sections.

This would be the size of the corresponding binary file.

Returns
The size in bytes of all sections.

◆ sectionsCount()

def tsduck.SectionFile.sectionsCount (   self)

Get the total number of sections in the file.

Returns
The total number of sections in the file.

◆ tablesCount()

def tsduck.SectionFile.tablesCount (   self)

Get the total number of full tables in the file.

Orphan sections are not included.

Returns
The total number of full tables in the file.

◆ setCRCValidation()

def tsduck.SectionFile.setCRCValidation (   self,
  mode 
)

Set the CRC32 processing mode when loading binary sections.

Parameters
modeFor binary files, how to process the CRC32 of the input sections. Must be one of the CRC32_* values.
Returns
None

◆ fromBinary()

def tsduck.SectionFile.fromBinary (   self,
  data 
)

Load a binary section file from a memory buffer.

The loaded sections are added to the content of this object.

Parameters
dataA bytearray containing the binary data to load.
Returns
True on success, False if some sections were incorrect or truncated.

◆ toBinary()

def tsduck.SectionFile.toBinary (   self)

Get the binary content of a section file.

Returns
A bytearray containing the binary sections.

◆ loadBinary()

def tsduck.SectionFile.loadBinary (   self,
  file 
)

Load a binary section file.

The loaded sections are added to the content of this object.

Parameters
fileBinary file name. If the file name is empty or "-", the standard input is used.
Returns
True on success, False on error.

◆ saveBinary()

def tsduck.SectionFile.saveBinary (   self,
  file 
)

Save a binary section file.

Parameters
[in]fileBinary file name. If the file name is empty or "-", the standard output is used.
Returns
True on success, False on error.

◆ loadXML()

def tsduck.SectionFile.loadXML (   self,
  file 
)

Load an XML file.

The loaded tables are added to the content of this object.

Parameters
fileXML file name. If the file name starts with "<?xml", this is considered as "inline XML content". If the file name is empty or "-", the standard input is used.
Returns
True on success, False on error.

◆ saveXML()

def tsduck.SectionFile.saveXML (   self,
  file 
)

Save an XML file.

Parameters
[in]fileXML file name. If the file name is empty or "-", the standard output is used.
Returns
True on success, False on error.

◆ saveJSON()

def tsduck.SectionFile.saveJSON (   self,
  file 
)

Save a JSON file after automated XML-to-JSON conversion.

Parameters
[in]fileJSON file name. If the file name is empty or "-", the standard output is used.
Returns
True on success, False on error.

◆ toXML()

def tsduck.SectionFile.toXML (   self)

Serialize as XML text.

Returns
Complete XML document text, empty on error.

◆ toJSON()

def tsduck.SectionFile.toJSON (   self)

Serialize as JSON text.

Returns
Complete JSON document text, empty on error.

◆ reorganizeEITs()

def tsduck.SectionFile.reorganizeEITs (   self,
  year = 0,
  month = 0,
  day = 0 
)

Reorganize all EIT sections according to ETSI TS 101 211.

Only one EITp/f subtable is kept per service. It is split in two sections if two events (present and following) are specified. All EIT schedule are kept. But they are completely reorganized. All events are extracted and spread over new EIT sections according to ETSI TS 101 211 rules.

The "last midnight" according to which EIT segments are assigned is derived from parameters year, month and day. If any of them is out or range, the start time of the oldest event in the section file is used as "reference date".

Parameters
yearYear of the reference time for EIT schedule. This is the "last midnight" according to which EIT segments are assigned.
monthMonth (1..12) of the reference time for EIT schedule.
dayDay (1..31) of the reference time for EIT schedule.
Returns
None.
See also
ETSI TS 101 211, section 4.1.4

Member Data Documentation

◆ CRC32_IGNORE

int tsduck.SectionFile.CRC32_IGNORE = 0
static

Ignore the section CRC32 when loading a binary section.

This is the default.


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