MythTV  master
videodisplayprofile.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "videodisplayprofile.h"
3 #include "mythcorecontext.h"
4 #include "mythdb.h"
5 #include "mythlogging.h"
6 #include "mythvideoout.h"
7 #include "avformatdecoder.h"
8 
9 // Std
10 #include <algorithm>
11 #include <utility>
12 
14 {
15  m_pref.clear();
16 }
17 
19 {
20  m_profileid = Id;
21 }
22 
23 void ProfileItem::Set(const QString &Value, const QString &Data)
24 {
25  m_pref[Value] = Data;
26 }
27 
29 {
30  return m_profileid;
31 }
32 
33 QMap<QString,QString> ProfileItem::GetAll(void) const
34 {
35  return m_pref;
36 }
37 
38 QString ProfileItem::Get(const QString &Value) const
39 {
40  QMap<QString,QString>::const_iterator it = m_pref.find(Value);
41  if (it != m_pref.end())
42  return *it;
43  return QString();
44 }
45 
47 {
48  QString tmp = Get("pref_priority");
49  return tmp.isEmpty() ? 0 : tmp.toUInt();
50 }
51 
52 // options are NNN NNN-MMM 0-MMM NNN-99999 >NNN >=NNN <MMM <=MMM or blank
53 // If string is blank then assumes a match.
54 // If value is 0 or negative assume a match (i.e. value unknown assumes a match)
55 // float values must be no more than 3 decimals.
56 bool ProfileItem::CheckRange(const QString &Key, float Value, bool *Ok) const
57 {
58  return CheckRange(Key, Value, 0, true, Ok);
59 }
60 
61 bool ProfileItem::CheckRange(const QString &Key, int Value, bool *Ok) const
62 {
63  return CheckRange(Key, 0.0, Value, false, Ok);
64 }
65 
66 bool ProfileItem::CheckRange(const QString& Key,
67  float FValue, int IValue, bool IsFloat, bool *Ok) const
68 {
69  bool match = true;
70  bool isOK = true;
71  if (IsFloat)
72  IValue = int(FValue * 1000.0F);
73  QString cmp = Get(Key);
74  if (!cmp.isEmpty())
75  {
76  cmp.replace(QLatin1String(" "),QLatin1String(""));
77  QStringList expr = cmp.split("&");
78  for (int ix = 0; ix < expr.size(); ++ix)
79  {
80  if (expr[ix].isEmpty())
81  {
82  isOK = false;
83  continue;
84  }
85  if (IValue > 0)
86  {
87  QRegularExpression regex("^([0-9.]*)([^0-9.]*)([0-9.]*)$");
88  QRegularExpressionMatch rmatch = regex.match(expr[ix]);
89 
90  int value1 = 0;
91  int value2 = 0;
92  QString oper;
93  QString capture1 = rmatch.captured(1);
94  QString capture3;
95  if (!capture1.isEmpty())
96  {
97  if (IsFloat)
98  {
99  int dec=capture1.indexOf('.');
100  if (dec > -1 && (capture1.length()-dec) > 4)
101  isOK = false;
102  if (isOK)
103  {
104  double double1 = capture1.toDouble(&isOK);
105  if (double1 > 2000000.0 || double1 < 0.0)
106  isOK = false;
107  value1 = int(double1 * 1000.0);
108  }
109  }
110  else
111  value1 = capture1.toInt(&isOK);
112  }
113  if (isOK)
114  {
115  oper = rmatch.captured(2);
116  capture3 = rmatch.captured(3);
117  if (!capture3.isEmpty())
118  {
119  if (IsFloat)
120  {
121  int dec=capture3.indexOf('.');
122  if (dec > -1 && (capture3.length()-dec) > 4)
123  isOK = false;
124  if (isOK)
125  {
126  double double1 = capture3.toDouble(&isOK);
127  if (double1 > 2000000.0 || double1 < 0.0)
128  isOK = false;
129  value2 = int(double1 * 1000.0);
130  }
131  }
132  else
133  value2 = capture3.toInt(&isOK);
134  }
135  }
136  if (isOK)
137  {
138  // Invalid string
139  if (value1 == 0 && value2 == 0 && oper.isEmpty())
140  isOK=false;
141  }
142  if (isOK)
143  {
144  // Case NNN
145  if (value1 != 0 && oper.isEmpty() && value2 == 0)
146  {
147  value2 = value1;
148  oper = "-";
149  }
150  // NNN-MMM 0-MMM NNN-99999 NNN- -MMM
151  else if (oper == "-")
152  {
153  // NNN- or -NNN
154  if (capture1.isEmpty() || capture3.isEmpty())
155  isOK = false;
156  // NNN-MMM
157  if (value2 < value1)
158  isOK = false;
159  }
160  else if (capture1.isEmpty())
161  {
162  // Other operators == > < >= <=
163  // Convert to a range
164  if (oper == "==")
165  value1 = value2;
166  else if (oper == ">")
167  {
168  value1 = value2 + 1;
169  value2 = 99999999;
170  }
171  else if (oper == ">=")
172  {
173  value1 = value2;
174  value2 = 99999999;
175  }
176  else if (oper == "<")
177  value2 = value2 - 1;
178  else if (oper == "<=")
179  ;
180  else isOK = false;
181  oper = "-";
182  }
183  }
184  if (isOK)
185  {
186  if (oper == "-")
187  match = match && (IValue >= value1 && IValue <= value2);
188  else isOK = false;
189  }
190  }
191  }
192  }
193  if (Ok != nullptr)
194  *Ok = isOK;
195  if (!isOK)
196  match=false;
197  return match;
198 }
199 
200 bool ProfileItem::IsMatch(const QSize &Size,
201  float Framerate, const QString &CodecName) const
202 {
203  bool match = true;
204 
205  QString cmp;
206 
207  // cond_width, cond_height, cond_codecs, cond_framerate.
208  // These replace old settings pref_cmp0 and pref_cmp1
209  match &= CheckRange("cond_width",Size.width());
210  match &= CheckRange("cond_height",Size.height());
211  match &= CheckRange("cond_framerate",Framerate);
212  // codec
213  cmp = Get(QString("cond_codecs"));
214  if (!cmp.isEmpty())
215  {
216  QStringList clist = cmp.split(" ", QString::SkipEmptyParts);
217  if (!clist.empty())
218  match &= clist.contains(CodecName,Qt::CaseInsensitive);
219  }
220 
221  return match;
222 }
223 
224 bool ProfileItem::IsValid(QString *Reason) const
225 {
226 
227  bool isOK = true;
228  CheckRange("cond_width",1,&isOK);
229  if (!isOK)
230  {
231  if (Reason)
232  *Reason = QString("Invalid width condition");
233  return false;
234  }
235  CheckRange("cond_height",1,&isOK);
236  if (!isOK)
237  {
238  if (Reason)
239  *Reason = QString("Invalid height condition");
240  return false;
241  }
242  CheckRange("cond_framerate",1.0F,&isOK);
243  if (!isOK)
244  {
245  if (Reason)
246  *Reason = QString("Invalid framerate condition");
247  return false;
248  }
249 
250  QString decoder = Get("pref_decoder");
251  QString renderer = Get("pref_videorenderer");
252  if (decoder.isEmpty() || renderer.isEmpty())
253  {
254  if (Reason)
255  *Reason = "Need a decoder and renderer";
256  return false;
257  }
258 
259  QStringList decoders = VideoDisplayProfile::GetDecoders();
260  if (!decoders.contains(decoder))
261  {
262  if (Reason)
263  *Reason = QString("decoder %1 is not available").arg(decoder);
264  return false;
265  }
266 
267  QStringList renderers = VideoDisplayProfile::GetVideoRenderers(decoder);
268  if (!renderers.contains(renderer))
269  {
270  if (Reason)
271  *Reason = QString("renderer %1 is not supported with decoder %2")
272  .arg(renderer).arg(decoder);
273  return false;
274  }
275 
276  if (Reason)
277  *Reason = QString();
278 
279  return true;
280 }
281 
282 bool ProfileItem::operator< (const ProfileItem &Other) const
283 {
284  return GetPriority() < Other.GetPriority();
285 }
286 
287 QString ProfileItem::toString(void) const
288 {
289  QString cmp0 = Get("pref_cmp0");
290  QString cmp1 = Get("pref_cmp1");
291  QString width = Get("cond_width");
292  QString height = Get("cond_height");
293  QString framerate = Get("cond_framerate");
294  QString codecs = Get("cond_codecs");
295  QString decoder = Get("pref_decoder");
296  uint max_cpus = Get("pref_max_cpus").toUInt();
297  bool skiploop = Get("pref_skiploop").toInt() != 0;
298  QString renderer = Get("pref_videorenderer");
299  QString deint0 = Get("pref_deint0");
300  QString deint1 = Get("pref_deint1");
301 
302  QString cond = QString("w(%1) h(%2) framerate(%3) codecs(%4)")
303  .arg(width).arg(height).arg(framerate).arg(codecs);
304  QString str = QString("cmp(%1%2) %7 dec(%3) cpus(%4) skiploop(%5) rend(%6) ")
305  .arg(cmp0).arg(QString(cmp1.isEmpty() ? "" : ",") + cmp1)
306  .arg(decoder).arg(max_cpus).arg((skiploop) ? "enabled" : "disabled").arg(renderer)
307  .arg(cond);
308  str += QString("deint(%1,%2)").arg(deint0).arg(deint1);
309 
310  return str;
311 }
312 
314 
315 #define LOC QString("VDP: ")
316 
317 QMutex VideoDisplayProfile::s_safe_lock(QMutex::Recursive);
319 QMap<QString,QStringList> VideoDisplayProfile::s_safe_renderer;
320 QMap<QString,QStringList> VideoDisplayProfile::s_safe_renderer_group;
321 QMap<QString,QStringList> VideoDisplayProfile::s_safe_equiv_dec;
324 QMap<QString,QString> VideoDisplayProfile::s_dec_name;
325 QMap<QString,QString> VideoDisplayProfile::s_rend_name;
327 QList<QPair<QString,QString> > VideoDisplayProfile::s_deinterlacer_options;
328 
330 {
331  QMutexLocker locker(&s_safe_lock);
332  InitStatics();
333 
334  QString hostname = gCoreContext->GetHostName();
335  QString cur_profile = GetDefaultProfileName(hostname);
336  uint groupid = GetProfileGroupID(cur_profile, hostname);
337 
338  vector<ProfileItem> items = LoadDB(groupid);
339  vector<ProfileItem>::const_iterator it;
340  for (it = items.begin(); it != items.end(); ++it)
341  {
342  QString err;
343  if (!(*it).IsValid(&err))
344  {
345  LOG(VB_GENERAL, LOG_ERR, LOC + "Rejecting: " + (*it).toString() + "\n\t\t\t" + err);
346  continue;
347  }
348 
349  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Accepting: " + (*it).toString());
350  m_allowedPreferences.push_back(*it);
351  }
352 }
353 
354 void VideoDisplayProfile::SetInput(const QSize &Size, float Framerate, const QString &CodecName)
355 {
356  QMutexLocker locker(&m_lock);
357  bool change = false;
358 
359  if (Size != m_lastSize)
360  {
361  m_lastSize = Size;
362  change = true;
363  }
364  if (Framerate > 0.0F && !qFuzzyCompare(Framerate + 1.0F, m_lastRate + 1.0F))
365  {
366  m_lastRate = Framerate;
367  change = true;
368  }
369  if (!CodecName.isEmpty() && CodecName != m_lastCodecName)
370  {
371  m_lastCodecName = CodecName;
372  change = true;
373  }
374  if (change)
376 }
377 
378 void VideoDisplayProfile::SetOutput(float Framerate)
379 {
380  QMutexLocker locker(&m_lock);
381  if (!qFuzzyCompare(Framerate + 1.0F, m_lastRate + 1.0F))
382  {
383  m_lastRate = Framerate;
385  }
386 }
387 
389 {
390  return m_lastRate;
391 }
392 
394 {
395  return GetPreference("pref_decoder");
396 }
397 
399 {
400  return GetPreference("pref_deint0");
401 }
402 
404 {
405  return GetPreference("pref_deint1");
406 }
407 
409 {
410  return GetPreference("pref_max_cpus").toUInt();
411 }
412 
414 {
415  return GetPreference("pref_skiploop").toInt();
416 }
417 
419 {
420  return GetPreference("pref_videorenderer");
421 }
422 
424 {
425  return m_lastVideoRenderer;
426 }
427 
428 void VideoDisplayProfile::SetVideoRenderer(const QString &VideoRenderer)
429 {
430  QMutexLocker locker(&m_lock);
431 
432  LOG(VB_PLAYBACK, LOG_INFO, LOC +
433  QString("SetVideoRenderer(%1)").arg(VideoRenderer));
434 
435  m_lastVideoRenderer = VideoRenderer;
436  if (VideoRenderer == GetVideoRenderer())
437  {
438  LOG(VB_PLAYBACK, LOG_INFO, LOC +
439  QString("SetVideoRender(%1) == GetVideoRenderer()").arg(VideoRenderer));
440  return; // already made preferences safe...
441  }
442 
443  // Make preferences safe...
444  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Old preferences: " + toString());
445 
446  SetPreference("pref_videorenderer", VideoRenderer);
447 
448  LOG(VB_PLAYBACK, LOG_INFO, LOC + "New preferences: " + toString());
449 }
450 
451 bool VideoDisplayProfile::CheckVideoRendererGroup(const QString &Renderer)
452 {
453  if (m_lastVideoRenderer == Renderer || m_lastVideoRenderer == "null")
454  return true;
455 
456  LOG(VB_PLAYBACK, LOG_INFO, LOC +
457  QString("Preferred video renderer: %1 (current: %2)")
458  .arg(Renderer).arg(m_lastVideoRenderer));
459 
460  foreach (const auto & group, s_safe_renderer_group)
461  if (group.contains(m_lastVideoRenderer) && group.contains(Renderer))
462  return true;
463  return false;
464 }
465 
467 {
468  const QString dec = GetDecoder();
469  if (dec == Decoder)
470  return true;
471 
472  QMutexLocker locker(&s_safe_lock);
473  return (s_safe_equiv_dec[dec].contains(Decoder));
474 }
475 
476 QString VideoDisplayProfile::GetPreference(const QString &Key) const
477 {
478  QMutexLocker locker(&m_lock);
479 
480  if (Key.isEmpty())
481  return QString();
482 
483  QMap<QString,QString>::const_iterator it = m_currentPreferences.find(Key);
484  if (it == m_currentPreferences.end())
485  return QString();
486 
487  return *it;
488 }
489 
490 void VideoDisplayProfile::SetPreference(const QString &Key, const QString &Value)
491 {
492  QMutexLocker locker(&m_lock);
493 
494  if (!Key.isEmpty())
495  m_currentPreferences[Key] = Value;
496 }
497 
498 vector<ProfileItem>::const_iterator VideoDisplayProfile::FindMatch
499  (const QSize &Size, float Framerate, const QString &CodecName)
500 {
501  for (auto it = m_allowedPreferences.cbegin(); it != m_allowedPreferences.cend(); ++it)
502  if ((*it).IsMatch(Size, Framerate, CodecName))
503  return it;
504  return m_allowedPreferences.end();
505 }
506 
508  (const QSize &Size, float Framerate, const QString &CodecName)
509 {
510  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("LoadBestPreferences(%1x%2, %3, %4)")
511  .arg(Size.width()).arg(Size.height())
512  .arg(static_cast<double>(Framerate), 0, 'f', 3).arg(CodecName));
513 
514  m_currentPreferences.clear();
515  auto it = FindMatch(Size, Framerate, CodecName);
516  if (it != m_allowedPreferences.end())
517  m_currentPreferences = (*it).GetAll();
518 
519  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("LoadBestPreferences Result "
520  "prio:%1, w:%2, h:%3, fps:%4,"
521  " codecs:%5, decoder:%6, renderer:%7, deint:%8")
522  .arg(GetPreference("pref_priority")).arg(GetPreference("cond_width"))
523  .arg(GetPreference("cond_height")).arg(GetPreference("cond_framerate"))
524  .arg(GetPreference("cond_codecs")).arg(GetPreference("pref_decoder"))
525  .arg(GetPreference("pref_videorenderer")).arg(GetPreference("pref_deint0"))
526  );
527 }
528 
529 vector<ProfileItem> VideoDisplayProfile::LoadDB(uint GroupId)
530 {
532  vector<ProfileItem> list;
533 
534  MSqlQuery query(MSqlQuery::InitCon());
535  query.prepare(
536  "SELECT profileid, value, data "
537  "FROM displayprofiles "
538  "WHERE profilegroupid = :GROUPID "
539  "ORDER BY profileid");
540  query.bindValue(":GROUPID", GroupId);
541  if (!query.exec())
542  {
543  MythDB::DBError("loaddb 1", query);
544  return list;
545  }
546 
547  uint profileid = 0;
548  while (query.next())
549  {
550  if (query.value(0).toUInt() != profileid)
551  {
552  if (profileid)
553  {
554  tmp.SetProfileID(profileid);
555  QString error;
556  bool valid = tmp.IsValid(&error);
557  if (valid)
558  list.push_back(tmp);
559  else
560  LOG(VB_PLAYBACK, LOG_NOTICE, LOC + QString("Ignoring profile %1 (%2)")
561  .arg(profileid).arg(error));
562  }
563  tmp.Clear();
564  profileid = query.value(0).toUInt();
565  }
566  tmp.Set(query.value(1).toString(), query.value(2).toString());
567  }
568  if (profileid)
569  {
570  tmp.SetProfileID(profileid);
571  QString error;
572  bool valid = tmp.IsValid(&error);
573  if (valid)
574  list.push_back(tmp);
575  else
576  LOG(VB_PLAYBACK, LOG_NOTICE, LOC + QString("Ignoring profile %1 (%2)")
577  .arg(profileid).arg(error));
578  }
579 
580  sort(list.begin(), list.end());
581  return list;
582 }
583 
584 bool VideoDisplayProfile::DeleteDB(uint GroupId, const vector<ProfileItem> &Items)
585 {
586  MSqlQuery query(MSqlQuery::InitCon());
587  query.prepare(
588  "DELETE FROM displayprofiles "
589  "WHERE profilegroupid = :GROUPID AND "
590  " profileid = :PROFILEID");
591 
592  bool ok = true;
593  for (const auto & item : Items)
594  {
595  if (!item.GetProfileID())
596  continue;
597 
598  query.bindValue(":GROUPID", GroupId);
599  query.bindValue(":PROFILEID", item.GetProfileID());
600  if (!query.exec())
601  {
602  MythDB::DBError("vdp::deletedb", query);
603  ok = false;
604  }
605  }
606 
607  return ok;
608 }
609 
610 bool VideoDisplayProfile::SaveDB(uint GroupId, vector<ProfileItem> &Items)
611 {
612  MSqlQuery query(MSqlQuery::InitCon());
613 
614  MSqlQuery update(MSqlQuery::InitCon());
615  update.prepare(
616  "UPDATE displayprofiles "
617  "SET data = :DATA "
618  "WHERE profilegroupid = :GROUPID AND "
619  " profileid = :PROFILEID AND "
620  " value = :VALUE");
621 
622  MSqlQuery insert(MSqlQuery::InitCon());
623  insert.prepare(
624  "INSERT INTO displayprofiles "
625  " ( profilegroupid, profileid, value, data) "
626  "VALUES "
627  " (:GROUPID, :PROFILEID, :VALUE, :DATA) ");
628 
629  MSqlQuery sqldelete(MSqlQuery::InitCon());
630  sqldelete.prepare(
631  "DELETE FROM displayprofiles "
632  "WHERE profilegroupid = :GROUPID AND "
633  " profileid = :PROFILEID AND "
634  " value = :VALUE");
635 
636  bool ok = true;
637  for (auto & item : Items)
638  {
639  QMap<QString,QString> list = item.GetAll();
640  if (list.begin() == list.end())
641  continue;
642 
643  QMap<QString,QString>::const_iterator lit = list.begin();
644 
645  if (!item.GetProfileID())
646  {
647  // create new profileid
648  if (!query.exec("SELECT MAX(profileid) FROM displayprofiles"))
649  {
650  MythDB::DBError("save_profile 1", query);
651  ok = false;
652  continue;
653  }
654  if (query.next())
655  {
656  item.SetProfileID(query.value(0).toUInt() + 1);
657  }
658 
659  for (; lit != list.end(); ++lit)
660  {
661  if ((*lit).isEmpty())
662  continue;
663 
664  insert.bindValue(":GROUPID", GroupId);
665  insert.bindValue(":PROFILEID", item.GetProfileID());
666  insert.bindValue(":VALUE", lit.key());
667  insert.bindValue(":DATA", ((*lit).isNull()) ? "" : (*lit));
668  if (!insert.exec())
669  {
670  MythDB::DBError("save_profile 2", insert);
671  ok = false;
672  continue;
673  }
674  }
675  continue;
676  }
677 
678  for (; lit != list.end(); ++lit)
679  {
680  query.prepare(
681  "SELECT count(*) "
682  "FROM displayprofiles "
683  "WHERE profilegroupid = :GROUPID AND "
684  " profileid = :PROFILEID AND "
685  " value = :VALUE");
686  query.bindValue(":GROUPID", GroupId);
687  query.bindValue(":PROFILEID", item.GetProfileID());
688  query.bindValue(":VALUE", lit.key());
689 
690  if (!query.exec())
691  {
692  MythDB::DBError("save_profile 3", query);
693  ok = false;
694  continue;
695  }
696  if (query.next() && (1 == query.value(0).toUInt()))
697  {
698  if (lit->isEmpty())
699  {
700  sqldelete.bindValue(":GROUPID", GroupId);
701  sqldelete.bindValue(":PROFILEID", item.GetProfileID());
702  sqldelete.bindValue(":VALUE", lit.key());
703  if (!sqldelete.exec())
704  {
705  MythDB::DBError("save_profile 5a", sqldelete);
706  ok = false;
707  continue;
708  }
709  }
710  else
711  {
712  update.bindValue(":GROUPID", GroupId);
713  update.bindValue(":PROFILEID", item.GetProfileID());
714  update.bindValue(":VALUE", lit.key());
715  update.bindValue(":DATA", ((*lit).isNull()) ? "" : (*lit));
716  if (!update.exec())
717  {
718  MythDB::DBError("save_profile 5b", update);
719  ok = false;
720  continue;
721  }
722  }
723  }
724  else
725  {
726  insert.bindValue(":GROUPID", GroupId);
727  insert.bindValue(":PROFILEID", item.GetProfileID());
728  insert.bindValue(":VALUE", lit.key());
729  insert.bindValue(":DATA", ((*lit).isNull()) ? "" : (*lit));
730  if (!insert.exec())
731  {
732  MythDB::DBError("save_profile 4", insert);
733  ok = false;
734  continue;
735  }
736  }
737  }
738  }
739 
740  return ok;
741 }
742 
744 {
745  InitStatics();
746  return s_safe_decoders;
747 }
748 
750 {
751  InitStatics();
752  QStringList list;
753 
754  const QStringList decs = GetDecoders();
755  foreach (const auto & dec, decs)
756  list += GetDecoderName(dec);
757 
758  return list;
759 }
760 
762 {
763  if (Decoder.isEmpty())
764  return "";
765 
766  QMutexLocker locker(&s_safe_lock);
767  if (s_dec_name.empty())
768  {
769  s_dec_name["ffmpeg"] = QObject::tr("Standard");
770  s_dec_name["vdpau"] = QObject::tr("NVIDIA VDPAU acceleration");
771  s_dec_name["vdpau-dec"] = QObject::tr("NVIDIA VDPAU acceleration (decode only)");
772  s_dec_name["vaapi"] = QObject::tr("VAAPI acceleration");
773  s_dec_name["vaapi-dec"] = QObject::tr("VAAPI acceleration (decode only)");
774  s_dec_name["dxva2"] = QObject::tr("Windows hardware acceleration");
775  s_dec_name["mediacodec"] = QObject::tr("Android MediaCodec acceleration");
776  s_dec_name["mediacodec-dec"] = QObject::tr("Android MediaCodec acceleration (decode only)");
777  s_dec_name["nvdec"] = QObject::tr("NVIDIA NVDEC acceleration");
778  s_dec_name["nvdec-dec"] = QObject::tr("NVIDIA NVDEC acceleration (decode only)");
779  s_dec_name["vtb"] = QObject::tr("VideoToolbox acceleration");
780  s_dec_name["vtb-dec"] = QObject::tr("VideoToolbox acceleration (decode only)");
781  s_dec_name["v4l2"] = QObject::tr("V4L2 acceleration");
782  s_dec_name["v4l2-dec"] = QObject::tr("V4L2 acceleration (decode only)");
783  s_dec_name["mmal"] = QObject::tr("MMAL acceleration");
784  s_dec_name["mmal-dec"] = QObject::tr("MMAL acceleration (decode only)");
785  s_dec_name["drmprime"] = QObject::tr("DRM PRIME acceleration");
786  }
787 
788  QString ret = Decoder;
789  QMap<QString,QString>::const_iterator it = s_dec_name.find(Decoder);
790  if (it != s_dec_name.end())
791  ret = *it;
792  return ret;
793 }
794 
795 
797 {
798  QString msg = QObject::tr("Processing method used to decode video.");
799 
800  if (Decoder.isEmpty())
801  return msg;
802 
803  msg += "\n";
804 
805  if (Decoder == "ffmpeg")
806  msg += QObject::tr("Standard will use the FFmpeg library for software decoding.");
807 
808  if (Decoder.startsWith("vdpau"))
809  {
810  msg += QObject::tr(
811  "VDPAU will attempt to use the graphics hardware to "
812  "accelerate video decoding.");
813  }
814 
815  if (Decoder.startsWith("vaapi"))
816  {
817  msg += QObject::tr(
818  "VAAPI will attempt to use the graphics hardware to "
819  "accelerate video decoding and playback.");
820  }
821 
822  if (Decoder.startsWith("dxva2"))
823  {
824  msg += QObject::tr(
825  "DXVA2 will use the graphics hardware to "
826  "accelerate video decoding and playback. ");
827  }
828 
829  if (Decoder.startsWith("mediacodec"))
830  {
831  msg += QObject::tr(
832  "Mediacodec will use Android graphics hardware to "
833  "accelerate video decoding and playback. ");
834  }
835 
836  if (Decoder.startsWith("nvdec"))
837  {
838  msg += QObject::tr(
839  "Nvdec uses the NVDEC API to "
840  "accelerate video decoding and playback with NVIDIA Graphics Adapters. ");
841  }
842 
843  if (Decoder.startsWith("vtb"))
844  msg += QObject::tr(
845  "The VideoToolbox library is used to accelerate video decoding. ");
846 
847  if (Decoder.startsWith("mmal"))
848  msg += QObject::tr(
849  "MMAL is used to accelerated video decoding (Raspberry Pi only). ");
850 
851  if (Decoder == "v4l2")
852  msg += "Highly experimental: ";
853 
854  if (Decoder.startsWith("v4l2"))
855  {
856  msg += QObject::tr(
857  "Video4Linux codecs are used to accelerate video decoding on "
858  "supported platforms. ");
859  }
860 
861  if (Decoder == "drmprime")
862  {
863  msg += QObject::tr(
864  "DRM-PRIME decoders are used to accelerate video decoding on "
865  "supported platforms. ");
866  }
867 
868  if (Decoder.endsWith("-dec"))
869  {
870  msg += QObject::tr("The decoder will transfer frames back to system memory "
871  "which will significantly reduce performance but may allow "
872  "other functionality to be used (such as automatic "
873  "letterbox detection). ");
874  }
875  return msg;
876 }
877 
878 QString VideoDisplayProfile::GetVideoRendererName(const QString &Renderer)
879 {
880  QMutexLocker locker(&s_safe_lock);
881  if (s_rend_name.empty())
882  {
883  s_rend_name["opengl"] = QObject::tr("OpenGL");
884  s_rend_name["opengl-yv12"] = QObject::tr("OpenGL YV12");
885  s_rend_name["opengl-hw"] = QObject::tr("OpenGL Hardware");
886  }
887 
888  QString ret = Renderer;
889  QMap<QString,QString>::const_iterator it = s_rend_name.find(Renderer);
890  if (it != s_rend_name.end())
891  ret = *it;
892  return ret;
893 }
894 
895 QStringList VideoDisplayProfile::GetProfiles(const QString &HostName)
896 {
897  InitStatics();
898  QStringList list;
899  MSqlQuery query(MSqlQuery::InitCon());
900  query.prepare(
901  "SELECT name "
902  "FROM displayprofilegroups "
903  "WHERE hostname = :HOST ");
904  query.bindValue(":HOST", HostName);
905  if (!query.exec() || !query.isActive())
906  MythDB::DBError("get_profiles", query);
907  else
908  {
909  while (query.next())
910  list += query.value(0).toString();
911  }
912  return list;
913 }
914 
915 QString VideoDisplayProfile::GetDefaultProfileName(const QString &HostName)
916 {
917  QString tmp =
918  gCoreContext->GetSettingOnHost("DefaultVideoPlaybackProfile", HostName);
919 
920  QStringList profiles = GetProfiles(HostName);
921 
922  tmp = (profiles.contains(tmp)) ? tmp : QString();
923 
924  if (tmp.isEmpty())
925  {
926  if (!profiles.empty())
927  tmp = profiles[0];
928 
929  tmp = (profiles.contains("Normal")) ? "Normal" : tmp;
930 
931  if (!tmp.isEmpty())
932  {
934  "DefaultVideoPlaybackProfile", tmp, HostName);
935  }
936  }
937 
938  return tmp;
939 }
940 
941 void VideoDisplayProfile::SetDefaultProfileName(const QString &ProfileName, const QString &HostName)
942 {
943  gCoreContext->SaveSettingOnHost("DefaultVideoPlaybackProfile", ProfileName, HostName);
944 }
945 
946 uint VideoDisplayProfile::GetProfileGroupID(const QString &ProfileName,
947  const QString &HostName)
948 {
949  MSqlQuery query(MSqlQuery::InitCon());
950  query.prepare(
951  "SELECT profilegroupid "
952  "FROM displayprofilegroups "
953  "WHERE name = :NAME AND "
954  " hostname = :HOST ");
955  query.bindValue(":NAME", ProfileName);
956  query.bindValue(":HOST", HostName);
957 
958  if (!query.exec() || !query.isActive())
959  MythDB::DBError("get_profile_group_id", query);
960  else if (query.next())
961  return query.value(0).toUInt();
962 
963  return 0;
964 }
965 
967  const QString& Width, const QString& Height, const QString& Codecs,
968  const QString& Decoder, uint MaxCpus, bool SkipLoop, const QString& VideoRenderer,
969  const QString& Deint1, const QString& Deint2)
970 {
971  MSqlQuery query(MSqlQuery::InitCon());
972 
973  // create new profileid
974  uint profileid = 1;
975  if (!query.exec("SELECT MAX(profileid) FROM displayprofiles"))
976  MythDB::DBError("create_profile 1", query);
977  else if (query.next())
978  profileid = query.value(0).toUInt() + 1;
979 
980  query.prepare(
981  "INSERT INTO displayprofiles "
982  "VALUES (:GRPID, :PROFID, 'pref_priority', :PRIORITY)");
983  query.bindValue(":GRPID", GroupId);
984  query.bindValue(":PROFID", profileid);
985  query.bindValue(":PRIORITY", Priority);
986  if (!query.exec())
987  MythDB::DBError("create_profile 2", query);
988 
989  QStringList queryValue;
990  QStringList queryData;
991 
992  queryValue += "cond_width";
993  queryData += Width;
994 
995  queryValue += "cond_height";
996  queryData += Height;
997 
998  queryValue += "cond_codecs";
999  queryData += Codecs;
1000 
1001  queryValue += "pref_decoder";
1002  queryData += Decoder;
1003 
1004  queryValue += "pref_max_cpus";
1005  queryData += QString::number(MaxCpus);
1006 
1007  queryValue += "pref_skiploop";
1008  queryData += (SkipLoop) ? "1" : "0";
1009 
1010  queryValue += "pref_videorenderer";
1011  queryData += VideoRenderer;
1012 
1013  queryValue += "pref_deint0";
1014  queryData += Deint1;
1015 
1016  queryValue += "pref_deint1";
1017  queryData += Deint2;
1018 
1019  QStringList::const_iterator itV = queryValue.begin();
1020  QStringList::const_iterator itD = queryData.begin();
1021  for (; itV != queryValue.end() && itD != queryData.end(); ++itV,++itD)
1022  {
1023  if (itD->isEmpty())
1024  continue;
1025  query.prepare(
1026  "INSERT INTO displayprofiles "
1027  "VALUES (:GRPID, :PROFID, :VALUE, :DATA)");
1028  query.bindValue(":GRPID", GroupId);
1029  query.bindValue(":PROFID", profileid);
1030  query.bindValue(":VALUE", *itV);
1031  query.bindValue(":DATA", *itD);
1032  if (!query.exec())
1033  MythDB::DBError("create_profile 3", query);
1034  }
1035 }
1036 
1037 uint VideoDisplayProfile::CreateProfileGroup(const QString &ProfileName, const QString &HostName)
1038 {
1039  MSqlQuery query(MSqlQuery::InitCon());
1040  query.prepare(
1041  "INSERT INTO displayprofilegroups (name, hostname) "
1042  "VALUES (:NAME,:HOST)");
1043 
1044  query.bindValue(":NAME", ProfileName);
1045  query.bindValue(":HOST", HostName);
1046 
1047  if (!query.exec())
1048  {
1049  MythDB::DBError("create_profile_group", query);
1050  return 0;
1051  }
1052 
1053  return GetProfileGroupID(ProfileName, HostName);
1054 }
1055 
1056 bool VideoDisplayProfile::DeleteProfileGroup(const QString &GroupName, const QString &HostName)
1057 {
1058  bool ok = true;
1059  MSqlQuery query(MSqlQuery::InitCon());
1060  MSqlQuery query2(MSqlQuery::InitCon());
1061 
1062  query.prepare(
1063  "SELECT profilegroupid "
1064  "FROM displayprofilegroups "
1065  "WHERE name = :NAME AND "
1066  " hostname = :HOST ");
1067 
1068  query.bindValue(":NAME", GroupName);
1069  query.bindValue(":HOST", HostName);
1070 
1071  if (!query.exec() || !query.isActive())
1072  {
1073  MythDB::DBError("delete_profile_group 1", query);
1074  ok = false;
1075  }
1076  else
1077  {
1078  while (query.next())
1079  {
1080  query2.prepare("DELETE FROM displayprofiles "
1081  "WHERE profilegroupid = :PROFID");
1082  query2.bindValue(":PROFID", query.value(0).toUInt());
1083  if (!query2.exec())
1084  {
1085  MythDB::DBError("delete_profile_group 2", query2);
1086  ok = false;
1087  }
1088  }
1089  }
1090 
1091  query.prepare(
1092  "DELETE FROM displayprofilegroups "
1093  "WHERE name = :NAME AND "
1094  " hostname = :HOST");
1095 
1096  query.bindValue(":NAME", GroupName);
1097  query.bindValue(":HOST", HostName);
1098 
1099  if (!query.exec())
1100  {
1101  MythDB::DBError("delete_profile_group 3", query);
1102  ok = false;
1103  }
1104 
1105  return ok;
1106 }
1107 
1108 void VideoDisplayProfile::CreateProfiles(const QString &HostName)
1109 {
1110  QStringList profiles = GetProfiles(HostName);
1111 
1112 #ifdef USING_OPENGL
1113  if (!profiles.contains("OpenGL High Quality"))
1114  {
1115  (void) QObject::tr("OpenGL High Quality",
1116  "Sample: OpenGL high quality");
1117  uint groupid = CreateProfileGroup("OpenGL High Quality", HostName);
1118  CreateProfile(groupid, 1, "", "", "",
1119  "ffmpeg", 2, true, "opengl-yv12",
1120  "shader:high", "shader:high");
1121  }
1122 
1123  if (!profiles.contains("OpenGL Normal"))
1124  {
1125  (void) QObject::tr("OpenGL Normal", "Sample: OpenGL medium quality");
1126  uint groupid = CreateProfileGroup("OpenGL Normal", HostName);
1127  CreateProfile(groupid, 1, "", "", "",
1128  "ffmpeg", 2, true, "opengl-yv12",
1129  "shader:medium", "shader:medium");
1130  }
1131 
1132  if (!profiles.contains("OpenGL Slim"))
1133  {
1134  (void) QObject::tr("OpenGL Slim", "Sample: OpenGL low power GPU");
1135  uint groupid = CreateProfileGroup("OpenGL Slim", HostName);
1136  CreateProfile(groupid, 1, "", "", "",
1137  "ffmpeg", 1, true, "opengl",
1138  "medium", "medium");
1139  }
1140 #endif
1141 
1142 #ifdef USING_VAAPI
1143  if (!profiles.contains("VAAPI Normal"))
1144  {
1145  (void) QObject::tr("VAAPI Normal", "Sample: VAAPI average quality");
1146  uint groupid = CreateProfileGroup("VAAPI Normal", HostName);
1147  CreateProfile(groupid, 1, "", "", "",
1148  "vaapi", 2, true, "opengl-hw",
1149  "shader:driver:high", "shader:driver:high");
1150  CreateProfile(groupid, 1, "", "", "",
1151  "ffmpeg", 1, true, "opengl-yv12",
1152  "shader:high", "shader:high");
1153  }
1154 #endif
1155 
1156 #ifdef USING_VDPAU
1157  if (!profiles.contains("VDPAU Normal"))
1158  {
1159  (void) QObject::tr("VDPAU Normal", "Sample: VDPAU medium quality");
1160  uint groupid = CreateProfileGroup("VDPAU Normal", HostName);
1161  CreateProfile(groupid, 1, "", "", "",
1162  "vdpau", 1, true, "opengl-hw",
1163  "driver:medium", "driver:medium");
1164  }
1165 #endif
1166 
1167 #ifdef USING_MEDIACODEC
1168  if (!profiles.contains("MediaCodec Normal"))
1169  {
1170  (void) QObject::tr("MediaCodec Normal",
1171  "Sample: MediaCodec Normal");
1172  uint groupid = CreateProfileGroup("MediaCodec Normal", HostName);
1173  CreateProfile(groupid, 1, "", "", "",
1174  "mediacodec-dec", 4, true, "opengl-yv12",
1175  "shader:driver:medium", "shader:driver:medium");
1176  }
1177 #endif
1178 
1179 #if defined(USING_NVDEC) && defined(USING_OPENGL)
1180  if (!profiles.contains("NVDEC Normal"))
1181  {
1182  (void) QObject::tr("NVDEC Normal", "Sample: NVDEC Normal");
1183  uint groupid = CreateProfileGroup("NVDEC Normal", HostName);
1184  CreateProfile(groupid, 1, "", "", "",
1185  "nvdec", 1, true, "opengl-hw",
1186  "shader:driver:high", "shader:driver:high");
1187  }
1188 #endif
1189 
1190 #if defined(USING_VTB) && defined(USING_OPENGL)
1191  if (!profiles.contains("VideoToolBox Normal")) {
1192  (void) QObject::tr("VideoToolBox Normal", "Sample: VideoToolBox Normal");
1193  uint groupid = CreateProfileGroup("VideoToolBox Normal", HostName);
1194  CreateProfile(groupid, 1, "", "", "",
1195  "vtb", 1, true, "opengl-hw",
1196  "shader:driver:medium", "shader:driver:medium");
1197  }
1198 #endif
1199 
1200 #if defined(USING_MMAL) && defined(USING_OPENGL)
1201  if (!profiles.contains("MMAL"))
1202  {
1203  (void) QObject::tr("MMAL", "Sample: MMAL");
1204  uint groupid = CreateProfileGroup("MMAL", HostName);
1205  CreateProfile(groupid, 1, "", "", "",
1206  "mmal", 1, true, "opengl-hw",
1207  "shader:driver:medium", "shader:driver:medium");
1208  }
1209 #endif
1210 
1211 #if defined(USING_V4L2)
1212  if (!profiles.contains("V4L2 Codecs"))
1213  {
1214  (void) QObject::tr("V4L2 Codecs", "Sample: V4L2");
1215  uint groupid = CreateProfileGroup("V4L2 Codecs", HostName);
1216  CreateProfile(groupid, 1, "", "", "",
1217  "v4l2-dec", 1, true, "opengl-yv12",
1218  "shader:driver:medium", "shader:driver:medium");
1219  CreateProfile(groupid, 2, "", "", "",
1220  "v4l2", 1, true, "opengl-hw",
1221  "shader:driver:medium", "shader:driver:medium");
1222  }
1223 #endif
1224 }
1225 
1227 {
1228  QMutexLocker locker(&s_safe_lock);
1229  InitStatics();
1230 
1231  QMap<QString,QStringList>::const_iterator it = s_safe_renderer.find(Decoder);
1232  QStringList tmp;
1233  if (it != s_safe_renderer.end())
1234  tmp = *it;
1235  return tmp;
1236 }
1237 
1238 QString VideoDisplayProfile::GetVideoRendererHelp(const QString &Renderer)
1239 {
1240  QString msg = QObject::tr("Video rendering method");
1241 
1242  if (Renderer.isEmpty())
1243  return msg;
1244 
1245  if (Renderer == "null")
1246  msg = QObject::tr(
1247  "Render video offscreen. Used internally.");
1248 
1249  if (Renderer == "direct3d")
1250  {
1251  msg = QObject::tr(
1252  "Windows video renderer based on Direct3D. Requires "
1253  "video card compatible with Direct3D 9. This is the preferred "
1254  "renderer for current Windows systems.");
1255  }
1256 
1257  if (Renderer == "opengl")
1258  {
1259  msg = QObject::tr(
1260  "Video is converted to an intermediate format by the CPU (YUV2) "
1261  "before OpenGL is used for color conversion, scaling, picture controls"
1262  " and optionally deinterlacing. Processing is balanced between the CPU "
1263  "and GPU.");
1264  }
1265 
1266  if (Renderer == "opengl-yv12")
1267  {
1268  msg = QObject::tr(
1269  "OpenGL is used for all color conversion, scaling, picture "
1270  "controls and optionally deinterlacing. CPU load is low but a slightly more "
1271  "powerful GPU is needed for deinterlacing.");
1272  }
1273 
1274  if (Renderer == "opengl-hw")
1275  {
1276  msg = QObject::tr(
1277  "This video renderer is used by hardware decoders to display "
1278  "frames using OpenGL.");
1279  }
1280 
1281  return msg;
1282 }
1283 
1285 {
1287 }
1288 
1289 bool VideoDisplayProfile::IsFilterAllowed(const QString &VideoRenderer)
1290 {
1291  QMutexLocker locker(&s_safe_lock);
1292  InitStatics();
1293  return s_safe_custom.contains(VideoRenderer);
1294 }
1295 
1296 QStringList VideoDisplayProfile::GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers)
1297 {
1298  const QStringList dec_list = GetVideoRenderers(Decoder);
1299  QStringList new_list;
1300 
1301  foreach (const auto & dec, dec_list)
1302  if (Renderers.contains(dec))
1303  new_list.push_back(dec);
1304 
1305  return new_list;
1306 }
1307 
1308 QString VideoDisplayProfile::GetBestVideoRenderer(const QStringList &Renderers)
1309 {
1310  QMutexLocker locker(&s_safe_lock);
1311  InitStatics();
1312 
1313  uint top_priority = 0;
1314  QString top_renderer;
1315 
1316  foreach (const auto & renderer, Renderers)
1317  {
1318  QMap<QString,uint>::const_iterator p = s_safe_renderer_priority.find(renderer);
1319  if ((p != s_safe_renderer_priority.end()) && (*p >= top_priority))
1320  {
1321  top_priority = *p;
1322  top_renderer = renderer;
1323  }
1324  }
1325 
1326  return top_renderer;
1327 }
1328 
1330 {
1331  QString renderer = GetPreference("pref_videorenderer");
1332  QString osd = GetPreference("pref_osdrenderer");
1333  QString deint0 = GetPreference("pref_deint0");
1334  QString deint1 = GetPreference("pref_deint1");
1335  return QString("rend(%4) osd(%5) deint(%6,%7) filt(%8)")
1336  .arg(renderer).arg(osd).arg(deint0).arg(deint1);
1337 }
1338 
1339 QList<QPair<QString,QString> > VideoDisplayProfile::GetDeinterlacers(void)
1340 {
1341  InitStatics();
1342  return s_deinterlacer_options;
1343 }
1344 
1345 void VideoDisplayProfile::InitStatics(bool Reinit /*= false*/)
1346 {
1347  if (Reinit)
1348  {
1349  s_safe_custom.clear();
1350  s_safe_renderer.clear();
1351  s_safe_renderer_group.clear();
1352  s_safe_renderer_priority.clear();
1353  s_safe_decoders.clear();
1354  s_safe_equiv_dec.clear();
1355  s_deinterlacer_options.clear();
1356  }
1357  else if (s_safe_initialized)
1358  {
1359  return;
1360  }
1361  s_safe_initialized = true;
1362 
1364  options.renderers = &s_safe_custom;
1365  options.safe_renderers = &s_safe_renderer;
1366  options.render_group = &s_safe_renderer_group;
1367  options.priorities = &s_safe_renderer_priority;
1368  options.decoders = &s_safe_decoders;
1369  options.equiv_decoders = &s_safe_equiv_dec;
1370 
1371  // N.B. assumes NuppelDecoder and DummyDecoder always present
1374 
1375  foreach(QString decoder, s_safe_decoders)
1376  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1377  QString("decoder<->render support: %1%2")
1378  .arg(decoder, -12).arg(GetVideoRenderers(decoder).join(" ")));
1379 
1380  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_NONE, QObject::tr("None")));
1381  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_LOW, QObject::tr("Low quality")));
1382  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_MEDIUM, QObject::tr("Medium quality")));
1383  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_HIGH, QObject::tr("High quality")));
1384 }
bool CheckRange(const QString &Key, float Value, bool *Ok=nullptr) const
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
QMap< QString, QString > m_pref
static QString GetPreferredVideoRenderer(const QString &Decoder)
static QStringList GetDecoders(void)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
void SetInput(const QSize &Size, float Framerate=0, const QString &CodecName=QString())
static uint CreateProfileGroup(const QString &ProfileName, const QString &HostName)
static QMap< QString, QStringList > s_safe_equiv_dec
static QMap< QString, QString > s_dec_name
static bool DeleteDB(uint GroupId, const vector< ProfileItem > &Items)
uint GetProfileID(void) const
static QList< QPair< QString, QString > > s_deinterlacer_options
static void GetDecoders(RenderOptions &opts)
static vector< ProfileItem > LoadDB(uint GroupId)
uint GetPriority(void) const
static QStringList GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers)
vector< ProfileItem > m_allowedPreferences
static QString GetDecoderHelp(const QString &Decoder=QString())
static QStringList GetDecoderNames(void)
static QMap< QString, uint > s_safe_renderer_priority
void SetOutput(float Framerate)
static void error(const char *str,...)
Definition: vbi.c:42
QMap< QString, QString > m_currentPreferences
static QList< QPair< QString, QString > > GetDeinterlacers(void)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
float GetOutput(void) const
bool CheckVideoRendererGroup(const QString &Renderer)
static void SetDefaultProfileName(const QString &ProfileName, const QString &HostName)
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define DEINT_QUALITY_HIGH
static void CreateProfile(uint GroupId, uint Priority, const QString &Width, const QString &Height, const QString &Codecs, const QString &Decoder, uint MaxCpus, bool SkipLoop, const QString &VideoRenderer, const QString &Deint1, const QString &Deint2)
static guint32 * tmp
Definition: goom_core.c:35
QVariant value(int i) const
Definition: mythdbcon.h:198
static QMap< QString, QString > s_rend_name
static QMap< QString, QStringList > s_safe_renderer_group
#define LOC
void LoadBestPreferences(const QSize &Size, float Framerate, const QString &CodecName)
static void CreateProfiles(const QString &HostName)
QString GetPreference(const QString &Key) const
void Set(const QString &Value, const QString &Data)
QString GetDecoder(void) const
vector< ProfileItem >::const_iterator FindMatch(const QSize &Size, float Framerate, const QString &CodecName)
static QString GetDefaultProfileName(const QString &HostName)
bool isActive(void) const
Definition: mythdbcon.h:204
static void InitStatics(bool Reinit=false)
static QString GetDecoderName(const QString &Decoder)
#define DEINT_QUALITY_NONE
QString toString(void) const
void SetProfileID(uint Id)
QMap< QString, QString > GetAll(void) const
string hostname
Definition: caa.py:17
void SetPreference(const QString &Key, const QString &Value)
unsigned int uint
Definition: compat.h:140
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
static bool DeleteProfileGroup(const QString &GroupName, const QString &HostName)
QString GetActualVideoRenderer(void) const
static QString GetVideoRendererName(const QString &Renderer)
bool IsSkipLoopEnabled(void) const
QString Get(const QString &Value) const
static QStringList s_safe_decoders
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808
static QStringList GetVideoRenderers(const QString &Decoder)
static bool IsFilterAllowed(const QString &VideoRenderer)
static void GetRenderOptions(RenderOptions &Options)
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
uint GetMaxCPUs(void) const
static QMap< QString, QStringList > s_safe_renderer
static bool SaveDB(uint GroupId, vector< ProfileItem > &Items)
bool IsValid(QString *Reason=nullptr) const
QString GetSingleRatePreferences(void) const
static QStringList GetProfiles(const QString &HostName)
static QString GetBestVideoRenderer(const QStringList &Renderers)
static QStringList s_safe_custom
QString GetVideoRenderer(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
QString toString(void) const
bool IsMatch(const QSize &Size, float Framerate, const QString &CodecName) const
static uint GetProfileGroupID(const QString &ProfileName, const QString &HostName)
bool operator<(const ProfileItem &Other) const
#define DEINT_QUALITY_MEDIUM
#define DEINT_QUALITY_LOW
QString GetHostName(void)
static QString GetVideoRendererHelp(const QString &Renderer)
QString GetDoubleRatePreferences(void) const
bool IsDecoderCompatible(const QString &Decoder)
void SetVideoRenderer(const QString &VideoRenderer)