TSDuck v3.40-4025
MPEG Transport Stream Toolkit
|
TSDuck execution context containing current preferences. More...
#include <tsDuckContext.h>
Classes | |
class | SavedArgs |
An opaque class to save all command line options, as loaded by loadArgs(). More... | |
Public Member Functions | |
DuckContext (Report *report=nullptr, std::ostream *output=nullptr) | |
Constructor. | |
PDS | actualPDS (PDS pds) const |
The actual private data specifier to use. | |
void | addDefaultREGID (REGID regid) |
Add a new id at the end of the list of default registration ids. | |
void | addStandards (Standards mask) |
Add a list of standards which are present in the transport stream or context. | |
CASID | casId (CASID cas=CASID_NULL) const |
The actual CAS id to use. | |
const Charset * | charsetIn (const Charset *charset=nullptr) const |
Get the default input character set for strings from tables and descriptors. | |
const Charset * | charsetOut (const Charset *charset=nullptr) const |
Get the preferred output character set for strings to insert in tables and descriptors. | |
bool | decode (UString &str, const uint8_t *data, size_t size) const |
Convert a signalization string into UTF-16 using the default input character set. | |
UString | decoded (const uint8_t *data, size_t size) const |
Convert a signalization string into UTF-16 using the default input character set. | |
UString | decodedWithByteLength (const uint8_t *&data, size_t &size) const |
Convert a signalization string (preceded by its one-byte length) into UTF-16 using the default input character set. | |
bool | decodeWithByteLength (UString &str, const uint8_t *&data, size_t &size) const |
Convert a signalization string (preceded by its one-byte length) into UTF-16 using the default input character set. | |
UString | defaultHFRegion () const |
Get the name of the default region for UVH and VHF band frequency layout. | |
void | defineArgsForCAS (Args &args) |
Define default CAS command line options in an Args. | |
void | defineArgsForCharset (Args &args) |
Define character set command line options in an Args. | |
void | defineArgsForHFBand (Args &args) |
Define HF band command line options in an Args. | |
void | defineArgsForPDS (Args &args) |
Define Private Data Specifier and Registration Id command line options in an Args. | |
void | defineArgsForStandards (Args &args) |
Define contextual standards command line options in an Args. | |
void | defineArgsForTimeReference (Args &args) |
Define time reference command line options in an Args. | |
size_t | encode (uint8_t *&buffer, size_t &size, const UString &str, size_t start=0, size_t count=NPOS) const |
Encode an UTF-16 string into a signalization string using the preferred output character set. | |
ByteBlock | encoded (const UString &str, size_t start=0, size_t count=NPOS) const |
Encode an UTF-16 string into a signalization string using the preferred output character set. | |
ByteBlock | encodedWithByteLength (const UString &str, size_t start=0, size_t count=NPOS) const |
Encode an UTF-16 string into a signalization string (preceded by its one-byte length) using the preferred output character set. | |
size_t | encodeWithByteLength (uint8_t *&buffer, size_t &size, const UString &str, size_t start=0, size_t count=NPOS) const |
Encode an UTF-16 string into a signalization string (preceded by its one-byte length) using the preferred output character set. | |
void | flush () |
Flush the text output. | |
const HFBand * | hfBand (const UString &name, bool silent_band=false) const |
Get the description of an HF band for the default region. | |
bool | loadArgs (Args &args) |
Load the values of all previously defined arguments from command line. | |
std::ostream & | out () const |
Get the current output stream to issue long text output. | |
bool | redirectedOutput () const |
Check if output was redirected. | |
Report & | report () const |
Get the current report for log and error messages. | |
void | reset () |
Reset the TSDuck context to initial configuration. | |
void | resetDefaultREGIDs () |
Reset the list of default registration ids. | |
void | resetStandards (Standards mask=Standards::NONE) |
Reset the list of standards which are present in the transport stream or context. | |
void | restoreArgs (const SavedArgs &args) |
Restore all command line options, as loaded by loadArgs() in another DuckContext. | |
void | saveArgs (SavedArgs &args) const |
Save all command line options, as loaded by loadArgs(). | |
void | setDefaultCASId (CASID cas) |
Set the default CAS id to use. | |
void | setDefaultCharsetIn (const Charset *charset) |
Set the default input character set for strings. | |
void | setDefaultCharsetOut (const Charset *charset) |
Set the preferred output character set for strings. | |
void | setDefaultHFRegion (const UString ®ion) |
Set the name of the default region for UVH and VHF band frequency layout. | |
void | setDefaultPDS (PDS pds) |
Set the default private data specifier to use in the absence of explicit private_data_specifier_descriptor. | |
bool | setOutput (const fs::path &fileName, bool override=true) |
Redirect the output stream to a file. | |
void | setOutput (std::ostream *output, bool override=true) |
Redirect the output stream to a stream. | |
void | setReport (Report *report) |
Set a new report for log and error messages. | |
bool | setTimeReference (const UString &name) |
Set a non-standard time reference offset using a name. | |
void | setTimeReferenceOffset (cn::milliseconds offset) |
Set a non-standard time reference offset. | |
void | setUseLeapSeconds (bool on) |
Set the explicit inclusion of leap seconds where it is needed. | |
Standards | standards () const |
Get the list of standards which are present in the transport stream or context. | |
UString | timeReferenceName () const |
Get the non-standard time reference offset as a string. | |
cn::milliseconds | timeReferenceOffset () const |
Get the non-standard time reference offset. | |
const HFBand * | uhfBand () const |
Get the description of the UHF band for the default region. | |
void | updateREGIDs (REGIDVector ®ids) const |
Update a list of registration ids (typically from a descriptor list) with the default registration ids. | |
bool | useLeapSeconds () const |
Check the explicit inclusion of leap seconds where it is needed. | |
const HFBand * | vhfBand () const |
Get the description of the VHF band for the default region. | |
TSDuck execution context containing current preferences.
An instance of this class contains specific contextual information for the execution of TSDuck. This context contains either user's preferences and accumulated contextual information.
Context information include:
Support is included to define and analyze command line options which define values for the environment.
Unlike DuckConfigFile, this class is not a singleton. More than one context is allowed in the same process as long as the various instances of classes which use DuckContext use only one context at a time. For instance, inside a tsp or tsswitch process, each plugin can use its own context, using different preferences.
The class DuckContext is not thread-safe. It shall be used from one single thread or explicit synchronization is required.
ts::DuckContext::DuckContext | ( | Report * | report = nullptr , |
std::ostream * | output = nullptr |
||
) |
Constructor.
[in] | report | Address of the report for log and error messages. If null, use the standard error. |
[in] | output | The output stream to use, std::cout on null pointer. |
|
inline |
Get the current report for log and error messages.
void ts::DuckContext::setReport | ( | Report * | report | ) |
Set a new report for log and error messages.
[in] | report | Address of the report for log and error messages. If null, use the standard error. |
|
inline |
Get the current output stream to issue long text output.
bool ts::DuckContext::setOutput | ( | const fs::path & | fileName, |
bool | override = true |
||
) |
Redirect the output stream to a file.
[in] | fileName | The file name to create. If empty or equal to "-", reset to std::cout . |
[in] | override | It true, the previous file is closed. If false and the output is already redirected outside std::cout , do nothing. |
void ts::DuckContext::setOutput | ( | std::ostream * | output, |
bool | override = true |
||
) |
Redirect the output stream to a stream.
[in] | output | The output stream to use, std::cout on null pointer. |
[in] | override | It true, the previous file is closed. If false and the output is already redirected outside std::cout , do nothing. |
|
inline |
Check if output was redirected.
Get the default input character set for strings from tables and descriptors.
The default is the DVB superset of ISO/IEC 6937 as defined in ETSI EN 300 468. Other defaults can be used in non-DVB contexts or when a DVB operator uses an incorrect signalization, assuming another default character set (usually from its own country).
[in] | charset | An optional specific character set to use instead of the default one. |
Get the preferred output character set for strings to insert in tables and descriptors.
[in] | charset | An optional specific character set to use instead of the default one. |
|
inline |
Convert a signalization string into UTF-16 using the default input character set.
[out] | str | Returned decoded string. |
[in] | data | Address of an encoded string. |
[in] | size | Size in bytes of the encoded string. |
|
inline |
Convert a signalization string into UTF-16 using the default input character set.
[in] | data | Address of a string in in binary representation (DVB or similar). |
[in] | size | Size in bytes of the string. |
|
inline |
Convert a signalization string (preceded by its one-byte length) into UTF-16 using the default input character set.
[out] | str | Returned decoded string. |
[in,out] | data | Address of an encoded string. The address is updated to point after the decoded value. |
[in,out] | size | Size of the buffer. Updated to remaining size. |
|
inline |
Convert a signalization string (preceded by its one-byte length) into UTF-16 using the default input character set.
[in,out] | data | Address of a buffer containing a string to read. The first byte in the buffer is the length in bytes of the string. Upon return, buffer is updated to point after the end of the string. |
[in,out] | size | Size in bytes of the buffer, which may be larger than the DVB string. Upon return, size is updated, decremented by the same amount buffer was incremented. |
|
inline |
Encode an UTF-16 string into a signalization string using the preferred output character set.
Stop either when this string is serialized or when the buffer is full, whichever comes first.
[in,out] | buffer | Address of the buffer where the signalization string is written. The address is updated to point after the encoded value. |
[in,out] | size | Size of the buffer. Updated to remaining size. |
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inline |
Encode an UTF-16 string into a signalization string using the preferred output character set.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inline |
Encode an UTF-16 string into a signalization string (preceded by its one-byte length) using the preferred output character set.
Stop either when this string is serialized or when the buffer is full or when 255 bytes are written, whichever comes first.
[in,out] | buffer | Address of the buffer where the DVB string is written. The first byte will receive the size in bytes of the DVB string. The address is updated to point after the encoded value. |
[in,out] | size | Size of the buffer. Updated to remaining size. |
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inline |
Encode an UTF-16 string into a signalization string (preceded by its one-byte length) using the preferred output character set.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
void ts::DuckContext::setDefaultCharsetIn | ( | const Charset * | charset | ) |
Set the default input character set for strings.
The default should be the DVB superset of ISO/IEC 6937 as defined in ETSI EN 300 468. Use another default in the context of an operator using an incorrect signalization, assuming another default character set (usually from its own country).
[in] | charset | The new default input character set or a null pointer to revert to the default. |
void ts::DuckContext::setDefaultCharsetOut | ( | const Charset * | charset | ) |
Set the preferred output character set for strings.
[in] | charset | The new preferred output character set or a null pointer to revert to the default. |
|
inline |
Set the default CAS id to use.
[in] | cas | Default CAS id to be used when the CAS is unknown. |
|
inline |
The actual CAS id to use.
[in] | cas | Proposed CAS id. If equal to CASID_NULL, then another value can be returned. |
|
inline |
Set the default private data specifier to use in the absence of explicit private_data_specifier_descriptor.
[in] | pds | Default PDS. Use zero to revert to no default. |
The actual private data specifier to use.
[in] | pds | Current PDS, typically from a private_data_specifier_descriptor. |
|
inline |
Reset the list of default registration ids.
All registration ids, including those coming from --default-registration
options, are deleted.
|
inline |
Add a new id at the end of the list of default registration ids.
[in] | regid | A registration id to add. |
|
inline |
Update a list of registration ids (typically from a descriptor list) with the default registration ids.
The default registration ids mostly come from --default-registration
options. They are inserted at the beginning of regids.
[in,out] | regids | The list of registration ids to update. |
|
inline |
Get the list of standards which are present in the transport stream or context.
void ts::DuckContext::addStandards | ( | Standards | mask | ) |
Add a list of standards which are present in the transport stream or context.
[in] | mask | A bit mask of standards. |
void ts::DuckContext::resetStandards | ( | Standards | mask = Standards::NONE | ) |
Reset the list of standards which are present in the transport stream or context.
[in] | mask | A bit mask of standards. |
|
inline |
Set the name of the default region for UVH and VHF band frequency layout.
[in] | region | Name of the region. Use an empty string to revert to the default. |
UString ts::DuckContext::defaultHFRegion | ( | ) | const |
Get the name of the default region for UVH and VHF band frequency layout.
Get the description of an HF band for the default region.
[in] | name | Name of the HF band to search (e.g. u"UHF", u"VHF", u"BS", u"CS"). |
[in] | silent_band | If true, do not report error message if the band is not found in the file. Other errors (HF band file not found, region not found) are still reported. |
const HFBand * ts::DuckContext::vhfBand | ( | ) | const |
Get the description of the VHF band for the default region.
const HFBand * ts::DuckContext::uhfBand | ( | ) | const |
Get the description of the UHF band for the default region.
|
inline |
Set a non-standard time reference offset.
In DVB SI, reference times are UTC. These SI can be reused in non-standard ways where the stored times use another reference. This is the case with ARIB and ABNT variants of ISDB which reuse TOT, TDT and EIT but with another local time reference.
[in] | offset | Offset from UTC in milli-seconds. Can be positive or negative. The default offset is zero, meaning plain UTC time. |
bool ts::DuckContext::setTimeReference | ( | const UString & | name | ) |
Set a non-standard time reference offset using a name.
[in] | name | Time reference name. The non-standard time reference offset is computed from this name which can be "JST" or "UTC[[+|-]hh[:mm]]". |
|
inline |
Get the non-standard time reference offset.
UString ts::DuckContext::timeReferenceName | ( | ) | const |
Get the non-standard time reference offset as a string.
|
inline |
Set the explicit inclusion of leap seconds where it is needed.
Currently, this applies to SCTE 35 splice_schedule() commands only.
[in] | on | True if leap seconds shall be explicitly included (the default), false to ignore leap seconds. |
|
inline |
Check the explicit inclusion of leap seconds where it is needed.
|
inline |
Define character set command line options in an Args.
Defined options: --default-charset
, --europe
. The context keeps track of defined options so that loadOptions() can parse the appropriate options.
[in,out] | args | Command line arguments to update. |
|
inline |
Define default CAS command line options in an Args.
Defined options: --default-cas-id
and other CAS-specific options. The context keeps track of defined options so that loadOptions() can parse the appropriate options.
[in,out] | args | Command line arguments to update. |
|
inline |
Define Private Data Specifier and Registration Id command line options in an Args.
Defined options: --default-pds
and --default-registration. The context keeps track of defined options so that loadOptions() can parse the appropriate options.
[in,out] | args | Command line arguments to update. |
|
inline |
Define contextual standards command line options in an Args.
Defined options: --atsc
. The context keeps track of defined options so that loadOptions() can parse the appropriate options.
[in,out] | args | Command line arguments to update. |
|
inline |
Define HF band command line options in an Args.
Defined options: --hf-band-region
. The context keeps track of defined options so that loadOptions() can parse the appropriate options.
[in,out] | args | Command line arguments to update. |
|
inline |
Define time reference command line options in an Args.
Defined options: --time-reference
. The context keeps track of defined options so that loadOptions() can parse the appropriate options.
[in,out] | args | Command line arguments to update. |
bool ts::DuckContext::loadArgs | ( | Args & | args | ) |
Load the values of all previously defined arguments from command line.
Args error indicator is set in case of incorrect arguments.
[in,out] | args | Command line arguments. |
void ts::DuckContext::saveArgs | ( | SavedArgs & | args | ) | const |
Save all command line options, as loaded by loadArgs().
[out] | args | Saved arguments. |
void ts::DuckContext::restoreArgs | ( | const SavedArgs & | args | ) |
Restore all command line options, as loaded by loadArgs() in another DuckContext.
[in] | args | Saved arguments to restore. |