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

Digital TV tuner physical device. More...

#include <tsTunerDevice.h>

Inheritance diagram for ts::TunerDevice:
Collaboration diagram for ts::TunerDevice:

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

static constexpr size_t DEFAULT_DEMUX_BUFFER_SIZE = 1024 * 1024
 Default demux buffer size in bytes (Linux-specific).
 
static constexpr cn::milliseconds DEFAULT_SIGNAL_POLL = cn::milliseconds(100)
 Default poll interval for signal timeout (Linux-specific).
 
static constexpr cn::milliseconds DEFAULT_SIGNAL_TIMEOUT = cn::seconds(5)
 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).
 

Protected Member Functions

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

Protected Attributes

DuckContext_duck
 TSDuck execution context for subclasses.
 

Detailed Description

Digital TV tuner physical device.

One version of this class exists for each operating system.

Constructor & Destructor Documentation

◆ TunerDevice() [1/2]

ts::TunerDevice::TunerDevice ( DuckContext duck)

Constructor.

Parameters
[in,out]duckTSDuck execution context.

◆ TunerDevice() [2/2]

ts::TunerDevice::TunerDevice ( DuckContext duck)

Constructor.

Parameters
[in,out]duckTSDuck execution context.

Member Function Documentation

◆ open() [1/2]

virtual bool ts::TunerDevice::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() [1/2]

virtual bool ts::TunerDevice::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() [1/2]

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

Check if the tuner is open.

Returns
True if the tuner is open.

Reimplemented from ts::TunerBase.

◆ infoOnly() [1/2]

virtual bool ts::TunerDevice::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() [1/2]

virtual const DeliverySystemSet & ts::TunerDevice::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() [1/2]

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

Get the device name of the tuner.

Returns
The device name of the tuner.

Reimplemented from ts::TunerBase.

◆ deviceInfo() [1/2]

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

Device-specific information.

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

Reimplemented from ts::TunerBase.

◆ devicePath() [1/2]

virtual UString ts::TunerDevice::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() [1/2]

virtual bool ts::TunerDevice::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() [1/2]

virtual bool ts::TunerDevice::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() [1/2]

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

Start receiving packets.

Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ stop() [1/2]

virtual bool ts::TunerDevice::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.

◆ abort() [1/2]

virtual void ts::TunerDevice::abort ( bool  silent = false)
overridevirtual

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 from ts::TunerBase.

◆ receive() [1/2]

virtual size_t ts::TunerDevice::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() [1/2]

virtual bool ts::TunerDevice::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.

◆ setSignalTimeout() [1/2]

virtual void ts::TunerDevice::setSignalTimeout ( cn::milliseconds  t)
overridevirtual

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 from ts::TunerBase.

◆ setSignalTimeoutSilent() [1/2]

virtual void ts::TunerDevice::setSignalTimeoutSilent ( bool  silent)
overridevirtual

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 from ts::TunerBase.

◆ setReceiveTimeout() [1/2]

virtual bool ts::TunerDevice::setReceiveTimeout ( cn::milliseconds  t)
overridevirtual

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 from ts::TunerBase.

◆ receiveTimeout() [1/2]

virtual cn::milliseconds ts::TunerDevice::receiveTimeout ( ) const
overridevirtual

Get the timeout for receive operation.

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

Reimplemented from ts::TunerBase.

◆ setSignalPoll()

virtual void ts::TunerDevice::setSignalPoll ( cn::milliseconds  t)
overridevirtual

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 from ts::TunerBase.

◆ setDemuxBufferSize()

virtual void ts::TunerDevice::setDemuxBufferSize ( size_t  s)
overridevirtual

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 from ts::TunerBase.

◆ displayStatus() [1/2]

virtual std::ostream & ts::TunerDevice::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.

◆ open() [2/2]

virtual bool ts::TunerDevice::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() [2/2]

virtual bool ts::TunerDevice::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() [2/2]

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

Check if the tuner is open.

Returns
True if the tuner is open.

Reimplemented from ts::TunerBase.

◆ infoOnly() [2/2]

virtual bool ts::TunerDevice::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() [2/2]

virtual const DeliverySystemSet & ts::TunerDevice::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() [2/2]

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

Get the device name of the tuner.

Returns
The device name of the tuner.

Reimplemented from ts::TunerBase.

◆ deviceInfo() [2/2]

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

Device-specific information.

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

Reimplemented from ts::TunerBase.

◆ devicePath() [2/2]

virtual UString ts::TunerDevice::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() [2/2]

virtual bool ts::TunerDevice::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() [2/2]

virtual bool ts::TunerDevice::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() [2/2]

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

Start receiving packets.

Returns
True on success, false on error.

Reimplemented from ts::TunerBase.

◆ stop() [2/2]

virtual bool ts::TunerDevice::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.

◆ abort() [2/2]

virtual void ts::TunerDevice::abort ( bool  silent = false)
overridevirtual

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 from ts::TunerBase.

◆ receive() [2/2]

virtual size_t ts::TunerDevice::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() [2/2]

virtual bool ts::TunerDevice::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.

◆ setSignalTimeout() [2/2]

virtual void ts::TunerDevice::setSignalTimeout ( cn::milliseconds  t)
overridevirtual

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 from ts::TunerBase.

◆ setSignalTimeoutSilent() [2/2]

virtual void ts::TunerDevice::setSignalTimeoutSilent ( bool  silent)
overridevirtual

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 from ts::TunerBase.

◆ setReceiveTimeout() [2/2]

virtual bool ts::TunerDevice::setReceiveTimeout ( cn::milliseconds  t)
overridevirtual

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 from ts::TunerBase.

◆ receiveTimeout() [2/2]

virtual cn::milliseconds ts::TunerDevice::receiveTimeout ( ) const
overridevirtual

Get the timeout for receive operation.

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

Reimplemented from ts::TunerBase.

◆ setSinkQueueSize()

virtual void ts::TunerDevice::setSinkQueueSize ( size_t  s)
overridevirtual

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 from ts::TunerBase.

◆ setReceiverFilterName()

virtual void ts::TunerDevice::setReceiverFilterName ( const UString name)
overridevirtual

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 from ts::TunerBase.

◆ displayStatus() [2/2]

virtual std::ostream & ts::TunerDevice::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.

◆ 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 files: