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