MythTV  master
mythvideoprofile.h
Go to the documentation of this file.
1 #ifndef VIDEO_DISPLAY_PROFILE_H_
2 #define VIDEO_DISPLAY_PROFILE_H_
3 
4 // Qt
5 #include <QStringList>
6 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
7 #include <QMutex>
8 #else
9 #include <QRecursiveMutex>
10 #endif
11 #include <QSize>
12 #include <QMap>
13 
14 // MythTV
15 #include "mythtvexp.h"
16 #include "mythcontext.h"
17 
18 // Std
19 #include <vector>
20 
21 #define DEINT_QUALITY_NONE QString("none")
22 #define DEINT_QUALITY_LOW QString("low")
23 #define DEINT_QUALITY_MEDIUM QString("medium")
24 #define DEINT_QUALITY_HIGH QString("high")
25 #define DEINT_QUALITY_SHADER QString("shader")
26 #define DEINT_QUALITY_DRIVER QString("driver")
27 #define UPSCALE_DEFAULT QString("bilinear")
28 #define UPSCALE_HQ1 QString("bicubic")
29 
30 #define COND_WIDTH "cond_width"
31 #define COND_HEIGHT "cond_height"
32 #define COND_RATE "cond_framerate"
33 #define COND_CODECS "cond_codecs"
34 #define PREF_DEC "pref_decoder"
35 #define PREF_CPUS "pref_max_cpus"
36 #define PREF_LOOP "pref_skiploop"
37 #define PREF_RENDER "pref_videorenderer"
38 #define PREF_DEINT1X "pref_deint0"
39 #define PREF_DEINT2X "pref_deint1"
40 #define PREF_PRIORITY "pref_priority"
41 #define PREF_UPSCALE "pref_upscale"
42 
43 #define VIDEO_MAX_CPUS (16U)
44 
46 {
47  QStringList *renderers;
48  QMap<QString,QStringList> *safe_renderers;
49  QMap<QString,QStringList> *render_group;
50  QMap<QString,uint> *priorities;
51  QStringList *decoders;
52  QMap<QString,QStringList> *equiv_decoders;
53 };
54 
56 {
57  public:
58  MythVideoProfileItem() = default;
59  ~MythVideoProfileItem() = default;
60 
61  // Sets
62  void Clear();
63  void SetProfileID(uint Id);
64  void Set(const QString &Value, const QString &Data);
65 
66  // Gets
67  uint GetProfileID() const;
68  QString Get(const QString &Value) const;
69  uint GetPriority() const;
70  QMap<QString,QString> GetAll() const;
71 
72  // Other
73  bool CheckRange(const QString& Key, float Value, bool *Ok = nullptr) const;
74  bool CheckRange(const QString& Key, int Value, bool *Ok = nullptr) const;
75  bool CheckRange(const QString& Key, float FValue, int IValue, bool IsFloat, bool *Ok = nullptr) const;
76  bool IsMatch(QSize Size, float Framerate, const QString &CodecName,
77  const QStringList &DisallowedDecoders = QStringList()) const;
78  auto IsValid() const;
79  bool operator<(const MythVideoProfileItem &Other) const;
80  QString toString() const;
81 
82  private:
83  uint m_profileid { 0 };
84  QMap<QString,QString> m_pref { };
85 };
86 
87 class MTV_PUBLIC MythVideoProfile : public QObject
88 {
89  Q_OBJECT
90 
91  signals:
92  void DeinterlacersChanged(const QString& Single, const QString& Double);
93  void UpscalerChanged(const QString& Upscaler);
94 
95  public:
97  ~MythVideoProfile() override = default;
98 
99  void SetInput(QSize Size, float Framerate = 0, const QString &CodecName = QString(),
100  const QStringList &DisallowedDecoders = QStringList());
101  void SetOutput(float Framerate);
102  float GetOutput() const;
103  void SetVideoRenderer(const QString &VideoRenderer);
104  QString GetDecoder() const;
105  bool IsDecoderCompatible(const QString &Decoder) const;
106  uint GetMaxCPUs() const ;
107  bool IsSkipLoopEnabled() const;
108  QString GetVideoRenderer() const;
109  QString toString() const;
110  QString GetSingleRatePreferences() const;
111  QString GetDoubleRatePreferences() const;
112  QString GetUpscaler() const;
113 
114  // Statics
115  static void InitStatics(bool Reinit = false);
116  static const QList<QPair<QString,QString> >& GetDeinterlacers();
117  static QStringList GetDecoders();
118  static QStringList GetDecoderNames();
119  static std::vector<std::pair<QString,QString>> GetUpscalers();
120  static QString GetDecoderName(const QString &Decoder);
121  static QString GetDecoderHelp(const QString &Decoder = QString());
122  static QString GetVideoRendererName(const QString &Renderer);
123  static QString GetDefaultProfileName(const QString &HostName);
124  static void SetDefaultProfileName(const QString &ProfileName, const QString &HostName);
125  static uint GetProfileGroupID(const QString &ProfileName, const QString &HostName);
126  static QStringList GetProfiles(const QString &HostName);
127  static bool DeleteProfileGroup(const QString &GroupName, const QString &HostName);
128  static uint CreateProfileGroup(const QString &ProfileName, const QString &HostName);
129  static void CreateProfile(uint GroupId, uint Priority,
130  const QString& Width, const QString& Height,
131  const QString& Codecs, const QString& Decoder,
132  uint MaxCpus, bool SkipLoop, const QString& VideoRenderer,
133  const QString& Deint1, const QString& Deint2,
134  const QString& Upscale = UPSCALE_DEFAULT);
135  static void CreateProfiles(const QString &HostName);
136  static QStringList GetVideoRenderers(const QString &Decoder);
137  static QString GetVideoRendererHelp(const QString &Renderer);
138  static QString GetPreferredVideoRenderer(const QString &Decoder);
139  static QStringList GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers);
140  static QString GetBestVideoRenderer(const QStringList &Renderers);
141  static std::vector<MythVideoProfileItem> LoadDB(uint GroupId);
142  static bool DeleteDB(uint GroupId, const std::vector<MythVideoProfileItem>& Items);
143  static bool SaveDB(uint GroupId, std::vector<MythVideoProfileItem>& Items);
144 
145  private:
146  std::vector<MythVideoProfileItem>::const_iterator
147  FindMatch(QSize Size, float Framerate, const QString &CodecName,
148  const QStringList& DisallowedDecoders = QStringList());
149  void LoadBestPreferences(QSize Size, float Framerate, const QString &CodecName,
150  const QStringList &DisallowedDecoders = QStringList());
151  QString GetPreference(const QString &Key) const;
152  void SetPreference(const QString &Key, const QString &Value);
153 
154  private:
155 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
156  mutable QMutex m_lock { QMutex::Recursive };
157 #else
158  mutable QRecursiveMutex m_lock;
159 #endif
160  QSize m_lastSize { 0, 0 };
161  float m_lastRate { 0.0F };
162  QString m_lastCodecName { };
163  QMap<QString,QString> m_currentPreferences { };
164  std::vector<MythVideoProfileItem> m_allowedPreferences { };
165 
166 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
167  static inline QMutex kSafeLock = QMutex(QMutex::Recursive);
168 #else
169  static inline QRecursiveMutex kSafeLock;
170 #endif
171  static inline bool kSafeInitialized = false;
172  static inline QMap<QString,QStringList> kSafeRenderer = {};
173  static inline QMap<QString,QStringList> kSafeRendererGroup = {};
174  static inline QMap<QString,QStringList> kSafeEquivDec = {};
175  static inline QStringList kSafeCustom = {};
176  static inline QMap<QString,uint> kSafeRendererPriority = {};
177  static inline QMap<QString,QString> kDecName = {};
178  static inline QMap<QString,QString> kRendName = {};
179  static inline QStringList kSafeDecoders = {};
180 };
181 
182 #endif
RenderOptions::equiv_decoders
QMap< QString, QStringList > * equiv_decoders
Definition: mythvideoprofile.h:52
MythVideoProfileItem
Definition: mythvideoprofile.h:55
RenderOptions::renderers
QStringList * renderers
Definition: mythvideoprofile.h:47
mythtvexp.h
MythVideoProfile
Definition: mythvideoprofile.h:87
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
RenderOptions::decoders
QStringList * decoders
Definition: mythvideoprofile.h:51
Decoder
Definition: decoder.h:70
RenderOptions
Definition: mythvideoprofile.h:45
RenderOptions::safe_renderers
QMap< QString, QStringList > * safe_renderers
Definition: mythvideoprofile.h:48
MythVideoProfile::kSafeLock
static QRecursiveMutex kSafeLock
Definition: mythvideoprofile.h:169
uint
unsigned int uint
Definition: compat.h:144
RenderOptions::render_group
QMap< QString, QStringList > * render_group
Definition: mythvideoprofile.h:49
MythVideoProfile::m_lock
QRecursiveMutex m_lock
Definition: mythvideoprofile.h:158
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
operator<
bool operator<(const ParentalLevel &lhs, const ParentalLevel &rhs)
Definition: parentalcontrols.cpp:143
UPSCALE_DEFAULT
#define UPSCALE_DEFAULT
Definition: mythvideoprofile.h:27
Clear
#define Clear(a)
Definition: audiooutputopensles.cpp:47
mythcontext.h
Priority
Definition: channelsettings.cpp:191
RenderOptions::priorities
QMap< QString, uint > * priorities
Definition: mythvideoprofile.h:50