Skip to content

Commit

Permalink
Recording profile optimisations (part one).
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartm authored and jyavenard committed Dec 14, 2010
1 parent eb02f2e commit 6e4b2c4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 40 deletions.
93 changes: 53 additions & 40 deletions mythtv/libs/libmythtv/recordingprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,35 +1268,7 @@ void RecordingProfile::loadByID(int profileId)
isEncoder = CardUtil::IsEncoder(type);
}

if (isEncoder)
{
QString tvFormat = gCoreContext->GetSetting("TVFormat");
if (type.toUpper() != "HDPVR")
addChild(new ImageSize(*this, tvFormat, profileName));

videoSettings = new VideoCompressionSettings(*this, profileName);
addChild(videoSettings);

audioSettings = new AudioCompressionSettings(*this, profileName);
addChild(audioSettings);

if (!profileName.isEmpty() && profileName.left(11) == "Transcoders")
{
connect(tr_resize, SIGNAL(valueChanged (bool)),
this, SLOT( ResizeTranscode(bool)));
connect(tr_lossless, SIGNAL(valueChanged (bool)),
this, SLOT( SetLosslessTranscode(bool)));
connect(tr_filters, SIGNAL(valueChanged(const QString&)),
this, SLOT(FiltersChanged(const QString&)));
}
}
else if (type.toUpper() == "DVB")
{
addChild(new RecordingType(*this));
}

id->setValue(profileId);
Load();
CompleteLoad(profileId, type);
}

void RecordingProfile::FiltersChanged(const QString &val)
Expand All @@ -1319,7 +1291,7 @@ void RecordingProfile::FiltersChanged(const QString &val)
bool RecordingProfile::loadByType(const QString &name, const QString &cardtype)
{
QString hostname = gCoreContext->GetHostName().toLower();
uint recid = 0;
uint profileId = 0;

MSqlQuery result(MSqlQuery::InitCon());
result.prepare(
Expand All @@ -1340,20 +1312,22 @@ bool RecordingProfile::loadByType(const QString &name, const QString &cardtype)

while (result.next())
{
if (result.value(1).toString().toLower() == hostname)
if ((result.value(1).toString().toLower() == hostname) ||
(result.value(2).toInt() == 1))
{
recid = result.value(0).toUInt();
profileId = result.value(0).toUInt();

if (result.value(1).toString().toLower() == hostname)
break;
}
else if (result.value(2).toInt() == 1)
{
recid = result.value(0).toUInt();
}
}

if (recid)
if (profileId)
{
loadByID(recid);
if (profileName.isEmpty())
profileName = name;
isEncoder = CardUtil::IsEncoder(cardtype);
CompleteLoad(profileId, cardtype);
return true;
}

Expand All @@ -1364,7 +1338,7 @@ bool RecordingProfile::loadByGroup(const QString &name, const QString &group)
{
MSqlQuery result(MSqlQuery::InitCon());
result.prepare(
"SELECT recordingprofiles.id "
"SELECT recordingprofiles.id, cardtype "
"FROM recordingprofiles, profilegroups "
"WHERE recordingprofiles.profilegroup = profilegroups.id AND "
" profilegroups.name = :GROUPNAME AND "
Expand All @@ -1380,13 +1354,52 @@ bool RecordingProfile::loadByGroup(const QString &name, const QString &group)

if (result.next())
{
loadByID(result.value(0).toUInt());
uint profileId = result.value(0).toUInt();
QString type = result.value(1).toString();

if (profileName.isEmpty())
profileName = name;
isEncoder = CardUtil::IsEncoder(type);
CompleteLoad(profileId, type);
return true;
}

return false;
}

void RecordingProfile::CompleteLoad(int profileId, QString type)
{
if (isEncoder)
{
QString tvFormat = gCoreContext->GetSetting("TVFormat");
if (type.toUpper() != "HDPVR")
addChild(new ImageSize(*this, tvFormat, profileName));

videoSettings = new VideoCompressionSettings(*this, profileName);
addChild(videoSettings);

audioSettings = new AudioCompressionSettings(*this, profileName);
addChild(audioSettings);

if (!profileName.isEmpty() && profileName.left(11) == "Transcoders")
{
connect(tr_resize, SIGNAL(valueChanged (bool)),
this, SLOT( ResizeTranscode(bool)));
connect(tr_lossless, SIGNAL(valueChanged (bool)),
this, SLOT( SetLosslessTranscode(bool)));
connect(tr_filters, SIGNAL(valueChanged(const QString&)),
this, SLOT(FiltersChanged(const QString&)));
}
}
else if (type.toUpper() == "DVB")
{
addChild(new RecordingType(*this));
}

id->setValue(profileId);
Load();
}

void RecordingProfile::setCodecTypes()
{
if (videoSettings)
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/recordingprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class MPUBLIC RecordingProfile : public QObject, public ConfigurationWizard
virtual void loadByID(int id);
virtual bool loadByType(const QString &name, const QString &cardtype);
virtual bool loadByGroup(const QString &name, const QString &group);
virtual void CompleteLoad(int profileId, QString type);
virtual DialogCode exec(void);

// sets
Expand Down

0 comments on commit 6e4b2c4

Please sign in to comment.