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