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 "dtvchannel.h"
7 
8 #ifdef USING_V4L2
9 #include "videodev2.h" // needed for v4l2_std_id type
10 #else
11 typedef uint64_t v4l2_std_id;
12 #endif
13 
14 using namespace std;
15 
16 #define FAKE_VIDEO 0
17 
18 class TVRec;
19 
20 typedef QMap<int,v4l2_std_id> VidModV4L2;
21 
32 class V4LChannel : public DTVChannel
33 {
34  public:
35  V4LChannel(TVRec *parent, const QString &videodevice,
36  const QString &audiodevice = "")
37  : DTVChannel(parent), m_device(videodevice), m_audio_device(audiodevice) {}
38  virtual ~V4LChannel(void);
39 
40  bool Init(QString &startchannel, bool setchan) override; // ChannelBase
41 
42  // Commands
43  bool Open(void) override; // ChannelBase
44  void Close(void) override; // ChannelBase
45  using DTVChannel::Tune;
46  bool Tune(const DTVMultiplex &tuning) override; // DTVChannel
47  bool Tune(uint64_t frequency) override; // DTVChannel
48  bool Tune(const QString &freqid, int finetune) override; // DTVChannel
49  bool Retune(void) override; // ChannelBase
50 
51  // Sets
52  void SetFd(int fd) override; // ChannelBase
53  void SetFormat(const QString &format) override; // DTVChannel
54  int SetDefaultFreqTable(const QString &name);
55 
56  // Gets
57  bool IsOpen(void) const override // ChannelBase
58  { return GetFd() >= 0; }
59  int GetFd(void) const override // ChannelBase
60  { return m_videofd; }
61  QString GetDevice(void) const override // ChannelBase
62  { return m_device; }
63  QString GetAudioDevice(void) const { return m_audio_device; }
64  QString GetSIStandard(void) const { return "atsc"; }
65 
66  // Picture attributes.
67  bool InitPictureAttributes(void) override; // ChannelBase
68  int GetPictureAttribute(PictureAttribute) const override; // ChannelBase
69  int ChangePictureAttribute(PictureAdjustType,
70  PictureAttribute, bool up) override; // ChannelBase
71 
72  protected:
73  bool IsExternalChannelChangeSupported(void) override // ChannelBase
74  { return true; }
75 
76  private:
77  // Helper Sets
78  void SetFreqTable(const int index);
79  int SetFreqTable(const QString &name) override; // ChannelBase
80  bool SetInputAndFormat(int inputNum, const QString& newFmt);
81 
82  // Helper Gets
83  int GetCurrentChannelNum(const QString &channame);
84  QString GetFormatForChannel(const QString& channum,
85  const QString& inputname);
86 
87  // Helper Commands
88  bool InitPictureAttribute(const QString &db_col_name);
89  bool InitializeInputs(void);
90 
91  private:
92  // Data
93  QString m_device;
94  QString m_audio_device;
95  int m_videofd {-1};
96  QString m_device_name;
97  QString m_driver_name;
98  QMap<QString,int> m_pict_attr_default;
99 
100  struct CHANLIST *m_curList {nullptr};
101  int m_totalChannels {0};
102 
103  bool m_has_stream_io {false};
104  bool m_has_std_io {false};
105  bool m_has_async_io {false};
106  bool m_has_tuner {false};
107  bool m_has_sliced_vbi {false};
108 
109  int m_defaultFreqTable {1};
110  int m_inputNumV4L {0};
111  int m_videoModeV4L2 {0};
112 };
113 
114 #endif
QString m_device
Definition: v4lchannel.h:93
QString m_device_name
Definition: v4lchannel.h:96
QMap< QString, int > m_pict_attr_default
Definition: v4lchannel.h:98
bool IsExternalChannelChangeSupported(void) override
Definition: v4lchannel.h:73
V4LChannel(TVRec *parent, const QString &videodevice, const QString &audiodevice="")
Definition: v4lchannel.h:35
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: v4lchannel.h:61
QString GetAudioDevice(void) const
Definition: v4lchannel.h:63
QString m_audio_device
Definition: v4lchannel.h:94
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:150
PictureAttribute
Definition: videoouttypes.h:89
int GetFd(void) const override
Returns file descriptor, -1 if it does not exist.
Definition: v4lchannel.h:59
const char * name
Definition: ParseText.cpp:328
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: v4lchannel.h:57
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
Definition: v4lchannel.h:32
QMap< int, v4l2_std_id > VidModV4L2
Definition: v4lchannel.h:18
QString m_driver_name
Definition: v4lchannel.h:97
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
PictureAdjustType
Definition: tv.h:120
QString GetSIStandard(void) const
Definition: v4lchannel.h:64