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#define FAKE_VIDEO 0 // NOLINT(cppcoreguidelines-macro-usage)
18
19class TVRec;
20
31class V4LChannel : public DTVChannel
32{
33 public:
34 V4LChannel(TVRec *parent, QString videodevice,
35 QString audiodevice = "")
36 : DTVChannel(parent), m_device(std::move(videodevice)),
37 m_audioDevice(std::move(audiodevice)) {}
38 ~V4LChannel(void) override;
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_audioDevice; }
64 static QString GetSIStandard(void) { return "atsc"; }
65
66 // Picture attributes.
67 bool InitPictureAttributes(void) override; // ChannelBase
68 int GetPictureAttribute(PictureAttribute attr) const override; // ChannelBase
70 PictureAttribute attr, 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(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;
95 int m_videoFd {-1};
96 QString m_deviceName;
97 QString m_driverName;
98 QMap<QString,int> m_pictAttrDefault;
99
101
102 bool m_hasStreamIO {false};
103 bool m_hasStdIO {false};
104 bool m_hasAsyncIO {false};
105 bool m_hasTuner {false};
106 bool m_hasSlicedVbi {false};
107
111};
112
113#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:143
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
Definition: v4lchannel.h:32
QString GetAudioDevice(void) const
Definition: v4lchannel.h:63
bool m_hasAsyncIO
Definition: v4lchannel.h:104
bool m_hasSlicedVbi
Definition: v4lchannel.h:106
int GetFd(void) const override
Returns file descriptor, -1 if it does not exist.
Definition: v4lchannel.h:59
bool m_hasStdIO
Definition: v4lchannel.h:103
int GetCurrentChannelNum(const QString &channame)
Definition: v4lchannel.cpp:339
~V4LChannel(void) override
Definition: v4lchannel.cpp:39
int m_videoFd
Definition: v4lchannel.h:95
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:105
CHANLIST_vec m_curList
Definition: v4lchannel.h:100
QString m_deviceName
Definition: v4lchannel.h:96
QString GetFormatForChannel(const QString &channum, const QString &inputname)
Definition: v4lchannel.cpp:471
QMap< QString, int > m_pictAttrDefault
Definition: v4lchannel.h:98
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: v4lchannel.h:57
bool m_hasStreamIO
Definition: v4lchannel.h:102
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:61
QString m_device
Definition: v4lchannel.h:93
bool Retune(void) override
Retunes to last tuned frequency.
Definition: v4lchannel.cpp:446
static QString GetSIStandard(void)
Definition: v4lchannel.h:64
bool InitPictureAttributes(void) override
Definition: v4lchannel.cpp:665
int m_videoModeV4L2
Definition: v4lchannel.h:110
QString m_audioDevice
Definition: v4lchannel.h:94
bool Open(void) override
Opens the channel changing hardware for use.
Definition: v4lchannel.cpp:54
QString m_driverName
Definition: v4lchannel.h:97
int m_inputNumV4L
Definition: v4lchannel.h:109
bool Init(QString &startchannel, bool setchan) override
Definition: v4lchannel.cpp:44
bool IsExternalChannelChangeSupported(void) override
Definition: v4lchannel.h:73
void SetFreqTable(int index)
Definition: v4lchannel.cpp:301
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:108
V4LChannel(TVRec *parent, QString videodevice, QString audiodevice="")
Definition: v4lchannel.h:34
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
STL namespace.
PictureAdjustType
Definition: tv.h:124
PictureAttribute