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