MythTV  master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
V4LChannel Class Reference

Implements tuning for TV cards using the V4L driver API, both versions 1 and 2. More...

#include <libmythtv/recorders/v4lchannel.h>

Inheritance diagram for V4LChannel:
[legend]
Collaboration diagram for V4LChannel:
[legend]

Public Member Functions

 V4LChannel (TVRec *parent, QString videodevice, QString audiodevice="")
 
 ~V4LChannel (void) override
 
bool Init (QString &startchannel, bool setchan) override
 
bool Open (void) override
 Opens the channel changing hardware for use. More...
 
void Close (void) override
 Closes the channel changing hardware to use. More...
 
bool Tune (const DTVMultiplex &tuning) override
 This performs the actual frequency tuning and in some cases input switching. More...
 
bool Tune (uint64_t frequency) override
 Tunes to a specific frequency (Hz) on a particular input. More...
 
bool Tune (const QString &freqid, int finetune) override
 
bool Retune (void) override
 Retunes to last tuned frequency. More...
 
void SetFd (int fd) override
 Sets file descriptor. More...
 
void SetFormat (const QString &format) override
 Initializes tuner and modulator variables. More...
 
int SetDefaultFreqTable (const QString &name)
 
bool IsOpen (void) const override
 Reports whether channel is already open. More...
 
int GetFd (void) const override
 Returns file descriptor, -1 if it does not exist. More...
 
QString GetDevice (void) const override
 Returns String representing device, useful for debugging. More...
 
QString GetAudioDevice (void) const
 
bool InitPictureAttributes (void) override
 
int GetPictureAttribute (PictureAttribute attr) const override
 
int ChangePictureAttribute (PictureAdjustType type, PictureAttribute attr, bool up) override
 
virtual bool Tune (const DTVMultiplex &tuning)=0
 This performs the actual frequency tuning and in some cases input switching. More...
 
virtual bool Tune (const IPTVTuningData &, bool)
 Performs IPTV Tuning. Only implemented by IPTVChannel. More...
 
virtual bool Tune (const QString &)
 Leave it up to the implementation to map the channnum appropriately. More...
 
bool Tune ([[maybe_unused]] const QString &freqid,[[maybe_unused]] int finetune) override
 This tunes on the frequency Identification parameter for hardware that supports it. More...
 
virtual bool Tune ([[maybe_unused]] uint64_t frequency)
 
- Public Member Functions inherited from DTVChannel
 DTVChannel (TVRec *parent)
 
 ~DTVChannel () override
 
bool SetChannelByString (const QString &chan) override
 
QString GetFormat (void)
 
virtual bool TuneMultiplex (uint mplexid, const QString &inputname)
 To be used by the channel scanner and possibly the EIT scanner. More...
 
virtual bool Tune (const IPTVTuningData &, bool)
 Performs IPTV Tuning. Only implemented by IPTVChannel. More...
 
virtual bool Tune (const QString &)
 Leave it up to the implementation to map the channnum appropriately. More...
 
virtual bool EnterPowerSavingMode (void)
 Enters power saving mode if the card supports it. More...
 
bool Tune ([[maybe_unused]] const QString &freqid, [[maybe_unused]] int finetune) override
 This tunes on the frequency Identification parameter for hardware that supports it. More...
 
virtual bool Tune ([[maybe_unused]] uint64_t frequency)
 
int GetProgramNumber (void) const
 Returns program number in PAT, -1 if unknown. More...
 
uint GetMajorChannel (void) const
 Returns major channel, 0 if unknown. More...
 
uint GetMinorChannel (void) const
 Returns minor channel, 0 if unknown. More...
 
uint GetOriginalNetworkID (void) const
 Returns DVB original_network_id, 0 if unknown. More...
 
uint GetTransportID (void) const
 Returns DVB transport_stream_id, 0 if unknown. More...
 
QString GetSIStandard (void) const
 Returns PSIP table standard: MPEG, DVB, ATSC, or OpenCable. More...
 
QString GetSuggestedTuningMode (bool is_live_tv) const
 Returns suggested tuning mode: "mpeg", "dvb", or "atsc". More...
 
QString GetTuningMode (void) const
 Returns tuning mode last set by SetTuningMode(). More...
 
virtual std::vector< DTVTunerTypeGetTunerTypes (void) const
 Returns a vector of supported tuning types. More...
 
void GetCachedPids (pid_cache_t &pid_cache) const
 Returns cached MPEG PIDs for last tuned channel. More...
 
void RegisterForMaster (const QString &key)
 
void DeregisterForMaster (const QString &key)
 
virtual bool IsMaster (void) const
 Returns true if this is the first of a number of multi-rec devs. More...
 
virtual bool IsPIDTuningSupported (void) const
 
virtual bool IsIPTV (void) const
 
bool HasGeneratedPAT (void) const
 
bool HasGeneratedPMT (void) const
 
const ProgramAssociationTableGetGeneratedPAT (void) const
 
const ProgramMapTableGetGeneratedPMT (void) const
 
void SetTuningMode (const QString &tuning_mode)
 Sets tuning mode: "mpeg", "dvb", "atsc", etc. More...
 
void SaveCachedPids (const pid_cache_t &pid_cache) const
 Saves MPEG PIDs to cache to database. More...
 
- Public Member Functions inherited from ChannelBase
 ChannelBase (TVRec *parent)
 
virtual ~ChannelBase (void)
 
virtual bool IsTunable (const QString &channum) const
 
virtual bool IsExternalChannelChangeInUse (void)
 
virtual uint GetNextChannel (uint chanid, ChannelChangeDirection direction) const
 
virtual uint GetNextChannel (const QString &channum, ChannelChangeDirection direction) const
 
virtual QString GetChannelName (void) const
 
virtual int GetChanID (void) const
 
virtual int GetInputID (void) const
 
virtual QString GetInputName (void) const
 
virtual uint GetSourceID (void) const
 
bool IsCommercialFree (void) const
 Returns true iff commercial detection is not required. More...
 
virtual void Renumber (uint sourceid, const QString &oldChanNum, const QString &newChanNum)
 Changes a channum if we have it cached anywhere. More...
 
virtual bool InitializeInput (void)
 Fills in input map from DB. More...
 
virtual void StoreInputChannels (void)
 Saves current channel as the default channel for the current input. More...
 
bool CheckChannel (const QString &channum) const
 
void SetInputID (uint _inputid)
 
int GetMajorID (void)
 

Static Public Member Functions

static QString GetSIStandard (void)
 
- Static Public Member Functions inherited from DTVChannel
static DTVChannelGetMasterLock (const QString &key)
 
static void ReturnMasterLock (DTVChannelP &chan)
 
- Static Public Member Functions inherited from ChannelBase
static ChannelBaseCreateChannel (TVRec *tvrec, const GeneralDBOptions &genOpt, const DVBDBOptions &dvbOpt, const FireWireDBOptions &fwOpt, const QString &startchannel, bool enter_power_save_mode, QString &rbFileExt, bool setchan)
 

Protected Member Functions

bool IsExternalChannelChangeSupported (void) override
 
- Protected Member Functions inherited from DTVChannel
void SetSIStandard (const QString &si_std)
 Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable. More...
 
void SetDTVInfo (uint atsc_major, uint atsc_minor, uint dvb_orig_netid, uint mpeg_tsid, int mpeg_pnum)
 
void ClearDTVInfo (void)
 
virtual void CheckOptions (DTVMultiplex &) const
 Checks tuning for problems, and tries to fix them. More...
 
void HandleScriptEnd (bool ok) override
 
- Protected Member Functions inherited from ChannelBase
virtual bool IsInputAvailable (uint &mplexid_restriction, uint &chanid_restriction) const
 Switches to another input on hardware, and sets the channel is setstarting is true. More...
 
bool KillScript (void)
 
void HandleScript (const QString &freqid)
 
uint GetScriptStatus (bool holding_lock=false)
 
bool ChangeExternalChannel (const QString &changer, const QString &freqid)
 
bool ChangeInternalChannel (const QString &freqid, uint cardinputid) const
 

Private Member Functions

void SetFreqTable (int index)
 
int SetFreqTable (const QString &name) override
 
bool SetInputAndFormat (int inputNum, const QString &newFmt)
 
int GetCurrentChannelNum (const QString &channame)
 
QString GetFormatForChannel (const QString &channum, const QString &inputname)
 
bool InitPictureAttribute (const QString &db_col_name)
 
bool InitializeInputs (void)
 

Private Attributes

QString m_device
 
QString m_audioDevice
 
int m_videoFd {-1}
 
QString m_deviceName
 
QString m_driverName
 
QMap< QString, int > m_pictAttrDefault
 
CHANLIST_vec m_curList
 
bool m_hasStreamIO {false}
 
bool m_hasStdIO {false}
 
bool m_hasAsyncIO {false}
 
bool m_hasTuner {false}
 
bool m_hasSlicedVbi {false}
 
int m_defaultFreqTable {1}
 
int m_inputNumV4L {0}
 
int m_videoModeV4L2 {0}
 

Additional Inherited Members

- Public Types inherited from DTVChannel
using DTVChannelP = DTVChannel *
 
- Protected Types inherited from DTVChannel
using MasterMap = QMap< QString, QList< DTVChannel * > >
 
- Protected Attributes inherited from DTVChannel
QMutex m_dtvinfoLock
 
DTVTunerType m_tunerType {DTVTunerType::kTunerTypeUnknown}
 
QString m_sistandard {"mpeg"}
 PSIP table standard: MPEG, DVB, ATSC, OpenCable. More...
 
QString m_tuningMode
 
QString m_tvFormat
 
int m_currentProgramNum {-1}
 
uint m_currentATSCMajorChannel {0}
 
uint m_currentATSCMinorChannel {0}
 
uint m_currentTransportID {0}
 
uint m_currentOriginalNetworkID {0}
 
ProgramAssociationTablem_genPAT {nullptr}
 This is a generated PAT for RAW pid tuning. More...
 
ProgramMapTablem_genPMT {nullptr}
 This is a generated PMT for RAW pid tuning. More...
 
- Protected Attributes inherited from ChannelBase
TVRecm_pParent {nullptr}
 
QString m_curChannelName
 
bool m_commFree {false}
 
uint m_inputId {0}
 
uint m_sourceId {0}
 
QString m_name
 
QString m_startChanNum
 
QString m_externalChanger
 
QString m_tuneToChannel
 
ChannelInfoList m_channels
 channels across all inputs More...
 
QMutex m_systemLock
 
MythSystemLegacym_system {nullptr}
 
uint m_systemStatus {0}
 These get mapped from the GENERIC_EXIT_* to these values for use with the signalmonitor code. More...
 
- Static Protected Attributes inherited from DTVChannel
static QReadWriteLock s_master_map_lock
 
static MasterMap s_master_map
 

Detailed Description

Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.

This class supports a wide range of tuning hardware including frame grabbers (whose output requires encoding), hardware encoders, digital cameras, and non-encoding hardware which simply records pre-encoded broadcast streams.

Definition at line 30 of file v4lchannel.h.

Constructor & Destructor Documentation

◆ V4LChannel()

V4LChannel::V4LChannel ( TVRec parent,
QString  videodevice,
QString  audiodevice = "" 
)
inline

Definition at line 33 of file v4lchannel.h.

◆ ~V4LChannel()

V4LChannel::~V4LChannel ( void  )
override

Definition at line 37 of file v4lchannel.cpp.

Member Function Documentation

◆ Init()

bool V4LChannel::Init ( QString &  startchannel,
bool  setchan 
)
overridevirtual

Reimplemented from ChannelBase.

Definition at line 42 of file v4lchannel.cpp.

◆ Open()

bool V4LChannel::Open ( void  )
overridevirtual

Opens the channel changing hardware for use.

Implements ChannelBase.

Definition at line 52 of file v4lchannel.cpp.

Referenced by SetFormat().

◆ Close()

void V4LChannel::Close ( void  )
overridevirtual

Closes the channel changing hardware to use.

Implements ChannelBase.

Definition at line 108 of file v4lchannel.cpp.

Referenced by Open(), SetFd(), and ~V4LChannel().

◆ Tune() [1/8]

bool V4LChannel::Tune ( const DTVMultiplex tuning)
overridevirtual

This performs the actual frequency tuning and in some cases input switching.

In rare cases such as ASI this does nothing since all the channels are in the same MPTS stream on the same input. But generally you will need to implement this when adding support for new hardware.

Implements DTVChannel.

Definition at line 373 of file v4lchannel.cpp.

Referenced by Tune().

◆ Tune() [2/8]

bool V4LChannel::Tune ( uint64_t  frequency)
override

Tunes to a specific frequency (Hz) on a particular input.

Note
This function always uses modulator zero.
Unlike digital tuning functions this accepts the visual carrier frequency and not the center frequency.
Parameters
frequencyFrequency in Hz, this is divided by 62.5 kHz or 62.5 Hz depending on the modulator and sent to the hardware.

Definition at line 387 of file v4lchannel.cpp.

◆ Tune() [3/8]

bool V4LChannel::Tune ( const QString &  freqid,
int  finetune 
)
overridevirtual

Reimplemented from ChannelBase.

Definition at line 352 of file v4lchannel.cpp.

◆ Retune()

bool V4LChannel::Retune ( void  )
overridevirtual

Retunes to last tuned frequency.

NOTE: This only works for V4L2 and only for analog tuning.

Reimplemented from ChannelBase.

Definition at line 444 of file v4lchannel.cpp.

◆ SetFd()

void V4LChannel::SetFd ( int  fd)
overridevirtual

Sets file descriptor.

Reimplemented from ChannelBase.

Definition at line 115 of file v4lchannel.cpp.

◆ SetFormat()

void V4LChannel::SetFormat ( const QString &  format)
overridevirtual

Initializes tuner and modulator variables.

Parameters
formatOne of twelve formats: "NTSC", "NTSC-JP", "ATSC", "SECAM", "PAL", "PAL-BG", "PAL-DK", "PAL-I", "PAL-60", "PAL-NC", "PAL-M", or "PAL-N"

Reimplemented from DTVChannel.

Definition at line 271 of file v4lchannel.cpp.

Referenced by Init(), and Open().

◆ SetDefaultFreqTable()

int V4LChannel::SetDefaultFreqTable ( const QString &  name)

Definition at line 293 of file v4lchannel.cpp.

Referenced by Init().

◆ IsOpen()

bool V4LChannel::IsOpen ( void  ) const
inlineoverridevirtual

Reports whether channel is already open.

Implements ChannelBase.

Definition at line 56 of file v4lchannel.h.

◆ GetFd()

int V4LChannel::GetFd ( void  ) const
inlineoverridevirtual

Returns file descriptor, -1 if it does not exist.

Reimplemented from ChannelBase.

Definition at line 58 of file v4lchannel.h.

Referenced by IsOpen().

◆ GetDevice()

QString V4LChannel::GetDevice ( void  ) const
inlineoverridevirtual

Returns String representing device, useful for debugging.

Reimplemented from ChannelBase.

Definition at line 60 of file v4lchannel.h.

Referenced by V4L2encRecorder::Open().

◆ GetAudioDevice()

QString V4LChannel::GetAudioDevice ( void  ) const
inline

Definition at line 62 of file v4lchannel.h.

Referenced by V4L2encRecorder::Open().

◆ GetSIStandard()

static QString V4LChannel::GetSIStandard ( void  )
inlinestatic

Definition at line 63 of file v4lchannel.h.

◆ InitPictureAttributes()

bool V4LChannel::InitPictureAttributes ( void  )
overridevirtual

Reimplemented from ChannelBase.

Definition at line 663 of file v4lchannel.cpp.

◆ GetPictureAttribute()

int V4LChannel::GetPictureAttribute ( PictureAttribute  attr) const
overridevirtual

Reimplemented from ChannelBase.

Definition at line 671 of file v4lchannel.cpp.

Referenced by ChangePictureAttribute().

◆ ChangePictureAttribute()

int V4LChannel::ChangePictureAttribute ( PictureAdjustType  type,
PictureAttribute  attr,
bool  up 
)
overridevirtual

Reimplemented from ChannelBase.

Definition at line 750 of file v4lchannel.cpp.

◆ IsExternalChannelChangeSupported()

bool V4LChannel::IsExternalChannelChangeSupported ( void  )
inlineoverrideprotectedvirtual

Reimplemented from ChannelBase.

Definition at line 72 of file v4lchannel.h.

◆ SetFreqTable() [1/2]

void V4LChannel::SetFreqTable ( int  index)
private

Definition at line 299 of file v4lchannel.cpp.

Referenced by SetDefaultFreqTable(), and SetFreqTable().

◆ SetFreqTable() [2/2]

int V4LChannel::SetFreqTable ( const QString &  name)
overrideprivatevirtual

Reimplemented from ChannelBase.

Definition at line 304 of file v4lchannel.cpp.

◆ SetInputAndFormat()

bool V4LChannel::SetInputAndFormat ( int  inputNum,
const QString &  newFmt 
)
private

Definition at line 492 of file v4lchannel.cpp.

Referenced by SetFormat().

◆ GetCurrentChannelNum()

int V4LChannel::GetCurrentChannelNum ( const QString &  channame)
private

Definition at line 337 of file v4lchannel.cpp.

Referenced by Tune().

◆ GetFormatForChannel()

QString V4LChannel::GetFormatForChannel ( const QString &  channum,
const QString &  inputname 
)
private

Definition at line 469 of file v4lchannel.cpp.

◆ InitPictureAttribute()

bool V4LChannel::InitPictureAttribute ( const QString &  db_col_name)
private

Definition at line 589 of file v4lchannel.cpp.

Referenced by InitPictureAttributes().

◆ InitializeInputs()

bool V4LChannel::InitializeInputs ( void  )
private

This enumerates the inputs, converts the format string to something the hardware understands, and if the parent pointer is valid retrieves the channels from the database.

Definition at line 226 of file v4lchannel.cpp.

Referenced by Open().

◆ Tune() [4/8]

virtual bool DTVChannel::Tune

This performs the actual frequency tuning and in some cases input switching.

In rare cases such as ASI this does nothing since all the channels are in the same MPTS stream on the same input. But generally you will need to implement this when adding support for new hardware.

◆ Tune() [5/8]

virtual bool DTVChannel::Tune
inline

Performs IPTV Tuning. Only implemented by IPTVChannel.

Definition at line 58 of file dtvchannel.h.

◆ Tune() [6/8]

virtual bool DTVChannel::Tune
inline

Leave it up to the implementation to map the channnum appropriately.

Used by the ExternalRecorder.

Definition at line 63 of file dtvchannel.h.

◆ Tune() [7/8]

bool DTVChannel::Tune
inlineoverride

This tunes on the frequency Identification parameter for hardware that supports it.

This is only called when there is no frequency set. This is used to implement "Channel Numbers" in analog tuning scenarios and to implement "Virtual Channels" in the OCUR and Firewire tuners.

Definition at line 75 of file dtvchannel.h.

◆ Tune() [8/8]

virtual bool DTVChannel::Tune
inline

Definition at line 81 of file dtvchannel.h.

Member Data Documentation

◆ m_device

QString V4LChannel::m_device
private

Definition at line 92 of file v4lchannel.h.

Referenced by GetDevice(), Open(), SetFreqTable(), and Tune().

◆ m_audioDevice

QString V4LChannel::m_audioDevice
private

Definition at line 93 of file v4lchannel.h.

Referenced by GetAudioDevice().

◆ m_videoFd

int V4LChannel::m_videoFd {-1}
private

◆ m_deviceName

QString V4LChannel::m_deviceName
private

Definition at line 95 of file v4lchannel.h.

Referenced by InitPictureAttribute(), and Open().

◆ m_driverName

QString V4LChannel::m_driverName
private

Definition at line 96 of file v4lchannel.h.

Referenced by Open().

◆ m_pictAttrDefault

QMap<QString,int> V4LChannel::m_pictAttrDefault
private

Definition at line 97 of file v4lchannel.h.

Referenced by GetPictureAttribute(), and InitPictureAttribute().

◆ m_curList

CHANLIST_vec V4LChannel::m_curList
private

Definition at line 99 of file v4lchannel.h.

Referenced by GetCurrentChannelNum(), SetFreqTable(), and Tune().

◆ m_hasStreamIO

bool V4LChannel::m_hasStreamIO {false}
private

Definition at line 101 of file v4lchannel.h.

Referenced by Open(), and SetInputAndFormat().

◆ m_hasStdIO

bool V4LChannel::m_hasStdIO {false}
private

Definition at line 102 of file v4lchannel.h.

Referenced by Open().

◆ m_hasAsyncIO

bool V4LChannel::m_hasAsyncIO {false}
private

Definition at line 103 of file v4lchannel.h.

Referenced by Open().

◆ m_hasTuner

bool V4LChannel::m_hasTuner {false}
private

Definition at line 104 of file v4lchannel.h.

Referenced by Open().

◆ m_hasSlicedVbi

bool V4LChannel::m_hasSlicedVbi {false}
private

Definition at line 105 of file v4lchannel.h.

Referenced by Open().

◆ m_defaultFreqTable

int V4LChannel::m_defaultFreqTable {1}
private

Definition at line 107 of file v4lchannel.h.

Referenced by SetDefaultFreqTable(), and SetFreqTable().

◆ m_inputNumV4L

int V4LChannel::m_inputNumV4L {0}
private

Definition at line 108 of file v4lchannel.h.

Referenced by InitializeInputs(), and SetInputAndFormat().

◆ m_videoModeV4L2

int V4LChannel::m_videoModeV4L2 {0}
private

Definition at line 109 of file v4lchannel.h.

Referenced by InitializeInputs(), and SetFormat().


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