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

Digital TV tuner emulator. More...

Inheritance diagram for ts::TunerEmulator:
Collaboration diagram for ts::TunerEmulator:

Public Member Functions

 TunerEmulator (DuckContext &duck)
 Constructor. More...
 
virtual ~TunerEmulator () override
 Destructor.
 
virtual void abort (bool silent=false)
 Abort any pending or blocked reception. More...
 
virtual bool close (bool silent=false) override
 Close the tuner. More...
 
virtual const DeliverySystemSetdeliverySystems () const override
 Set of delivery systems which are supported by the tuner. More...
 
virtual UString deviceInfo () const override
 Device-specific information. More...
 
virtual UString deviceName () const override
 Get the device name of the tuner. More...
 
virtual UString devicePath () const override
 System-specific device path (for information only). More...
 
virtual std::ostream & displayStatus (std::ostream &strm, const UString &margin=UString(), bool extended=false) override
 Display the characteristics and status of the tuner. More...
 
virtual bool getCurrentTuning (ModulationArgs &params, bool reset_unknown) override
 Get the current tuning parameters. More...
 
virtual bool getSignalState (SignalState &state) override
 Check if a signal is present and get the signal state. More...
 
virtual bool infoOnly () const override
 Get the open mode. More...
 
virtual bool isOpen () const override
 Check if the tuner is open. More...
 
virtual bool open (const UString &device_name, bool info_only) override
 Open the tuner. More...
 
virtual size_t receive (TSPacket *buffer, size_t max_packets, const AbortInterface *abort=nullptr) override
 Receive packets. More...
 
virtual MilliSecond receiveTimeout () const
 Get the timeout for receive operation. More...
 
Reportreport () const
 Get a reference to the error report. More...
 
virtual void setDemuxBufferSize (size_t s)
 Set the demux buffer size in bytes (Linux-specific). More...
 
virtual void setReceiverFilterName (const UString &name)
 Specify a receiver filter name (Windows-specific). More...
 
virtual bool setReceiveTimeout (MilliSecond t)
 Set the timeout for receive operations. More...
 
virtual void setSignalPoll (MilliSecond t)
 Set the poll interval for signal timeout (Linux-specific). More...
 
virtual void setSignalTimeout (MilliSecond t)
 Set the timeout before getting a signal on start. More...
 
virtual void setSignalTimeoutSilent (bool silent)
 Set if an error should be reported on timeout before getting a signal on start. More...
 
virtual void setSinkQueueSize (size_t s)
 Set the max number of queued media samples (Windows-specific). More...
 
virtual bool start () override
 Start receiving packets. More...
 
virtual bool stop (bool silent=false) override
 Stop receiving packets. More...
 
virtual bool tune (ModulationArgs &params) override
 Tune to the specified parameters. More...
 

Static Public Member Functions

static bool GetAllTuners (DuckContext &duck, TunerPtrVector &tuners)
 Get the list of all existing physical tuners. More...
 

Static Public Attributes

static constexpr size_t DEFAULT_DEMUX_BUFFER_SIZE = 1024 * 1024
 Default demux buffer size in bytes (Linux-specific).
 
static constexpr MilliSecond DEFAULT_SIGNAL_POLL = 100
 Default poll interval for signal timeout (Linux-specific).
 
static constexpr MilliSecond DEFAULT_SIGNAL_TIMEOUT = 5000
 Default timeout before getting a signal on start.
 
static constexpr size_t DEFAULT_SINK_QUEUE_SIZE = 1000
 Default max number of queued media samples (Windows-specific). More...
 

Protected Member Functions

bool checkTuneParameters (ModulationArgs &params) const
 Check the consistency of tune() parameters. More...
 
bool unimplemented () const
 Helper for unimplemented methods. More...
 

Protected Attributes

DuckContext_duck
 TSDuck execution context for subclasses.
 

Detailed Description

Digital TV tuner emulator.

A tuner emulator implements the TunerBase interface without physical tuner. The "device name" is the name of an XML file which describes the tuner configuration.

A tuner configuration contains a list of frequencies. The "tuner" can tune around each of these frequencies (center frequency with a given bandwidth). Each frequency is associated with a TS file. When the emulated tuner is tuned to a valid frequency, the reception is emulated by reading packets from the associated TS file again and again.

Sample XML tuner emulator configuration:

<?xml version="1.0" encoding="UTF-8"?>
<tsduck>
<defaults delivery="DVB-T" bandwidth="4,000,000" directory="/home/user/streams"/>
<channel frequency="474,000,000" file="mux1.ts"/>
<channel frequency="482,000,000" file="mux2.ts"/>
<channel frequency="490,000,000" file="mux3.ts"/>
<channel frequency="498,000,000" file="mux4.ts"/>
<channel frequency="506,000,000" file="mux5.ts"/>
<channel frequency="514,000,000" file="mux6.ts"/>
<channel frequency="522,000,000" file="mux7.ts"/>
<channel frequency="530,000,000" file="mux8.ts" delivery="DVB-T2" bandwidth="6,000,000"/>
</tsduck>

Sample tuning test using this tuner emulator. The various TS files are read as if they were actual muxes:

tsscan -d etuner.xml --uhf-band --first-channel 21 --last-channel 28 --service-list

Constructor & Destructor Documentation

◆ TunerEmulator()

ts::TunerEmulator::TunerEmulator ( DuckContext duck)

Constructor.

Parameters
[in,out]duckTSDuck execution context.

Member Function Documentation

◆ open()

virtual bool ts::TunerEmulator::open ( const UString device_name,
bool  info_only 
)
overridevirtual

Open the tuner.

Parameters
[in]device_nameTuner device name. If name is empty, use "first" or "default" tuner.
[in]info_onlyIf true, we will only fetch the properties of the tuner, we won't use it to receive streams. Thus, it is possible to open tuners which are already used to actually receive a stream.
Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ close()

virtual bool ts::TunerEmulator::close ( bool  silent = false)
overridevirtual

Close the tuner.

Parameters
[in]silentWhen true, do not report close errors.
Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ isOpen()

virtual bool ts::TunerEmulator::isOpen ( ) const
overridevirtual

Check if the tuner is open.

Returns
True if the tuner is open.

Reimplemented from ts::TunerBase.

◆ infoOnly()

virtual bool ts::TunerEmulator::infoOnly ( ) const
overridevirtual

Get the open mode.

Returns
True if the tuner is open to fetch information only. In that case, the tuner cannot receive streams.

Reimplemented from ts::TunerBase.

◆ deliverySystems()

virtual const DeliverySystemSet& ts::TunerEmulator::deliverySystems ( ) const
overridevirtual

Set of delivery systems which are supported by the tuner.

Returns
A constant reference to the set of delivery systems which are supported by the tuner.

Reimplemented from ts::TunerBase.

◆ deviceName()

virtual UString ts::TunerEmulator::deviceName ( ) const
overridevirtual

Get the device name of the tuner.

Returns
The device name of the tuner.

Reimplemented from ts::TunerBase.

◆ deviceInfo()

virtual UString ts::TunerEmulator::deviceInfo ( ) const
overridevirtual

Device-specific information.

Returns
A string with device-specific information. Can be empty.

Reimplemented from ts::TunerBase.

◆ devicePath()

virtual UString ts::TunerEmulator::devicePath ( ) const
overridevirtual

System-specific device path (for information only).

Returns
A string with system-specific device path. Can be empty.

Reimplemented from ts::TunerBase.

◆ getSignalState()

virtual bool ts::TunerEmulator::getSignalState ( SignalState state)
overridevirtual

Check if a signal is present and get the signal state.

Parameters
[out]stateReturned state of the tuner. Some fields may be unset if unavailable with that tuner.
Returns
True in case of success (even if no signal was detected), false on error.

Reimplemented from ts::TunerBase.

◆ tune()

virtual bool ts::TunerEmulator::tune ( ModulationArgs params)
overridevirtual

Tune to the specified parameters.

Parameters
[in,out]paramsTuning parameters. Updated with missing default values.
Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ start()

virtual bool ts::TunerEmulator::start ( )
overridevirtual

Start receiving packets.

Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ stop()

virtual bool ts::TunerEmulator::stop ( bool  silent = false)
overridevirtual

Stop receiving packets.

Parameters
[in]silentWhen true, do not report close errors.
Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ receive()

virtual size_t ts::TunerEmulator::receive ( TSPacket buffer,
size_t  max_packets,
const AbortInterface abort = nullptr 
)
overridevirtual

Receive packets.

Parameters
[out]bufferAddress of TS packet receive buffer. Read only complete 188-byte TS packets.
[in]max_packetsMaximum number of packets to read in buffer.
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
Returns
The number of actually received packets (in the range 1 to max_packets). Returning zero means error or end of input.

Reimplemented from ts::TunerBase.

◆ getCurrentTuning()

virtual bool ts::TunerEmulator::getCurrentTuning ( ModulationArgs params,
bool  reset_unknown 
)
overridevirtual

Get the current tuning parameters.

Parameters
[in,out]paramsReturned tuning parameters. Modify only the properties which can be reported by the tuner.
[in]reset_unknownIf true, the unknown values (those which are not reported by the tuner) are reset to unknown/zero/auto values. Otherwise, they are left unmodified.
Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ displayStatus()

virtual std::ostream& ts::TunerEmulator::displayStatus ( std::ostream &  strm,
const UString margin = UString(),
bool  extended = false 
)
overridevirtual

Display the characteristics and status of the tuner.

Parameters
[in,out]strmOutput text stream.
[in]marginLeft margin to display.
[in]extendedDisplay "extended" information. Can be very verbose.
Returns
A reference to strm.

Reimplemented from ts::TunerBase.

◆ GetAllTuners()

static bool ts::TunerBase::GetAllTuners ( DuckContext duck,
TunerPtrVector tuners 
)
staticinherited

Get the list of all existing physical tuners.

Parameters
[in,out]duckTSDuck execution context.
[out]tunersReturned list of physical tuners on the system.
Returns
True on success, false on error.

◆ abort()

virtual void ts::TunerBase::abort ( bool  silent = false)
virtualinherited

Abort any pending or blocked reception.

This unblocks a blocked reader but leaves the tuner in an undefined state. The only safe option after this is a close().

Parameters
[in]silentWhen true, do not report close errors.

Reimplemented in ts::TunerDevice, ts::TunerDevice, and ts::Tuner.

◆ setSignalTimeout()

virtual void ts::TunerBase::setSignalTimeout ( MilliSecond  t)
virtualinherited

Set the timeout before getting a signal on start.

If zero, do not wait for signal on start. Must be set before start().

Parameters
[in]tNumber of milliseconds to wait after start() before receiving a signal.

Reimplemented in ts::TunerDevice, ts::TunerDevice, and ts::Tuner.

◆ setSignalTimeoutSilent()

virtual void ts::TunerBase::setSignalTimeoutSilent ( bool  silent)
virtualinherited

Set if an error should be reported on timeout before getting a signal on start.

Must be set before start().

Parameters
[in]silentIf true, no error message will be reported if no signal is received after the timeout on start.

Reimplemented in ts::TunerDevice, ts::TunerDevice, and ts::Tuner.

◆ setReceiveTimeout()

virtual bool ts::TunerBase::setReceiveTimeout ( MilliSecond  t)
virtualinherited

Set the timeout for receive operations.

Parameters
[in]tNumber of milliseconds to wait before receiving packets in a receive() operation. If zero (the default), no timeout is applied.
Returns
True on success, false on error.

Reimplemented in ts::TunerDevice, ts::TunerDevice, and ts::Tuner.

◆ receiveTimeout()

virtual MilliSecond ts::TunerBase::receiveTimeout ( ) const
virtualinherited

Get the timeout for receive operation.

Returns
The timeout for receive operation.
See also
setReceiveTimeout()

Reimplemented in ts::TunerDevice, ts::TunerDevice, and ts::Tuner.

◆ setSignalPoll()

virtual void ts::TunerBase::setSignalPoll ( MilliSecond  t)
virtualinherited

Set the poll interval for signal timeout (Linux-specific).

Must be set before start(). This is a Linux-specific method which does nothing on other systems.

Parameters
[in]tPoll interval in milliseconds.

Reimplemented in ts::TunerDevice, and ts::Tuner.

◆ setDemuxBufferSize()

virtual void ts::TunerBase::setDemuxBufferSize ( size_t  s)
virtualinherited

Set the demux buffer size in bytes (Linux-specific).

Must be set before start(). This is a Linux-specific method which does nothing on other systems.

Parameters
[in]sThe demux buffer size in bytes.

Reimplemented in ts::TunerDevice, and ts::Tuner.

◆ setSinkQueueSize()

virtual void ts::TunerBase::setSinkQueueSize ( size_t  s)
virtualinherited

Set the max number of queued media samples (Windows-specific).

Must be set before start(). This is a Windows-specific method which does nothing on other systems.

Parameters
[in]sMax number of media samples in the queue between the graph thread and the application thread.

Reimplemented in ts::TunerDevice, and ts::Tuner.

◆ setReceiverFilterName()

virtual void ts::TunerBase::setReceiverFilterName ( const UString name)
virtualinherited

Specify a receiver filter name (Windows-specific).

Must be set before open(). This is a Windows-specific method which does nothing on other systems.

Parameters
[in]nameName of the receiver filter to use. The DirectShow graph will use the specified receiver filter instead of the standard search algorithm.

Reimplemented in ts::TunerDevice, and ts::Tuner.

◆ report()

Report& ts::TunerBase::report ( ) const
inlineinherited

Get a reference to the error report.

Returns
A reference to the error report.

◆ checkTuneParameters()

bool ts::TunerBase::checkTuneParameters ( ModulationArgs params) const
protectedinherited

Check the consistency of tune() parameters.

Parameters
[in,out]paramsModulation parameters. Updated with default values.
Returns
True on success, false on error.

◆ unimplemented()

bool ts::TunerBase::unimplemented ( ) const
protectedinherited

Helper for unimplemented methods.

Display a standard error message.

Returns
False.

Member Data Documentation

◆ DEFAULT_SINK_QUEUE_SIZE

constexpr size_t ts::TunerBase::DEFAULT_SINK_QUEUE_SIZE = 1000
staticconstexprinherited

Default max number of queued media samples (Windows-specific).

See also
setSinkQueueSize().

The documentation for this class was generated from the following file:
tsduck.version
def version()
TSDuck version as a string.
Definition: tsduck.py:199