MythTV  master
v4lchannel.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef V4LCHANNEL_H
4 #define V4LCHANNEL_H
5 
6 #include <utility>
7 
8 // MythTV headers
9 #include "dtvchannel.h"
10 #include "frequencies.h"
11 
12 #ifdef USING_V4L2
13 #include <linux/videodev2.h>
14 #endif
15 
16 #define FAKE_VIDEO 0 // NOLINT(cppcoreguidelines-macro-usage)
17 
18 class TVRec;
19 
30 class V4LChannel : public DTVChannel
31 {
32  public:
33  V4LChannel(TVRec *parent, QString videodevice,
34  QString audiodevice = "")
35  : DTVChannel(parent), m_device(std::move(videodevice)),
36  m_audioDevice(std::move(audiodevice)) {}
37  ~V4LChannel(void) override;
38 
39  bool Init(QString &startchannel, bool setchan) override; // ChannelBase
40 
41  // Commands
42  bool Open(void) override; // ChannelBase
43  void Close(void) override; // ChannelBase
44  using DTVChannel::Tune;
45  bool Tune(const DTVMultiplex &tuning) override; // DTVChannel
46  bool Tune(uint64_t frequency) override; // DTVChannel
47  bool Tune(const QString &freqid, int finetune) override; // DTVChannel
48  bool Retune(void) override; // ChannelBase
49 
50  // Sets
51  void SetFd(int fd) override; // ChannelBase
52  void SetFormat(const QString &format) override; // DTVChannel
53  int SetDefaultFreqTable(const QString &name);
54 
55  // Gets
56  bool IsOpen(void) const override // ChannelBase
57  { return GetFd() >= 0; }
58  int GetFd(void) const override // ChannelBase
59  { return m_videoFd; }
60  QString GetDevice(void) const override // ChannelBase
61  { return m_device; }
62  QString GetAudioDevice(void) const { return m_audioDevice; }
63  static QString GetSIStandard(void) { return "atsc"; }
64 
65  // Picture attributes.
66  bool InitPictureAttributes(void) override; // ChannelBase
67  int GetPictureAttribute(PictureAttribute attr) const override; // ChannelBase
69  PictureAttribute attr, bool up) override; // ChannelBase
70 
71  protected:
72  bool IsExternalChannelChangeSupported(void) override // ChannelBase
73  { return true; }
74 
75  private:
76  // Helper Sets
77  void SetFreqTable(int index);
78  int SetFreqTable(const QString &name) override; // ChannelBase
79  bool SetInputAndFormat(int inputNum, const QString& newFmt);
80 
81  // Helper Gets
82  int GetCurrentChannelNum(const QString &channame);
83  QString GetFormatForChannel(const QString& channum,
84  const QString& inputname);
85 
86  // Helper Commands
87  bool InitPictureAttribute(const QString &db_col_name);
88  bool InitializeInputs(void);
89 
90  private:
91  // Data
92  QString m_device;
93  QString m_audioDevice;
94  int m_videoFd {-1};
95  QString m_deviceName;
96  QString m_driverName;
97  QMap<QString,int> m_pictAttrDefault;
98 
100 
101  bool m_hasStreamIO {false};
102  bool m_hasStdIO {false};
103  bool m_hasAsyncIO {false};
104  bool m_hasTuner {false};
105  bool m_hasSlicedVbi {false};
106 
108  int m_inputNumV4L {0};
110 };
111 
112 #endif
V4LChannel::m_hasSlicedVbi
bool m_hasSlicedVbi
Definition: v4lchannel.h:105
V4LChannel::~V4LChannel
~V4LChannel(void) override
Definition: v4lchannel.cpp:37
DTVMultiplex
Definition: dtvmultiplex.h:24
dtvchannel.h
V4LChannel::Init
bool Init(QString &startchannel, bool setchan) override
Definition: v4lchannel.cpp:42
V4LChannel::InitializeInputs
bool InitializeInputs(void)
Definition: v4lchannel.cpp:226
V4LChannel::GetSIStandard
static QString GetSIStandard(void)
Definition: v4lchannel.h:63
V4LChannel::Open
bool Open(void) override
Opens the channel changing hardware for use.
Definition: v4lchannel.cpp:52
PictureAdjustType
PictureAdjustType
Definition: tv.h:120
V4LChannel::SetFormat
void SetFormat(const QString &format) override
Initializes tuner and modulator variables.
Definition: v4lchannel.cpp:271
frequencies.h
V4LChannel::GetCurrentChannelNum
int GetCurrentChannelNum(const QString &channame)
Definition: v4lchannel.cpp:337
V4LChannel::Close
void Close(void) override
Closes the channel changing hardware to use.
Definition: v4lchannel.cpp:108
DTVChannel::Tune
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
V4LChannel::m_pictAttrDefault
QMap< QString, int > m_pictAttrDefault
Definition: v4lchannel.h:97
V4LChannel::m_curList
CHANLIST_vec m_curList
Definition: v4lchannel.h:99
V4LChannel::m_inputNumV4L
int m_inputNumV4L
Definition: v4lchannel.h:108
V4LChannel::m_device
QString m_device
Definition: v4lchannel.h:92
V4LChannel::GetFd
int GetFd(void) const override
Returns file descriptor, -1 if it does not exist.
Definition: v4lchannel.h:58
V4LChannel::IsOpen
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: v4lchannel.h:56
V4LChannel::m_hasTuner
bool m_hasTuner
Definition: v4lchannel.h:104
V4LChannel::m_driverName
QString m_driverName
Definition: v4lchannel.h:96
V4LChannel::ChangePictureAttribute
int ChangePictureAttribute(PictureAdjustType type, PictureAttribute attr, bool up) override
Definition: v4lchannel.cpp:750
V4LChannel::V4LChannel
V4LChannel(TVRec *parent, QString videodevice, QString audiodevice="")
Definition: v4lchannel.h:33
CHANLIST_vec
std::vector< struct CHANLIST > CHANLIST_vec
Definition: frequencies.h:103
V4LChannel::m_hasStdIO
bool m_hasStdIO
Definition: v4lchannel.h:102
V4LChannel::m_defaultFreqTable
int m_defaultFreqTable
Definition: v4lchannel.h:107
V4LChannel::InitPictureAttributes
bool InitPictureAttributes(void) override
Definition: v4lchannel.cpp:663
V4LChannel::Retune
bool Retune(void) override
Retunes to last tuned frequency.
Definition: v4lchannel.cpp:444
V4LChannel::SetFd
void SetFd(int fd) override
Sets file descriptor.
Definition: v4lchannel.cpp:115
V4LChannel::GetPictureAttribute
int GetPictureAttribute(PictureAttribute attr) const override
Definition: v4lchannel.cpp:671
PictureAttribute
PictureAttribute
Definition: videoouttypes.h:103
V4LChannel::InitPictureAttribute
bool InitPictureAttribute(const QString &db_col_name)
Definition: v4lchannel.cpp:589
V4LChannel::SetDefaultFreqTable
int SetDefaultFreqTable(const QString &name)
Definition: v4lchannel.cpp:293
V4LChannel::Tune
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
Definition: v4lchannel.cpp:373
V4LChannel::GetAudioDevice
QString GetAudioDevice(void) const
Definition: v4lchannel.h:62
V4LChannel::m_videoFd
int m_videoFd
Definition: v4lchannel.h:94
std
Definition: mythchrono.h:23
V4LChannel::m_audioDevice
QString m_audioDevice
Definition: v4lchannel.h:93
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
V4LChannel::SetFreqTable
void SetFreqTable(int index)
Definition: v4lchannel.cpp:299
V4LChannel::m_deviceName
QString m_deviceName
Definition: v4lchannel.h:95
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:33
V4LChannel::SetInputAndFormat
bool SetInputAndFormat(int inputNum, const QString &newFmt)
Definition: v4lchannel.cpp:492
V4LChannel
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
Definition: v4lchannel.h:30
V4LChannel::m_videoModeV4L2
int m_videoModeV4L2
Definition: v4lchannel.h:109
V4LChannel::GetFormatForChannel
QString GetFormatForChannel(const QString &channum, const QString &inputname)
Definition: v4lchannel.cpp:469
V4LChannel::IsExternalChannelChangeSupported
bool IsExternalChannelChangeSupported(void) override
Definition: v4lchannel.h:72
V4LChannel::m_hasAsyncIO
bool m_hasAsyncIO
Definition: v4lchannel.h:103
V4LChannel::GetDevice
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: v4lchannel.h:60
V4LChannel::m_hasStreamIO
bool m_hasStreamIO
Definition: v4lchannel.h:101