Permalink
Browse files

Video Setup Wizard: Stage automatic download of sample files.

Lay the groundwork to pull sample files from services.mythtv.org (or wherever) in the near future when running the video configuration wizard.  The file is sought on the Master Backend's temp storage group, and if it's not found, it's downloaded to that location.  Thus, the download is only ever necessary once in the entire system (and we don't need to distribute 100 MB of samples with the source).
  • Loading branch information...
1 parent 3bebf27 commit 4b86ba04082c082d3c6807fb421ede77cac1e43b Robert McNamara committed Jan 23, 2011
Showing with 121 additions and 23 deletions.
  1. +102 −23 mythtv/programs/mythfrontend/setupwizard_video.cpp
  2. +19 −0 mythtv/programs/mythfrontend/setupwizard_video.h
@@ -1,20 +1,30 @@
// qt
#include <QString>
#include <QVariant>
+#include <QFileInfo>
// myth
-#include <mythcontext.h>
-#include <mythdbcon.h>
-#include <mythdirs.h>
-#include <mythprogressdialog.h>
+#include "mythcontext.h"
+#include "mythdbcon.h"
+#include "mythdirs.h"
+#include "mythprogressdialog.h"
+#include "mythcoreutil.h"
+#include "videoutils.h"
+#include "remotefile.h"
#include "setupwizard_general.h"
#include "setupwizard_audio.h"
#include "setupwizard_video.h"
+const QString VIDEO_SAMPLE_HD_LOCATION =
+ QString("http://www.fecitfacta.com/mythtv_video_test_HD_19000Kbps_H264.mkv");
+const QString VIDEO_SAMPLE_SD_LOCATION =
+ QString("http://www.fecitfacta.com/mythtv_video_test_SD_6000Kbps_H264.mkv");
+
VideoSetupWizard::VideoSetupWizard(MythScreenStack *parent, MythScreenType *general,
MythScreenType *audio, const char *name)
- : MythScreenType(parent, name),
+ : MythScreenType(parent, name), m_downloadFile(QString()),
+ m_testType(ttNone),
m_generalScreen(general), m_audioScreen(audio),
m_playbackProfileButtonList(NULL), m_testSDButton(NULL),
m_testHDButton(NULL), m_nextButton(NULL),
@@ -137,43 +147,112 @@ bool VideoSetupWizard::keyPressEvent(QKeyEvent *event)
void VideoSetupWizard::testSDVideo(void)
{
- QString sdtestfile =
- QString("%1themes/default/test_sd.mov")
- .arg(GetShareDir());
-
+ QFileInfo qfile(VIDEO_SAMPLE_SD_LOCATION);
+ QString baseName = qfile.fileName();
+ QString sdtestfile = generate_file_url("Temp",
+ gCoreContext->GetMasterHostName(), baseName);
QString desiredpbp =
m_playbackProfileButtonList->GetItemCurrent()->GetText();
- QString currentpbp = m_vdp->GetDefaultProfileName(gCoreContext->GetHostName());
-
QString desc = tr("A short test of your system's playback of "
"Standard Definition content with the %1 profile.")
.arg(desiredpbp);
QString title = tr("Standard Definition Playback Test");
- m_vdp->SetDefaultProfileName(desiredpbp, gCoreContext->GetHostName());
- GetMythMainWindow()->HandleMedia("Internal", sdtestfile,
- desc, title);
- m_vdp->SetDefaultProfileName(currentpbp, gCoreContext->GetHostName());
+ if (!RemoteFile::Exists(sdtestfile))
+ {
+ m_testType = ttStandardDefinition;
+ DownloadSample(VIDEO_SAMPLE_SD_LOCATION);
+ }
+ else
+ playVideoTest(desc, title, sdtestfile);
}
void VideoSetupWizard::testHDVideo(void)
{
- QString hdtestfile =
- QString("%1themes/default/test_hd.mov")
- .arg(GetShareDir());
-
+ QFileInfo qfile(VIDEO_SAMPLE_HD_LOCATION);
+ QString baseName = qfile.fileName();
+ QString hdtestfile = generate_file_url("Temp",
+ gCoreContext->GetMasterHostName(), baseName);
QString desiredpbp =
m_playbackProfileButtonList->GetItemCurrent()->GetText();
- QString currentpbp = m_vdp->GetDefaultProfileName(gCoreContext->GetHostName());
-
QString desc = tr("A short test of your system's playback of "
"High Definition content with the %1 profile.")
.arg(desiredpbp);
QString title = tr("High Definition Playback Test");
+ if (!RemoteFile::Exists(hdtestfile))
+ {
+ m_testType = ttHighDefinition;
+ DownloadSample(VIDEO_SAMPLE_HD_LOCATION);
+ }
+ else
+ playVideoTest(desc, title, hdtestfile);
+}
+
+void VideoSetupWizard::playVideoTest(QString desc, QString title, QString file)
+{
+ QString desiredpbp =
+ m_playbackProfileButtonList->GetItemCurrent()->GetText();
+ QString currentpbp = m_vdp->GetDefaultProfileName(gCoreContext->GetHostName());
+
m_vdp->SetDefaultProfileName(desiredpbp, gCoreContext->GetHostName());
- GetMythMainWindow()->HandleMedia("Internal", hdtestfile,
- desc, title);
+ GetMythMainWindow()->HandleMedia("Internal", file, desc, title);
m_vdp->SetDefaultProfileName(currentpbp, gCoreContext->GetHostName());
}
+void VideoSetupWizard::DownloadSample(QString url)
+{
+ QFileInfo qfile(url);
+ QString baseName = qfile.fileName();
+
+ OpenBusyPopup(tr("Downloading Video Sample..."));
+ m_downloadFile = RemoteDownloadFile(url, "Temp", baseName);
+}
+
+void VideoSetupWizard::customEvent(QEvent *e)
+{
+ if ((MythEvent::Type)(e->type()) == MythEvent::MythEventMessage)
+ {
+ MythEvent *me = (MythEvent *)e;
+ QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);
+
+ if (tokens.isEmpty())
+ return;
+
+ if (tokens[0] == "DOWNLOAD_FILE")
+ {
+ QStringList args = me->ExtraDataList();
+ if ((tokens.size() != 2) ||
+ (args[1] != m_downloadFile))
+ return;
+
+ if (tokens[1] == "UPDATE")
+ {
+ }
+ else if (tokens[1] == "FINISHED")
+ {
+ int fileSize = args[2].toInt();
+ int errorCode = args[4].toInt();
+
+ CloseBusyPopup();
+
+ QFileInfo file(m_downloadFile);
+ if ((m_downloadFile.startsWith("myth://")))
+ {
+ if ((errorCode == 0) &&
+ (fileSize > 0))
+ {
+ if (m_testType == ttHighDefinition)
+ testHDVideo();
+ else if (m_testType == ttStandardDefinition)
+ testSDVideo();
+ }
+ else
+ {
+ ShowOkPopup(tr("Error downloading sample to backend."));
+ }
+ }
+ }
+ }
+ }
+}
@@ -14,6 +14,9 @@
#include <mythscreentype.h>
#include <mythdialogbox.h>
+extern const QString VIDEO_SAMPLE_HD_LOCATION;
+extern const QString VIDEO_SAMPLE_SD_LOCATION;
+
class VideoSetupWizard : public MythScreenType
{
Q_OBJECT
@@ -26,10 +29,21 @@ class VideoSetupWizard : public MythScreenType
bool Create(void);
bool keyPressEvent(QKeyEvent *);
+ void customEvent(QEvent *e);
void save(void);
private:
+ enum TestType
+ {
+ ttNone = 0,
+ ttHighDefinition,
+ ttStandardDefinition
+ };
+
+ QString m_downloadFile;
+ TestType m_testType;
+
MythScreenType *m_generalScreen;
MythScreenType *m_audioScreen;
@@ -50,6 +64,11 @@ class VideoSetupWizard : public MythScreenType
void testSDVideo(void);
void testHDVideo(void);
+ void playVideoTest(QString desc,
+ QString title,
+ QString file);
+
+ void DownloadSample(QString url);
};
#endif

0 comments on commit 4b86ba0

Please sign in to comment.