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 "libmythbase/mythconfig.h"
10#include "dtvchannel.h"
11#include "frequencies.h"
12
13#if CONFIG_V4L2
14#include <linux/videodev2.h>
15#endif
16
17// NOLINTNEXTLINE(cppcoreguidelines-macro-usage,modernize-macro-to-enum)
18#define FAKE_VIDEO 0
19
20class TVRec;
21
32class V4LChannel : public DTVChannel
33{
34 public:
35 V4LChannel(TVRec *parent, QString videodevice,
36 QString audiodevice = "")
37 : DTVChannel(parent), m_device(std::move(videodevice)),
38 m_audioDevice(std::move(audiodevice)) {}
39 ~V4LChannel(void) override;
40
41 bool Init(QString &startchannel, bool setchan) override; // ChannelBase
42
43 // Commands
44 bool Open(void) override; // ChannelBase
45 void Close(void) override; // ChannelBase
46 using DTVChannel::Tune;
47 bool Tune(const DTVMultiplex &tuning) override; // DTVChannel
48 bool Tune(uint64_t frequency) override; // DTVChannel
49 bool Tune(const QString &freqid, int finetune) override; // DTVChannel
50 bool Retune(void) override; // ChannelBase
51
52 // Sets
53 void SetFd(int fd) override; // ChannelBase
54 int SetFreqTable(const QString &name) override; // ChannelBase
55 void SetFormat(const QString &format) override; // DTVChannel
56 int SetDefaultFreqTable(const QString &name);
57
58 // Gets
59 bool IsOpen(void) const override // ChannelBase
60 { return GetFd() >= 0; }
61 int GetFd(void) const override // ChannelBase
62 { return m_videoFd; }
63 QString GetDevice(void) const override // ChannelBase
64 { return m_device; }
65 QString GetAudioDevice(void) const { return m_audioDevice; }
66 static QString GetSIStandard(void) { return "atsc"; }
67
68 // Picture attributes.
69 bool InitPictureAttributes(void) override; // ChannelBase
70 int GetPictureAttribute(PictureAttribute attr) const override; // ChannelBase
72 PictureAttribute attr, bool up) override; // ChannelBase
73
74 protected:
75 bool IsExternalChannelChangeSupported(void) override // ChannelBase
76 { return true; }
77
78 private:
79 // Helper Sets
80 void SetFreqTable(int index);
81 bool SetInputAndFormat(int inputNum, const QString& newFmt);
82
83 // Helper Gets
84 int GetCurrentChannelNum(const QString &channame);
85 QString GetFormatForChannel(const QString& channum,
86 const QString& inputname);
87
88 // Helper Commands
89 bool InitPictureAttribute(const QString &db_col_name);
90 bool InitializeInputs(void);
91
92 private:
93 // Data
94 QString m_device;
96 int m_videoFd {-1};
97 QString m_deviceName;
98 QString m_driverName;
99 QMap<QString,int> m_pictAttrDefault;
100
102
103 bool m_hasStreamIO {false};
104 bool m_hasStdIO {false};
105 bool m_hasAsyncIO {false};
106 bool m_hasTuner {false};
107 bool m_hasSlicedVbi {false};
108
112};
113
114#endif
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
Definition: v4lchannel.h:33
QString GetAudioDevice(void) const
Definition: v4lchannel.h:65
bool m_hasAsyncIO
Definition: v4lchannel.h:105
bool m_hasSlicedVbi
Definition: v4lchannel.h:107
int GetFd(void) const override
Returns file descriptor, -1 if it does not exist.
Definition: v4lchannel.h:61
bool m_hasStdIO
Definition: v4lchannel.h:104
int GetCurrentChannelNum(const QString &channame)
Definition: v4lchannel.cpp:339
~V4LChannel(void) override
Definition: v4lchannel.cpp:39
int m_videoFd
Definition: v4lchannel.h:96
bool SetInputAndFormat(int inputNum, const QString &newFmt)
Definition: v4lchannel.cpp:494
int ChangePictureAttribute(PictureAdjustType type, PictureAttribute attr, bool up) override
Definition: v4lchannel.cpp:752
int GetPictureAttribute(PictureAttribute attr) const override
Definition: v4lchannel.cpp:673
bool m_hasTuner
Definition: v4lchannel.h:106
CHANLIST_vec m_curList
Definition: v4lchannel.h:101
QString m_deviceName
Definition: v4lchannel.h:97
QString GetFormatForChannel(const QString &channum, const QString &inputname)
Definition: v4lchannel.cpp:471
QMap< QString, int > m_pictAttrDefault
Definition: v4lchannel.h:99
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: v4lchannel.h:59
bool m_hasStreamIO
Definition: v4lchannel.h:103
bool InitializeInputs(void)
This enumerates the inputs, converts the format string to something the hardware understands,...
Definition: v4lchannel.cpp:228
int SetDefaultFreqTable(const QString &name)
Definition: v4lchannel.cpp:295
bool InitPictureAttribute(const QString &db_col_name)
Definition: v4lchannel.cpp:591
void Close(void) override
Closes the channel changing hardware to use.
Definition: v4lchannel.cpp:110
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: v4lchannel.h:63
QString m_device
Definition: v4lchannel.h:94
bool Retune(void) override
Retunes to last tuned frequency.
Definition: v4lchannel.cpp:446
int SetFreqTable(const QString &name) override
Definition: v4lchannel.cpp:306
static QString GetSIStandard(void)
Definition: v4lchannel.h:66
bool InitPictureAttributes(void) override
Definition: v4lchannel.cpp:665
int m_videoModeV4L2
Definition: v4lchannel.h:111
QString m_audioDevice
Definition: v4lchannel.h:95
bool Open(void) override
Opens the channel changing hardware for use.
Definition: v4lchannel.cpp:54
QString m_driverName
Definition: v4lchannel.h:98
int m_inputNumV4L
Definition: v4lchannel.h:110
bool Init(QString &startchannel, bool setchan) override
Definition: v4lchannel.cpp:44
bool IsExternalChannelChangeSupported(void) override
Definition: v4lchannel.h:75
void SetFormat(const QString &format) override
Initializes tuner and modulator variables.
Definition: v4lchannel.cpp:273
void SetFd(int fd) override
Sets file descriptor.
Definition: v4lchannel.cpp:117
int m_defaultFreqTable
Definition: v4lchannel.h:109
V4LChannel(TVRec *parent, QString videodevice, QString audiodevice="")
Definition: v4lchannel.h:35
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
Definition: v4lchannel.cpp:375
std::vector< struct CHANLIST > CHANLIST_vec
Definition: frequencies.h:103
PictureAdjustType
Definition: tv.h:124
PictureAttribute