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