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