MythTV  master
videodisplayprofile.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef _VIDEO_DISPLAY_PROFILE_H_
4 #define _VIDEO_DISPLAY_PROFILE_H_
5 
6 #include <vector>
7 using namespace std;
8 
9 #include <QStringList>
10 #include <QMutex>
11 #include <QSize>
12 #include <QMap>
13 
14 #include "mythtvexp.h"
15 #include "mythcontext.h"
16 
17 typedef QMap<QString,QString> pref_map_t;
18 typedef QMap<QString,QStringList> safe_map_t;
19 typedef QStringList safe_list_t;
20 typedef QMap<QString,uint> priority_map_t;
21 
23 {
32 };
33 
35 {
36  public:
37  ProfileItem() : profileid(0) {}
38  ~ProfileItem() = default;
39 
40  void Clear(void) { pref.clear(); }
41 
42  // Sets
43  void SetProfileID(uint id) { profileid = id; }
44  void Set(const QString &value, const QString &data)
45  { pref[value] = data; }
46 
47 
48  // Gets
49  uint GetProfileID(void) const { return profileid; }
50 
51  QString Get(const QString &value) const
52  {
53  pref_map_t::const_iterator it = pref.find(value);
54  if (it != pref.end())
55  return *it;
56  return QString();
57  }
58 
59  uint GetPriority(void) const
60  {
61  QString tmp = Get("pref_priority");
62  return (tmp.isEmpty()) ? 0 : tmp.toUInt();
63  }
64 
65  pref_map_t GetAll(void) const { return pref; }
66 
67  // Other
68  bool checkRange(QString key, float fvalue, bool *ok = nullptr) const;
69  bool checkRange(QString key, int ivalue, bool *ok = nullptr) const;
70  bool checkRange(const QString& key,
71  float fvalue, int ivalue, bool isFloat, bool *ok = nullptr) const;
72  bool IsMatch(const QSize &size, float framerate, const QString &codecName) const;
73  bool IsValid(QString *reason = nullptr) const;
74 
75  bool operator<(const ProfileItem &other) const;
76 
77  QString toString(void) const;
78 
79  private:
82 };
83 typedef vector<ProfileItem> item_list_t;
84 
86 {
87  public:
89  ~VideoDisplayProfile() = default;
90 
91  void SetInput(const QSize &size,
92  float framerate = 0, const QString &codecName = QString());
93  void SetOutput(float framerate);
94  float GetOutput(void) const { return last_rate; }
95 
96  void SetVideoRenderer(const QString &video_renderer);
97  bool CheckVideoRendererGroup(const QString &renderer);
98 
99  QString GetDecoder(void) const
100  { return GetPreference("pref_decoder"); }
101  bool IsDecoderCompatible(const QString &decoder);
102 
103  uint GetMaxCPUs(void) const
104  { return GetPreference("pref_max_cpus").toUInt(); }
105 
106  bool IsSkipLoopEnabled(void) const
107  { return GetPreference("pref_skiploop").toInt(); }
108 
109  QString GetVideoRenderer(void) const
110  { return GetPreference("pref_videorenderer"); }
111 
112  QString GetOSDRenderer(void) const
113  { return GetPreference("pref_osdrenderer"); }
114  bool IsOSDFadeEnabled(void) const
115  { return GetPreference("pref_osdfade").toInt(); }
116 
117  QString GetDeinterlacer(void) const
118  { return GetPreference("pref_deint0"); }
119  QString GetFallbackDeinterlacer(void) const
120  { return GetPreference("pref_deint1"); }
121 
122  QString GetFilters(void) const
123  { return GetPreference("pref_filters"); }
124 
125  QString GetFilteredDeint(const QString &override);
126 
127  QString toString(void) const;
128 
129  static QStringList GetDecoders(void);
130  static QStringList GetDecoderNames(void);
131  static QString GetDecoderName(const QString &decoder);
132  static QString GetDecoderHelp(const QString& decoder = QString());
133 
134  static QString GetDefaultProfileName(const QString &hostname);
135  static void SetDefaultProfileName(const QString &profilename,
136  const QString &hostname);
137  static uint GetProfileGroupID(const QString &profilename,
138  const QString &hostname);
139  static QStringList GetProfiles(const QString &hostname);
140 
141  static bool DeleteProfileGroup(const QString &groupname,
142  const QString &hostname);
143  static uint CreateProfileGroup(const QString &profilename,
144  const QString &hostname);
145 
146  static void CreateProfile(
147  uint groupid, uint priority,
148  const QString& cmp0, uint width0, uint height0,
149  const QString& cmp1, uint width1, uint height1,
150  QString decoder, uint max_cpus, bool skiploop, QString videorenderer,
151  QString osdrenderer, bool osdfade,
152  QString deint0, QString deint1, QString filters);
153 
154  static void CreateProfile(
155  uint groupid, uint priority,
156  const QString& width, const QString& height, const QString& codecs,
157  const QString& decoder, uint max_cpus, bool skiploop, const QString& videorenderer,
158  const QString& osdrenderer, bool osdfade,
159  const QString& deint0, const QString& deint1, const QString& filters);
160 
161  static void DeleteProfiles(const QString &hostname);
162  static void CreateProfiles(const QString &hostname);
163 
164  static QStringList GetVideoRenderers(const QString &decoder);
165  static QString GetVideoRendererHelp(const QString &renderer);
166  static QString GetPreferredVideoRenderer(const QString &decoder);
167  static QStringList GetDeinterlacers(const QString &video_renderer);
168  static QString GetDeinterlacerName(const QString &short_name);
169  static QString GetDeinterlacerHelp(const QString &deint);
170  static QStringList GetOSDs(const QString &video_renderer);
171  static QString GetOSDHelp(const QString &osd);
172  static bool IsFilterAllowed( const QString &video_renderer);
173 
174  static QStringList GetFilteredRenderers(const QString &decoder,
175  const QStringList &renderers);
176  static QString GetBestVideoRenderer(const QStringList &renderers);
177 
178  static item_list_t LoadDB(uint groupid);
179  static bool DeleteDB(uint groupid, const item_list_t&);
180  static bool SaveDB(uint groupid, item_list_t&);
181 
182  QString GetActualVideoRenderer(void) const
183  { return last_video_renderer; }
184 
185  private:
186  item_list_t::const_iterator FindMatch(const QSize &size,
187  float framerate, const QString &codecName);
188  void LoadBestPreferences(const QSize &size, float framerate, const QString &codecName);
189 
190  QString GetPreference(const QString &key) const;
191  void SetPreference(const QString &key, const QString &value);
192 
193  static void init_statics(void);
194 
195  private:
196  mutable QMutex lock;
197  QSize last_size;
198  float last_rate;
199  QString last_codecName;
203 
204  static QMutex s_safe_lock;
205  static bool s_safe_initialized;
215 };
216 
217 #endif // _VIDEO_DISPLAY_PROFILE_H_
static safe_map_t s_safe_renderer
uint GetProfileID(void) const
priority_map_t * priorities
QString GetFilters(void) const
QMap< QString, QStringList > safe_map_t
uint GetPriority(void) const
QString toString(MarkTypes type)
static safe_list_t s_safe_custom
safe_list_t * renderers
QString GetDeinterlacer(void) const
float GetOutput(void) const
static priority_map_t s_safe_renderer_priority
safe_map_t * deints
static safe_list_t s_safe_decoders
QString GetFallbackDeinterlacer(void) const
unsigned int uint
Definition: compat.h:140
void SetProfileID(uint id)
bool operator<(const ParentalLevel &lhs, const ParentalLevel &rhs)
static guint32 * tmp
Definition: goom_core.c:35
static safe_map_t s_safe_renderer_group
safe_map_t * render_group
QStringList safe_list_t
safe_list_t * decoders
safe_map_t * osds
void Clear(void)
#define MTV_PUBLIC
Definition: mythtvexp.h:15
vector< ProfileItem > item_list_t
QString GetDecoder(void) const
QMap< QString, QString > pref_map_t
safe_map_t * equiv_decoders
string hostname
Definition: caa.py:17
QString GetActualVideoRenderer(void) const
bool IsSkipLoopEnabled(void) const
static pref_map_t s_dec_name
QMap< QString, uint > priority_map_t
static safe_map_t s_safe_deint
static safe_map_t s_safe_equiv_dec
uint GetMaxCPUs(void) const
QString GetOSDRenderer(void) const
safe_map_t * safe_renderers
QString Get(const QString &value) const
pref_map_t GetAll(void) const
static safe_map_t s_safe_osd
void Set(const QString &value, const QString &data)
QString GetVideoRenderer(void) const
bool IsOSDFadeEnabled(void) const