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

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

#include <tsChannelFile.h>

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

using NetworkPtr = std::shared_ptr< Network >
 Safe pointer to a Network object (thread-safe).
 
using NetworkVector = std::vector< NetworkPtr >
 Vector of safe pointers to Network objects.
 
using ServicePtr = std::shared_ptr< Service >
 Safe pointer to a Service object (thread-safe).
 
using ServiceVector = std::vector< ServicePtr >
 Vector of safe pointers to Service objects.
 
using TransportStreamPtr = std::shared_ptr< TransportStream >
 Safe pointer to a TransportStream object (thread-safe).
 
using TransportStreamVector = std::vector< TransportStreamPtr >
 Vector of safe pointers to TransportStream objects.
 

Public Member Functions

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

Static Public Member Functions

static UString DefaultFileName ()
 Default XML channel file name.
 

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 = (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 = (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 = (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 = (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 = (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 = (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 = (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 = (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 = (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: