MythTV  master
videodisplayprofile.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 using namespace std;
17 
18 #define DEINT_QUALITY_NONE QString("none")
19 #define DEINT_QUALITY_LOW QString("low")
20 #define DEINT_QUALITY_MEDIUM QString("medium")
21 #define DEINT_QUALITY_HIGH QString("high")
22 #define DEINT_QUALITY_SHADER QString("shader")
23 #define DEINT_QUALITY_DRIVER QString("driver")
24 
25 #define VIDEO_MAX_CPUS (16U)
26 
28 {
29  QStringList *renderers;
30  QMap<QString,QStringList> *safe_renderers;
31  QMap<QString,QStringList> *render_group;
32  QMap<QString,uint> *priorities;
33  QStringList *decoders;
34  QMap<QString,QStringList> *equiv_decoders;
35 };
36 
38 {
39  public:
40  ProfileItem() = default;
41  ~ProfileItem() = default;
42 
43  // Sets
44  void Clear(void);
45  void SetProfileID(uint Id);
46  void Set(const QString &Value, const QString &Data);
47 
48  // Gets
49  uint GetProfileID(void) const;
50  QString Get(const QString &Value) const;
51  uint GetPriority(void) const;
52  QMap<QString,QString> GetAll(void) const;
53 
54  // Other
55  bool CheckRange(const QString& Key, float Value, bool *Ok = nullptr) const;
56  bool CheckRange(const QString& Key, int Value, bool *Ok = nullptr) const;
57  bool CheckRange(const QString& Key, float FValue, int IValue, bool IsFloat, bool *Ok = nullptr) const;
58  bool IsMatch(const QSize &Size, float Framerate, const QString &CodecName,
59  const QStringList &DisallowedDecoders = QStringList()) const;
60  bool IsValid(QString *Reason = nullptr) const;
61  bool operator<(const ProfileItem &Other) const;
62  QString toString(void) const;
63 
64  private:
65  uint m_profileid { 0 };
66  QMap<QString,QString> m_pref { };
67 };
68 
70 {
71  public:
73  ~VideoDisplayProfile() = default;
74 
75  void SetInput(const QSize &Size, float Framerate = 0, const QString &CodecName = QString(),
76  const QStringList &DisallowedDecoders = QStringList());
77  void SetOutput(float Framerate);
78  float GetOutput(void) const;
79  void SetVideoRenderer(const QString &VideoRenderer);
80  bool CheckVideoRendererGroup(const QString &Renderer);
81  QString GetDecoder(void) const;
82  bool IsDecoderCompatible(const QString &Decoder);
83  uint GetMaxCPUs(void) const ;
84  bool IsSkipLoopEnabled(void) const;
85  QString GetVideoRenderer(void) const;
86  QString GetActualVideoRenderer(void) const;
87  QString toString(void) const;
88  QString GetSingleRatePreferences(void) const;
89  QString GetDoubleRatePreferences(void) const;
90 
91  // Statics
92  static void InitStatics(bool Reinit = false);
93  static QList<QPair<QString,QString> > GetDeinterlacers(void);
94  static QStringList GetDecoders(void);
95  static QStringList GetDecoderNames(void);
96  static QString GetDecoderName(const QString &Decoder);
97  static QString GetDecoderHelp(const QString &Decoder = QString());
98  static QString GetVideoRendererName(const QString &Renderer);
99  static QString GetDefaultProfileName(const QString &HostName);
100  static void SetDefaultProfileName(const QString &ProfileName, const QString &HostName);
101  static uint GetProfileGroupID(const QString &ProfileName, const QString &HostName);
102  static QStringList GetProfiles(const QString &HostName);
103  static bool DeleteProfileGroup(const QString &GroupName, const QString &HostName);
104  static uint CreateProfileGroup(const QString &ProfileName, const QString &HostName);
105  static void CreateProfile(uint GroupId, uint Priority,
106  const QString& Width, const QString& Height, const QString& Codecs,
107  const QString& Decoder, uint MaxCpus, bool SkipLoop, const QString& VideoRenderer,
108  const QString& Deint1, const QString& Deint2);
109  static void CreateProfiles(const QString &HostName);
110  static QStringList GetVideoRenderers(const QString &Decoder);
111  static QString GetVideoRendererHelp(const QString &Renderer);
112  static QString GetPreferredVideoRenderer(const QString &Decoder);
113  static bool IsFilterAllowed( const QString &VideoRenderer);
114  static QStringList GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers);
115  static QString GetBestVideoRenderer(const QStringList &Renderers);
116  static vector<ProfileItem> LoadDB(uint GroupId);
117  static bool DeleteDB(uint GroupId, const vector<ProfileItem>& Items);
118  static bool SaveDB(uint GroupId, vector<ProfileItem>& Items);
119 
120  private:
121  vector<ProfileItem>::const_iterator
122  FindMatch(const QSize &Size, float Framerate, const QString &CodecName,
123  const QStringList DisallowedDecoders = QStringList());
124  void LoadBestPreferences(const QSize &Size, float Framerate, const QString &CodecName,
125  const QStringList &DisallowedDecoders = QStringList());
126  QString GetPreference(const QString &Key) const;
127  void SetPreference(const QString &Key, const QString &Value);
128 
129  private:
130  mutable QMutex m_lock { QMutex::Recursive };
131  QSize m_lastSize { 0, 0 };
132  float m_lastRate { 0.0F };
133  QString m_lastCodecName { };
134  QString m_lastVideoRenderer { };
135  QMap<QString,QString> m_currentPreferences { };
136  vector<ProfileItem> m_allowedPreferences { };
137 
138  static QMutex s_safe_lock;
139  static bool s_safe_initialized;
140  static QMap<QString,QStringList> s_safe_renderer;
141  static QMap<QString,QStringList> s_safe_renderer_group;
142  static QMap<QString,QStringList> s_safe_equiv_dec;
143  static QStringList s_safe_custom;
144  static QMap<QString,uint> s_safe_renderer_priority;
145  static QMap<QString,QString> s_dec_name;
146  static QMap<QString,QString> s_rend_name;
147  static QStringList s_safe_decoders;
148  static QList<QPair<QString,QString> > s_deinterlacer_options;
149 };
150 
151 #endif // VIDEO_DISPLAY_PROFILE_H_
static QMap< QString, QStringList > s_safe_equiv_dec
static QMap< QString, QString > s_dec_name
static QList< QPair< QString, QString > > s_deinterlacer_options
QString toString(MarkTypes type)
static QMap< QString, uint > s_safe_renderer_priority
QMap< QString, QStringList > * render_group
bool operator<(const ParentalLevel &lhs, const ParentalLevel &rhs)
QMap< QString, QStringList > * safe_renderers
static QMap< QString, QString > s_rend_name
static QMap< QString, QStringList > s_safe_renderer_group
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QStringList * renderers
unsigned int uint
Definition: compat.h:140
QMap< QString, QStringList > * equiv_decoders
QStringList * decoders
static QStringList s_safe_decoders
static QMap< QString, QStringList > s_safe_renderer
static QStringList s_safe_custom
QMap< QString, uint > * priorities
#define Clear(a)