MythTV  master
setupwizard_video.cpp
Go to the documentation of this file.
1 // qt
2 #include <QString>
3 #include <QVariant>
4 #include <QFileInfo>
5 
6 // myth
7 #include "mythcontext.h"
8 #include "mythdbcon.h"
9 #include "mythdirs.h"
10 #include "mythprogressdialog.h"
11 #include "mythcoreutil.h"
12 #include "videoutils.h"
13 #include "remotefile.h"
14 
15 #include "setupwizard_general.h"
16 #include "setupwizard_audio.h"
17 #include "setupwizard_video.h"
18 
19 const QString VIDEO_SAMPLE_HD_LOCATION =
20  QString("http://services.mythtv.org/samples/video/?sample=HD");
21 const QString VIDEO_SAMPLE_SD_LOCATION =
22  QString("http://services.mythtv.org/samples/video/?sample=SD");
23 const QString VIDEO_SAMPLE_HD_FILENAME =
24  QString("mythtv_video_test_HD_19000Kbps_H264.mkv");
25 const QString VIDEO_SAMPLE_SD_FILENAME =
26  QString("mythtv_video_test_SD_6000Kbps_H264.mkv");
27 
29  MythScreenType *general,
30  MythScreenType *audio, const char *name)
31  : MythScreenType(parent, name),
32  m_generalScreen(general), m_audioScreen(audio)
33 {
34  m_popupStack = GetMythMainWindow()->GetStack("popup stack");
35 
37 }
38 
40 {
41  // Load the theme for this screen
42  bool foundtheme = LoadWindowFromXML("config-ui.xml", "videowizard", this);
43  if (!foundtheme)
44  return false;
45 
47  dynamic_cast<MythUIButtonList *> (GetChild("playbackprofiles"));
48 
49  m_testSDButton = dynamic_cast<MythUIButton *> (GetChild("testsd"));
50  m_testHDButton = dynamic_cast<MythUIButton *> (GetChild("testhd"));
51 
52  m_nextButton = dynamic_cast<MythUIButton *> (GetChild("next"));
53  m_prevButton = dynamic_cast<MythUIButton *> (GetChild("previous"));
54 
57  {
58  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
59  return false;
60  }
61 
62  m_playbackProfileButtonList->SetHelpText( tr("Select from one of the "
63  "preconfigured playback profiles. When "
64  "satisfied, you can test Standard Definition "
65  "and High Definition playback with the selected "
66  "profile before moving on.") );
67  m_testSDButton->SetHelpText( tr("Test your playback settings with Standard "
68  "Definition content. (480p)") );
69  m_testHDButton->SetHelpText( tr("Test your playback settings with High "
70  "Definition content (1080p).") );
71  m_nextButton->SetHelpText( tr("Save these changes and move on to the "
72  "next configuration step.") );
73  m_prevButton->SetHelpText(tr("Return to the previous configuration step."));
74 
75  connect(m_testSDButton, SIGNAL(Clicked()), this, SLOT(testSDVideo()));
76  connect(m_testHDButton, SIGNAL(Clicked()), this, SLOT(testHDVideo()));
77  connect(m_nextButton, SIGNAL(Clicked()), this, SLOT(slotNext()));
78  connect(m_prevButton, SIGNAL(Clicked()), this, SLOT(slotPrevious()));
79 
81  loadData();
82 
83  return true;
84 }
85 
87 {
89 }
90 
92 {
94 
95  for (const auto & prof : qAsConst(profiles))
96  {
97  auto *item = new MythUIButtonListItem(m_playbackProfileButtonList, prof);
98  item->SetData(prof);
99  }
100 
102  if (!currentpbp.isEmpty())
103  {
104  MythUIButtonListItem *set =
107  }
108 }
109 
111 {
112  save();
113 
114  if (m_audioScreen)
115  {
116  m_audioScreen->Close();
117  m_audioScreen = nullptr;
118  }
119 
120  if (m_generalScreen)
121  {
123  m_generalScreen = nullptr;
124  }
125 
126  Close();
127 }
128 
130 {
131  QString desiredpbp =
134 }
135 
137 {
138  Close();
139 }
140 
141 bool VideoSetupWizard::keyPressEvent(QKeyEvent *event)
142 {
143  if (GetFocusWidget()->keyPressEvent(event))
144  return true;
145 
146  bool handled = false;
147 
149  handled = true;
150 
151  return handled;
152 }
153 
155 {
156  QString sdtestfile = generate_file_url("Temp",
159  QString desiredpbp =
161  QString desc = tr("A short test of your system's playback of "
162  "Standard Definition content with the %1 profile.")
163  .arg(desiredpbp);
164  QString title = tr("Standard Definition Playback Test");
165 
166  if (!RemoteFile::Exists(sdtestfile))
167  {
170  }
171  else
172  playVideoTest(desc, title, sdtestfile);
173 }
174 
176 {
177  QString hdtestfile = generate_file_url("Temp",
180  QString desiredpbp =
182  QString desc = tr("A short test of your system's playback of "
183  "High Definition content with the %1 profile.")
184  .arg(desiredpbp);
185  QString title = tr("High Definition Playback Test");
186 
187  if (!RemoteFile::Exists(hdtestfile))
188  {
191  }
192  else
193  playVideoTest(desc, title, hdtestfile);
194 }
195 
196 void VideoSetupWizard::playVideoTest(const QString& desc, const QString& title, const QString& file)
197 {
198  QString desiredpbp =
201 
203  GetMythMainWindow()->HandleMedia("Internal", file, desc, title);
205 }
206 
207 void VideoSetupWizard::DownloadSample(const QString& url, const QString& dest)
208 {
210  m_downloadFile = RemoteDownloadFile(url, "Temp", dest);
211 }
212 
214 {
215  QString message = tr("Downloading Video Sample...");
217  m_popupStack, "sampledownloadprogressdialog");
218 
219  if (m_progressDialog->Create())
220  {
222  }
223  else
224  {
225  delete m_progressDialog;
226  m_progressDialog = nullptr;
227  }
228 }
229 
231 {
232  if (e->type() == MythEvent::MythEventMessage)
233  {
234  auto *me = dynamic_cast<MythEvent *>(e);
235  if (me == nullptr)
236  return;
237 
238 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
239  QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);
240 #else
241  QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
242 #endif
243  if (tokens.isEmpty())
244  return;
245 
246  if (tokens[0] == "DOWNLOAD_FILE")
247  {
248  QStringList args = me->ExtraDataList();
249  if ((tokens.size() != 2) ||
250  (args[1] != m_downloadFile))
251  return;
252 
253  if (tokens[1] == "UPDATE")
254  {
255  QString message = tr("Downloading Video Sample...\n"
256  "(%1 of %2 MB)")
257  .arg(QString::number(args[2].toInt() / 1024.0 / 1024.0, 'f', 2))
258  .arg(QString::number(args[3].toInt() / 1024.0 / 1024.0, 'f', 2));
259  m_progressDialog->SetMessage(message);
260  m_progressDialog->SetTotal(args[3].toInt());
261  m_progressDialog->SetProgress(args[2].toInt());
262  }
263  else if (tokens[1] == "FINISHED")
264  {
265  int fileSize = args[2].toInt();
266  int errorCode = args[4].toInt();
267 
268  if (m_progressDialog)
270 
271  if ((m_downloadFile.startsWith("myth://")))
272  {
273  if ((errorCode == 0) &&
274  (fileSize > 0))
275  {
277  testHDVideo();
278  else if (m_testType == ttStandardDefinition)
279  testSDVideo();
280  }
281  else
282  {
283  ShowOkPopup(tr("Error downloading sample to backend."));
284  }
285  }
286  }
287  }
288  }
289 }
VideoSetupWizard::m_generalScreen
MythScreenType * m_generalScreen
Definition: setupwizard_video.h:48
VideoSetupWizard::~VideoSetupWizard
~VideoSetupWizard() override
Definition: setupwizard_video.cpp:86
build_compdb.args
args
Definition: build_compdb.py:11
MythUIProgressDialog::Create
bool Create(void) override
Definition: mythprogressdialog.cpp:130
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1423
generate_file_url
QString generate_file_url(const QString &storage_group, const QString &host, const QString &path)
Definition: videoutils.h:65
VIDEO_SAMPLE_HD_LOCATION
const QString VIDEO_SAMPLE_HD_LOCATION
Definition: setupwizard_video.cpp:19
build_compdb.dest
dest
Definition: build_compdb.py:9
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:73
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1590
MythCoreContext::GetMasterHostName
QString GetMasterHostName(void)
Definition: mythcorecontext.cpp:825
VideoSetupWizard::playVideoTest
void playVideoTest(const QString &desc, const QString &title, const QString &file)
Definition: setupwizard_video.cpp:196
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:551
VideoSetupWizard::ttHighDefinition
@ ttHighDefinition
Definition: setupwizard_video.h:41
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:402
RemoteFile::Exists
static bool Exists(const QString &url, struct stat *fileinfo)
Definition: remotefile.cpp:462
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:639
VideoSetupWizard::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: setupwizard_video.cpp:141
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:131
VideoSetupWizard::testSDVideo
void testSDVideo(void)
Definition: setupwizard_video.cpp:154
VideoSetupWizard::initProgressDialog
void initProgressDialog()
Definition: setupwizard_video.cpp:213
VIDEO_SAMPLE_HD_FILENAME
const QString VIDEO_SAMPLE_HD_FILENAME
Definition: setupwizard_video.cpp:23
VIDEO_SAMPLE_SD_FILENAME
const QString VIDEO_SAMPLE_SD_FILENAME
Definition: setupwizard_video.cpp:25
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:17
mythcoreutil.h
VideoSetupWizard::Create
bool Create(void) override
Definition: setupwizard_video.cpp:39
setupwizard_general.h
MythScreenStack
Definition: mythscreenstack.h:16
mythdbcon.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
VideoSetupWizard::save
void save(void)
Definition: setupwizard_video.cpp:129
build_compdb.file
file
Definition: build_compdb.py:55
mythdirs.h
MythUIProgressDialog::SetMessage
void SetMessage(const QString &message)
Definition: mythprogressdialog.cpp:205
setupwizard_video.h
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:309
mythprogressdialog.h
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
VideoSetupWizard::customEvent
void customEvent(QEvent *e) override
Definition: setupwizard_video.cpp:230
VIDEO_SAMPLE_SD_LOCATION
const QString VIDEO_SAMPLE_SD_LOCATION
Definition: setupwizard_video.cpp:21
MythUIButtonList::GetItemByData
MythUIButtonListItem * GetItemByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1684
VideoSetupWizard::ttStandardDefinition
@ ttStandardDefinition
Definition: setupwizard_video.h:42
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
VideoSetupWizard::m_downloadFile
QString m_downloadFile
Definition: setupwizard_video.h:45
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
VideoDisplayProfile::SetDefaultProfileName
static void SetDefaultProfileName(const QString &ProfileName, const QString &HostName)
Definition: videodisplayprofile.cpp:963
VideoSetupWizard::m_playbackProfileButtonList
MythUIButtonList * m_playbackProfileButtonList
Definition: setupwizard_video.h:51
remotefile.h
MythUIProgressDialog
Definition: mythprogressdialog.h:60
MythUIProgressDialog::SetProgress
void SetProgress(uint count)
Definition: mythprogressdialog.cpp:199
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:153
VideoSetupWizard::slotPrevious
void slotPrevious(void)
Definition: setupwizard_video.cpp:136
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
VideoSetupWizard::m_progressDialog
MythUIProgressDialog * m_progressDialog
Definition: setupwizard_video.h:53
VideoSetupWizard::VideoSetupWizard
VideoSetupWizard(MythScreenStack *parent, MythScreenType *general, MythScreenType *audio, const char *name=nullptr)
Definition: setupwizard_video.cpp:28
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:57
setupwizard_audio.h
VideoDisplayProfile::GetProfiles
static QStringList GetProfiles(const QString &HostName)
Definition: videodisplayprofile.cpp:917
VideoSetupWizard::m_nextButton
MythUIButton * m_nextButton
Definition: setupwizard_video.h:58
MythUIButtonListItem::GetText
QString GetText(const QString &name="") const
Definition: mythuibuttonlist.cpp:3305
VideoSetupWizard::m_testType
TestType m_testType
Definition: setupwizard_video.h:46
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
VideoSetupWizard::m_prevButton
MythUIButton * m_prevButton
Definition: setupwizard_video.h:59
MythMainWindow::HandleMedia
bool HandleMedia(const QString &handler, const QString &mrl, const QString &plot="", const QString &title="", const QString &subtitle="", const QString &director="", int season=0, int episode=0, const QString &inetref="", int lenMins=120, const QString &year="1895", const QString &id="", bool useBookmarks=false)
Definition: mythmainwindow.cpp:1489
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
MythUIProgressDialog::SetTotal
void SetTotal(uint total)
Definition: mythprogressdialog.cpp:193
mythcontext.h
VideoSetupWizard::slotNext
void slotNext(void)
Definition: setupwizard_video.cpp:110
VideoSetupWizard::testHDVideo
void testHDVideo(void)
Definition: setupwizard_video.cpp:175
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:107
MythUIButtonList::SetItemCurrent
void SetItemCurrent(MythUIButtonListItem *item)
Definition: mythuibuttonlist.cpp:1557
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:856
VideoSetupWizard::m_testSDButton
MythUIButton * m_testSDButton
Definition: setupwizard_video.h:55
VideoSetupWizard::loadData
void loadData(void)
Definition: setupwizard_video.cpp:91
VideoSetupWizard::DownloadSample
void DownloadSample(const QString &url, const QString &dest)
Definition: setupwizard_video.cpp:207
VideoSetupWizard::m_testHDButton
MythUIButton * m_testHDButton
Definition: setupwizard_video.h:56
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:144
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:49
RemoteDownloadFile
QString RemoteDownloadFile(const QString &url, const QString &storageGroup, const QString &filename)
Definition: mythcoreutil.cpp:299
VideoSetupWizard::m_audioScreen
MythScreenType * m_audioScreen
Definition: setupwizard_video.h:49
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
VideoDisplayProfile::GetDefaultProfileName
static QString GetDefaultProfileName(const QString &HostName)
Definition: videodisplayprofile.cpp:937
videoutils.h
VideoSetupWizard::m_popupStack
MythScreenStack * m_popupStack
Definition: setupwizard_video.h:52