TSDuck Version 3.32-2769 (TSDuck - The MPEG Transport Stream Toolkit)
ts::ChannelFile Class Reference

An XML file containing the description of TV channels and their networks. More...

Classes

class  Network
 Description of one network. More...
 
class  Service
 Description of one service. More...
 
class  TransportStream
 Description of one transport stream. More...
 

Public Types

typedef SafePtr< Network, MutexNetworkPtr
 Safe pointer to a Network object (thread-safe).
 
typedef std::vector< NetworkPtrNetworkVector
 Vector of safe pointers to Network objects.
 
typedef SafePtr< Service, MutexServicePtr
 Safe pointer to a Service object (thread-safe).
 
typedef std::vector< ServicePtrServiceVector
 Vector of safe pointers to Service objects.
 
typedef SafePtr< TransportStream, MutexTransportStreamPtr
 Safe pointer to a TransportStream object (thread-safe).
 
typedef std::vector< TransportStreamPtrTransportStreamVector
 Vector of safe pointers to TransportStream objects.
 

Public Member Functions

 ChannelFile ()
 Default constructor.
 
void clear ()
 Clear all networks.
 
UString fileDescription () const
 Get a description of the file from which the channel database was loaded. More...
 
UString fileName () const
 Get the file name from which the channel database was loaded. More...
 
bool load (const UString &fileName, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Load an XML file. More...
 
bool load (std::istream &strm, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Load an XML file. More...
 
NetworkPtr networkById (uint16_t id, TunerType type) const
 Get a network by id and type in the file. More...
 
NetworkPtr networkByIndex (size_t index) const
 Get a network by index in the file. More...
 
size_t networkCount () const
 Get the number of networks in the file. More...
 
NetworkPtr networkGetOrCreate (uint16_t id, TunerType type)
 Get or create a network. More...
 
bool parse (const UString &text, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Parse an XML content. More...
 
bool save (const UString &fileName, bool createDirectories=false, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const
 Save an XML file. More...
 
bool searchService (NetworkPtr &net, TransportStreamPtr &ts, ServicePtr &srv, const DeliverySystemSet &delsys, const UString &name, bool strict=true, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const
 Search a service by name in any network of a given type of the file. More...
 
bool searchService (NetworkPtr &net, TransportStreamPtr &ts, ServicePtr &srv, const UString &name, bool strict=true, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const
 Search a service by name in any network of the file. More...
 
bool serviceToTuning (ModulationArgs &tune, const DeliverySystemSet &delsys, const UString &name, bool strict=true, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const
 Get tuner parameters from a service name in any network of a given type of the file. More...
 
bool serviceToTuning (ModulationArgs &tune, const UString &name, bool strict=true, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const
 Get tuner parameters from a service name in any network of the file. More...
 
void setTweaks (const xml::Tweaks &tweaks)
 Set new parsing and formatting tweaks for XML files. More...
 
UString toXML (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const
 Serialize as XML text. More...
 

Static Public Member Functions

static UString DefaultFileName ()
 Default XML channel file name. More...
 

Detailed Description

An XML file containing the description of TV channels and their networks.

The XML template for such files is in file tsduck.channels.model.xml. This is a proprietary XML syntax from TSDuck which is used to replace the deprecated "zap" format from Linux tools such szap or tzap.

The default file location depends on the operating system:

  • Windows: %APPDATA%\tsduck\channels.xml
  • Unix: $HOME/.tsduck.channels.xml

Member Function Documentation

◆ setTweaks()

void ts::ChannelFile::setTweaks ( const xml::Tweaks tweaks)
inline

Set new parsing and formatting tweaks for XML files.

Parameters
[in]tweaksXML tweaks.

◆ load() [1/2]

bool ts::ChannelFile::load ( const UString fileName,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)

Load an XML file.

Parameters
[in]fileNameXML file name. If empty, use the default file name.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ load() [2/2]

bool ts::ChannelFile::load ( std::istream &  strm,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)

Load an XML file.

Parameters
[in,out]strmA standard text stream in input mode.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ parse()

bool ts::ChannelFile::parse ( const UString text,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)

Parse an XML content.

Parameters
[in]textXML file content.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ save()

bool ts::ChannelFile::save ( const UString fileName,
bool  createDirectories = false,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
) const

Save an XML file.

Parameters
[in]fileNameXML file name.
[in]createDirectoriesIf true, also create intermediate directories if necessary.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ toXML()

UString ts::ChannelFile::toXML ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const

Serialize as XML text.

Parameters
[in,out]reportWhere to report errors.
Returns
Complete XML document text, empty on error.

◆ fileName()

UString ts::ChannelFile::fileName ( ) const
inline

Get the file name from which the channel database was loaded.

Returns
The file name. Empty string if no file was loaded.

◆ fileDescription()

UString ts::ChannelFile::fileDescription ( ) const

Get a description of the file from which the channel database was loaded.

Typically used in error or debug messages.

Returns
The file name or description. Never empty.

◆ DefaultFileName()

static UString ts::ChannelFile::DefaultFileName ( )
static

Default XML channel file name.

Returns
The default file name.

◆ networkCount()

size_t ts::ChannelFile::networkCount ( ) const
inline

Get the number of networks in the file.

Returns
The number of networks in the file.

◆ networkByIndex()

NetworkPtr ts::ChannelFile::networkByIndex ( size_t  index) const

Get a network by index in the file.

Parameters
[in]indexNetwork index, from 0 to networkCount()-1.
Returns
A safe pointer to the network or a null pointer if the specified network does not exist.

◆ networkById()

NetworkPtr ts::ChannelFile::networkById ( uint16_t  id,
TunerType  type 
) const

Get a network by id and type in the file.

Parameters
[in]idNetwork identifier.
[in]typeNetwork type.
Returns
A safe pointer to the network or a null pointer if the specified network does not exist.

◆ networkGetOrCreate()

NetworkPtr ts::ChannelFile::networkGetOrCreate ( uint16_t  id,
TunerType  type 
)

Get or create a network.

Parameters
[in]idNetwork identifier.
[in]typeNetwork type.
Returns
A safe pointer to the network, never a null pointer.

◆ searchService() [1/2]

bool ts::ChannelFile::searchService ( NetworkPtr net,
TransportStreamPtr ts,
ServicePtr srv,
const UString name,
bool  strict = true,
Report report = (*(static_cast<ts::Report*>(ts::CerrReport::Instance()))) 
) const
inline

Search a service by name in any network of the file.

Parameters
[out]netReturned network of the service.
[out]tsReturned transport stream of the service.
[out]srvReturned service.
[in]nameService name.
[in]strictIf true, search exactly name. If false, the comparison is case-insensitive and spaces are ignored. If false, name can also be "major.minor" for ATSC services.
[in,out]reportWhere to report errors.
Returns
True if the service is found, false if the specified service does not exist.

◆ searchService() [2/2]

bool ts::ChannelFile::searchService ( NetworkPtr net,
TransportStreamPtr ts,
ServicePtr srv,
const DeliverySystemSet delsys,
const UString name,
bool  strict = true,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
) const

Search a service by name in any network of a given type of the file.

Parameters
[out]netReturned network of the service.
[out]tsReturned transport stream of the service.
[out]srvReturned service.
[in]delsysSearch only for these delivery systems. If empty, search any network.
[in]nameService name.
[in]strictIf true, search exactly name. If false, the comparison is case-insensitive and spaces are ignored. If false, name can also be "major.minor" for ATSC services.
[in,out]reportWhere to report errors.
Returns
True if the service is found, false if the specified service does not exist.

◆ serviceToTuning() [1/2]

bool ts::ChannelFile::serviceToTuning ( ModulationArgs tune,
const UString name,
bool  strict = true,
Report report = (*(static_cast<ts::Report*>(ts::CerrReport::Instance()))) 
) const
inline

Get tuner parameters from a service name in any network of the file.

Parameters
[out]tuneReturned modulation parameters.
[in]nameService name.
[in]strictIf true, search exactly name. If false, the comparison is case-insensitive and spaces are ignored. If false, name can also be "major.minor" for ATSC services.
[in,out]reportWhere to report errors.
Returns
True on success, false if the specified service does not exist.

◆ serviceToTuning() [2/2]

bool ts::ChannelFile::serviceToTuning ( ModulationArgs tune,
const DeliverySystemSet delsys,
const UString name,
bool  strict = true,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
) const

Get tuner parameters from a service name in any network of a given type of the file.

Parameters
[out]tuneReturned modulation parameters. Unmodified if the channel is not found.
[in]delsysSearch only for these delivery systems. If empty, search any network.
[in]nameService name.
[in]strictIf true, search exactly name. If false, the comparison is case-insensitive and spaces are ignored. If false, name can also be "major.minor" for ATSC services.
[in,out]reportWhere to report errors.
Returns
True on success, false if the specified service does not exist.

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