MythTV  master
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 <v4lchannel.h>

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

Public Member Functions

 V4LChannel (TVRec *parent, const QString &videodevice, const QString &audiodevice="")
 
virtual ~V4LChannel (void)
 
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
 This tunes on the frequency Identification parameter for hardware that supports it. More...
 
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
 
QString GetSIStandard (void) const
 
bool InitPictureAttributes (void) override
 
int GetPictureAttribute (PictureAttribute) const override
 
int ChangePictureAttribute (PictureAdjustType, PictureAttribute, 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 (const QString &freqid, int finetune) override
 This tunes on the frequency Identification parameter for hardware that supports it. More...
 
virtual bool Tune (uint64_t frequency)
 
- Public Member Functions inherited from DTVChannel
 DTVChannel (TVRec *parent)
 
virtual ~DTVChannel ()
 
bool SetChannelByString (const QString &chan) override
 
QString GetFormat (void)
 
virtual bool TuneMultiplex (uint mplexid, 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...
 
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 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 &tuningmode)
 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 srcid, 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)
 

Protected Member Functions

bool IsExternalChannelChangeSupported (void) override
 
- Protected Member Functions inherited from DTVChannel
void SetSIStandard (const QString &)
 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_restrtiction) 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 &newchan)
 
bool ChangeInternalChannel (const QString &newchan, uint cardinputid)
 

Private Member Functions

void SetFreqTable (const int index)
 
int SetFreqTable (const QString &name) override
 
bool SetInputAndFormat (int newcapchannel, QString newFmt)
 
int GetCurrentChannelNum (const QString &channame)
 
QString GetFormatForChannel (QString channum, QString inputname)
 
bool InitPictureAttribute (const QString &db_col_name)
 
bool InitializeInputs (void)
 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. More...
 

Private Attributes

QString device
 
QString audio_device
 
int videofd
 
QString device_name
 
QString driver_name
 
QMap< QString, int > pict_attr_default
 
struct CHANLISTcurList
 
int totalChannels
 
bool has_stream_io
 
bool has_std_io
 
bool has_async_io
 
bool has_tuner
 
bool has_sliced_vbi
 
VidModV4L2 videomode_v4l2
 Current video mode if 'usingv4l2' is true. More...
 
int defaultFreqTable
 
int m_inputNumV4L
 
int m_videoModeV4L2
 

Additional Inherited Members

- Public Types inherited from DTVChannel
typedef DTVChannelDTVChannelP
 
- Static Public Member Functions inherited from DTVChannel
static DTVChannelGetMasterLock (const QString &key)
 
static void ReturnMasterLock (DTVChannelP &)
 
- Static Public Member Functions inherited from ChannelBase
static ChannelBaseCreateChannel (TVRec *tv_rec, const GeneralDBOptions &genOpt, const DVBDBOptions &dvbOpt, const FireWireDBOptions &fwOpt, const QString &startchannel, bool enter_power_save_mode, QString &rbFileExt, bool setchan)
 
- Protected Types inherited from DTVChannel
typedef QMap< QString, QList< DTVChannel * > > MasterMap
 
- Protected Attributes inherited from DTVChannel
QMutex dtvinfo_lock
 
DTVTunerType tunerType
 
QString sistandard
 PSIP table standard: MPEG, DVB, ATSC, OpenCable. More...
 
QString tuningMode
 
QString m_tvFormat
 
int currentProgramNum
 
uint currentATSCMajorChannel
 
uint currentATSCMinorChannel
 
uint currentTransportID
 
uint currentOriginalNetworkID
 
ProgramAssociationTablegenPAT
 This is a generated PAT for RAW pid tuning. More...
 
ProgramMapTablegenPMT
 This is a generated PMT for RAW pid tuning. More...
 
- Protected Attributes inherited from ChannelBase
TVRecm_pParent
 
QString m_curchannelname
 
bool m_commfree
 
uint m_inputid
 
uint m_sourceid
 
QString m_name
 
QString m_startChanNum
 
QString m_externalChanger
 
QString m_tuneToChannel
 
ChannelInfoList m_channels
 channels across all inputs More...
 
QMutex m_system_lock
 
MythSystemLegacym_system
 
uint m_system_status
 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 master_map_lock
 
static MasterMap 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 32 of file v4lchannel.h.

Constructor & Destructor Documentation

◆ V4LChannel()

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

Definition at line 37 of file v4lchannel.cpp.

◆ ~V4LChannel()

V4LChannel::~V4LChannel ( void  )
virtual

Definition at line 52 of file v4lchannel.cpp.

Member Function Documentation

◆ Init()

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

Reimplemented from ChannelBase.

Definition at line 57 of file v4lchannel.cpp.

◆ Open()

bool V4LChannel::Open ( void  )
overridevirtual

Opens the channel changing hardware for use.

Implements ChannelBase.

Definition at line 67 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 122 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 392 of file v4lchannel.cpp.

Referenced by Tune().

◆ Tune() [2/8]

bool V4LChannel::Tune ( uint64_t  frequency)
overridevirtual

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.

Reimplemented from DTVChannel.

Definition at line 406 of file v4lchannel.cpp.

◆ Tune() [3/8]

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

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.

Reimplemented from DTVChannel.

Definition at line 371 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 466 of file v4lchannel.cpp.

◆ SetFd()

void V4LChannel::SetFd ( int  fd)
overridevirtual

Sets file descriptor.

Reimplemented from ChannelBase.

Definition at line 129 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 286 of file v4lchannel.cpp.

Referenced by Init(), and Open().

◆ SetDefaultFreqTable()

int V4LChannel::SetDefaultFreqTable ( const QString &  name)

Definition at line 308 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.

◆ 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(), and V4L2encSignalMonitor::UpdateValues().

◆ GetAudioDevice()

QString V4LChannel::GetAudioDevice ( void  ) const
inline

Definition at line 62 of file v4lchannel.h.

Referenced by V4L2encRecorder::Open(), and V4L2encSignalMonitor::UpdateValues().

◆ GetSIStandard()

QString V4LChannel::GetSIStandard ( void  ) const
inline

Definition at line 63 of file v4lchannel.h.

◆ InitPictureAttributes()

bool V4LChannel::InitPictureAttributes ( void  )
overridevirtual

Reimplemented from ChannelBase.

Definition at line 688 of file v4lchannel.cpp.

◆ GetPictureAttribute()

int V4LChannel::GetPictureAttribute ( PictureAttribute  attr) const
overridevirtual

Reimplemented from ChannelBase.

Definition at line 696 of file v4lchannel.cpp.

Referenced by ChangePictureAttribute().

◆ ChangePictureAttribute()

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

Reimplemented from ChannelBase.

Definition at line 779 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 ( const int  index)
private

Definition at line 314 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 320 of file v4lchannel.cpp.

◆ SetInputAndFormat()

bool V4LChannel::SetInputAndFormat ( int  newcapchannel,
QString  newFmt 
)
private

Definition at line 515 of file v4lchannel.cpp.

Referenced by SetFormat().

◆ GetCurrentChannelNum()

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

Definition at line 356 of file v4lchannel.cpp.

Referenced by Tune().

◆ GetFormatForChannel()

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

Definition at line 493 of file v4lchannel.cpp.

◆ InitPictureAttribute()

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

Definition at line 612 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 240 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 59 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 64 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 76 of file dtvchannel.h.

◆ Tune() [8/8]

virtual bool DTVChannel::Tune
inline

Definition at line 82 of file dtvchannel.h.

Member Data Documentation

◆ device

QString V4LChannel::device
private

Definition at line 92 of file v4lchannel.h.

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

◆ audio_device

QString V4LChannel::audio_device
private

Definition at line 93 of file v4lchannel.h.

◆ videofd

int V4LChannel::videofd
private

◆ device_name

QString V4LChannel::device_name
private

Definition at line 95 of file v4lchannel.h.

Referenced by InitPictureAttribute(), and Open().

◆ driver_name

QString V4LChannel::driver_name
private

Definition at line 96 of file v4lchannel.h.

Referenced by Open().

◆ pict_attr_default

QMap<QString,int> V4LChannel::pict_attr_default
private

Definition at line 97 of file v4lchannel.h.

Referenced by GetPictureAttribute(), and InitPictureAttribute().

◆ curList

struct CHANLIST* V4LChannel::curList
private

Definition at line 99 of file v4lchannel.h.

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

◆ totalChannels

int V4LChannel::totalChannels
private

Definition at line 100 of file v4lchannel.h.

Referenced by GetCurrentChannelNum(), and SetFreqTable().

◆ has_stream_io

bool V4LChannel::has_stream_io
private

Definition at line 102 of file v4lchannel.h.

Referenced by Open(), and SetInputAndFormat().

◆ has_std_io

bool V4LChannel::has_std_io
private

Definition at line 103 of file v4lchannel.h.

Referenced by Open().

◆ has_async_io

bool V4LChannel::has_async_io
private

Definition at line 104 of file v4lchannel.h.

Referenced by Open().

◆ has_tuner

bool V4LChannel::has_tuner
private

Definition at line 105 of file v4lchannel.h.

Referenced by Open().

◆ has_sliced_vbi

bool V4LChannel::has_sliced_vbi
private

Definition at line 106 of file v4lchannel.h.

Referenced by Open().

◆ videomode_v4l2

VidModV4L2 V4LChannel::videomode_v4l2
private

Current video mode if 'usingv4l2' is true.

Definition at line 108 of file v4lchannel.h.

Referenced by InitializeInputs().

◆ defaultFreqTable

int V4LChannel::defaultFreqTable
private

Definition at line 110 of file v4lchannel.h.

Referenced by SetDefaultFreqTable(), and SetFreqTable().

◆ m_inputNumV4L

int V4LChannel::m_inputNumV4L
private

Definition at line 111 of file v4lchannel.h.

Referenced by InitializeInputs(), and SetInputAndFormat().

◆ m_videoModeV4L2

int V4LChannel::m_videoModeV4L2
private

Definition at line 112 of file v4lchannel.h.

Referenced by InitializeInputs(), and SetFormat().


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