Permalink
Browse files

Refactor InfputInfo.sourceid to InputInfo.mainsourceid to aid further…

… refactoring
  • Loading branch information...
1 parent b081809 commit 218e9b000cc828fd25f8efc72d9f8235fc206241 @pinkylinc committed Jun 4, 2012
View
10 mythtv/libs/libmyth/programinfo.cpp
@@ -4230,10 +4230,12 @@ bool ProgramInfo::QueryTuningInfo(QString &channum, QString &input) const
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("SELECT channel.channum, cardinput.inputname "
- "FROM channel, capturecard, cardinput "
- "WHERE channel.chanid = :CHANID AND "
- " cardinput.cardid = capturecard.cardid AND "
- " cardinput.sourceid = :SOURCEID AND "
+ "FROM channel, capturecard, cardinput, videosourcemap as map "
+ "WHERE channel.chanid = :CHANID AND "
+ " cardinput.cardid = capturecard.cardid AND "
+ " map.sourceid = :SOURCEID AND "
+ " map.cardinputid = cardinput.cardinputid AND "
+ " map.type in ('main') AND "
" capturecard.cardid = :CARDID");
query.bindValue(":CHANID", chanid);
query.bindValue(":SOURCEID", sourceid);
View
11 mythtv/libs/libmythtv/cardutil.cpp
@@ -1250,10 +1250,10 @@ bool CardUtil::GetInputInfo(InputInfo &input, vector<uint> *groupids)
if (!query.next())
return false;
- input.name = query.value(0).toString();
- input.sourceid = query.value(1).toUInt();
- input.cardid = query.value(2).toUInt();
- input.livetvorder = query.value(3).toUInt();
+ input.name = query.value(0).toString();
+ input.mainsourceid = query.value(1).toUInt();
+ input.cardid = query.value(2).toUInt();
+ input.livetvorder = query.value(3).toUInt();
if (groupids)
*groupids = GetInputGroups(input.inputid);
@@ -1419,7 +1419,6 @@ vector<uint> CardUtil::GetInputIDs(uint cardid)
}
int CardUtil::CreateCardInput(const uint cardid,
- const uint sourceid, //FIXME: THIS IS NO LONGER STORED IN CARDINPUT
const QString &inputname,
const QString &externalcommand,
const QString &changer_device,
@@ -1517,7 +1516,7 @@ bool CardUtil::DeleteVideoSourceMap(uint videosourcemapid)
bool CardUtil::DeleteUnusedInputs(void)
{
- MSqlQuery query(MSqlQuery::InitCon()); //FIXME: THIS WILL DELETE A CARD IF *ANY* LINKED MAPS HAVE A SOURCEID OF 0 OR NULL.
+ MSqlQuery query(MSqlQuery::InitCon());
query.prepare("SELECT cardinput.cardinputid "
"FROM cardinput "
"LEFT JOIN videosourcemap "
View
1 mythtv/libs/libmythtv/cardutil.h
@@ -261,7 +261,6 @@ class MTV_PUBLIC CardUtil
// Input creation and deletion
static int CreateCardInput(const uint cardid,
- const uint sourceid,
const QString &inputname,
const QString &externalcommand,
const QString &changer_device,
View
32 mythtv/libs/libmythtv/channelbase.cpp
@@ -212,7 +212,7 @@ bool ChannelBase::IsTunable(const QString &input, const QString &channum) const
bool commfree, use_on_air_guide, visible;
QString xmltvid, default_authority, icon;
- if (!ChannelUtil::GetChannelData((*it)->sourceid, channum,
+ if (!ChannelUtil::GetChannelData((*it)->mainsourceid, channum,
tvformat, modulation, freqtable, freqid,
finetune, frequency, dtv_si_std,
mpeg_prog_num, atsc_major, atsc_minor,
@@ -248,7 +248,7 @@ uint ChannelBase::GetNextChannel(uint chanid, int direction) const
if (it == m_inputs.end())
return 0;
- chanid = ChannelUtil::GetChanID((*it)->sourceid, m_curchannelname);
+ chanid = ChannelUtil::GetChanID((*it)->mainsourceid, m_curchannelname);
}
uint mplexid_restriction = 0;
@@ -264,7 +264,7 @@ uint ChannelBase::GetNextChannel(const QString &channum, int direction) const
if (it == m_inputs.end())
return 0;
- uint chanid = ChannelUtil::GetChanID((*it)->sourceid, channum);
+ uint chanid = ChannelUtil::GetChanID((*it)->mainsourceid, channum);
return GetNextChannel(chanid, direction);
}
@@ -298,7 +298,7 @@ int ChannelBase::GetNextInputNum(void) const
}
skip_incr = false;
- if ((*it)->sourceid)
+ if ((*it)->mainsourceid)
break;
}
@@ -315,7 +315,7 @@ QStringList ChannelBase::GetConnectedInputs(void) const
InputMap::const_iterator it = m_inputs.begin();
for (; it != m_inputs.end(); ++it)
- if ((*it)->sourceid)
+ if ((*it)->mainsourceid)
list.push_back((*it)->name);
return list;
@@ -460,13 +460,13 @@ static bool is_input_group_busy(
bool is_busy_input = false;
for (uint i = 0; i < conflicts.size() && !is_busy_input; i++)
- is_busy_input = (in.sourceid != conflicts[i].sourceid);
+ is_busy_input = (in.mainsourceid != conflicts[i].mainsourceid);
if (is_busy_input)
return true;
// If the source's channels aren't digitally tuned then there is a conflict
- is_busy_input = !SourceUtil::HasDigitalChannel(in.sourceid);
+ is_busy_input = !SourceUtil::HasDigitalChannel(in.mainsourceid);
if (!is_busy_input && conflicts[0].chanid)
{
MSqlQuery query(MSqlQuery::InitCon());
@@ -890,7 +890,7 @@ int ChannelBase::GetChanID() const
"WHERE channum = :CHANNUM AND "
" sourceid = :SOURCEID");
query.bindValue(":CHANNUM", m_curchannelname);
- query.bindValue(":SOURCEID", (*it)->sourceid);
+ query.bindValue(":SOURCEID", (*it)->mainsourceid);
if (!query.exec() || !query.isActive())
{
@@ -932,9 +932,9 @@ bool ChannelBase::InitializeInputs(void)
"WHERE cardid = :CARDID AND "
" cardinput.cardinputid = videosourcemap.cardinputid AND "
" type = 'main'");
- /////////////////////////////////////////
- // MAY NEED TO WORK WITH THIS MORE.... //
- /////////////////////////////////////////
+ ///////////////////////////////////////////////
+ // TODO: MAY NEED TO WORK WITH THIS MORE.... //
+ ///////////////////////////////////////////////
query.bindValue(":CARDID", cardid);
@@ -956,15 +956,15 @@ bool ChannelBase::InitializeInputs(void)
QString order = gCoreContext->GetSetting("ChannelOrdering", "channum");
while (query.next())
{
- uint sourceid = query.value(5).toUInt(); //HERE IS WHERE A BLANKET SOURCEID IS BEING DETERMINED FOR THE CARD!!!!
- DBChanInfoList channels = ChannelUtil::GetChannels(sourceid, false);
+ uint mainsourceid = query.value(5).toUInt(); //HERE IS WHERE A BLANKET SOURCEID IS BEING DETERMINED FOR THE CARD!!!!
+ DBChanInfoList channels = ChannelUtil::GetChannels(mainsourceid, false);
ChannelUtil::SortChannels(channels, order);
m_inputs[query.value(0).toUInt()] = new ChannelInputInfo(
query.value(1).toString(), query.value(2).toString(),
query.value(3).toString(), query.value(4).toString(),
- sourceid, cardid,
+ mainsourceid, cardid,
query.value(0).toUInt(), query.value(5).toUInt(),
0, channels);
@@ -994,7 +994,7 @@ bool ChannelBase::InitializeInputs(void)
LOG(VB_CHANNEL, LOG_INFO, LOC +
QString("Input #%1: '%2' schan(%3) sourceid(%4) ccid(%5)")
.arg(it.key()).arg((*it)->name).arg((*it)->startChanNum)
- .arg((*it)->sourceid).arg((*it)->cardid));
+ .arg((*it)->mainsourceid).arg((*it)->cardid));
}
LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Current Input #%1: '%2'")
.arg(GetCurrentInputNum()).arg(GetCurrentInput()));
@@ -1016,7 +1016,7 @@ void ChannelBase::Renumber(uint sourceid,
bool skip = ((*it)->name.isEmpty() ||
(*it)->startChanNum.isEmpty() ||
(*it)->startChanNum != oldChanNum ||
- (*it)->sourceid != sourceid);
+ (*it)->mainsourceid != sourceid);
if (!skip)
(*it)->startChanNum = newChanNum;
}
View
6 mythtv/libs/libmythtv/channelbase.h
@@ -75,10 +75,12 @@ class ChannelBase
{ return m_inputs[GetNextInputNum()]->name; }
virtual QString GetNextInputStartChan(void)
{ return m_inputs[GetNextInputNum()]->startChanNum; }
+
virtual uint GetCurrentSourceID(void) const
- { return m_inputs[GetCurrentInputNum()]->sourceid; }
+ { return m_inputs[GetCurrentInputNum()]->mainsourceid; }
virtual uint GetSourceID(int inputID) const
- { return m_inputs[inputID]->sourceid; }
+ { return m_inputs[inputID]->mainsourceid; }
+
virtual uint GetInputCardID(int inputNum) const;
virtual DBChanInfoList GetChannels(int inputNum) const;
virtual DBChanInfoList GetChannels(const QString &inputname) const;
View
2 mythtv/libs/libmythtv/dtvchannel.cpp
@@ -346,7 +346,7 @@ ChannelUtil::GetChannelSourceID(variablesrcid, channum, GetCurrentInputNum(), ma
{
// We need to pull the pid_cache since there are no tuning tables
pid_cache_t pid_cache;
- int chanid = ChannelUtil::GetChanID((*it)->sourceid, channum);
+ int chanid = ChannelUtil::GetChanID((*it)->mainsourceid, channum);
ChannelUtil::GetCachedPids(chanid, pid_cache);
if (pid_cache.empty())
{
View
24 mythtv/libs/libmythtv/inputinfo.cpp
@@ -5,10 +5,10 @@
InputInfo::InputInfo(
const QString &_name,
- uint _sourceid, uint _inputid, uint _cardid, uint _mplexid,
+ uint _mainsourceid, uint _inputid, uint _cardid, uint _mplexid,
uint _livetvorder) :
name(_name),
- sourceid(_sourceid),
+ mainsourceid(_mainsourceid),
inputid(_inputid),
cardid(_cardid),
mplexid(_mplexid),
@@ -19,7 +19,7 @@ InputInfo::InputInfo(
InputInfo::InputInfo(const InputInfo &other) :
name(other.name),
- sourceid(other.sourceid),
+ mainsourceid(other.mainsourceid),
inputid(other.inputid),
cardid(other.cardid),
mplexid(other.mplexid),
@@ -32,7 +32,7 @@ InputInfo &InputInfo::operator=(const InputInfo &other)
{
name = other.name;
name.detach();
- sourceid = other.sourceid;
+ mainsourceid = other.mainsourceid;
inputid = other.inputid;
cardid = other.cardid;
mplexid = other.mplexid;
@@ -58,11 +58,11 @@ bool InputInfo::FromStringList(QStringList::const_iterator &it,
name = (name == "<EMPTY>") ? QString::null : name;
NEXT();
- sourceid = (*it).toUInt(); NEXT();
- inputid = (*it).toUInt(); NEXT();
- cardid = (*it).toUInt(); NEXT();
- mplexid = (*it).toUInt(); NEXT();
- livetvorder = (*it).toUInt(); ++it;
+ mainsourceid = (*it).toUInt(); NEXT();
+ inputid = (*it).toUInt(); NEXT();
+ cardid = (*it).toUInt(); NEXT();
+ mplexid = (*it).toUInt(); NEXT();
+ livetvorder = (*it).toUInt(); ++it;
return true;
}
@@ -71,7 +71,7 @@ bool InputInfo::FromStringList(QStringList::const_iterator &it,
void InputInfo::ToStringList(QStringList &list) const
{
list.push_back(name.isEmpty() ? "<EMPTY>" : name);
- list.push_back(QString::number(sourceid));
+ list.push_back(QString::number(mainsourceid));
list.push_back(QString::number(inputid));
list.push_back(QString::number(cardid));
list.push_back(QString::number(mplexid));
@@ -80,9 +80,9 @@ void InputInfo::ToStringList(QStringList &list) const
TunedInputInfo::TunedInputInfo(
const QString &_name,
- uint _sourceid, uint _inputid, uint _cardid, uint _mplexid,
+ uint _mainsourceid, uint _inputid, uint _cardid, uint _mplexid,
uint _livetvorder, uint _chanid) :
- InputInfo(_name, _sourceid, _inputid, _cardid, _mplexid, _livetvorder),
+ InputInfo(_name, _mainsourceid, _inputid, _cardid, _mplexid, _livetvorder),
chanid(_chanid)
{
}
View
26 mythtv/libs/libmythtv/inputinfo.h
@@ -13,11 +13,11 @@ class MTV_PUBLIC InputInfo
{
public:
InputInfo() : name(QString::null),
- sourceid(0), inputid(0), cardid(0), mplexid(0),
+ mainsourceid(0), inputid(0), cardid(0), mplexid(0),
livetvorder(0) {}
InputInfo(const QString &name,
- uint sourceid, uint inputid, uint cardid, uint mplexid,
- uint livetvorder);
+ uint _mainsourceid, uint _inputid, uint _cardid, uint _mplexid,
+ uint _livetvorder);
InputInfo(const InputInfo &other);
InputInfo &operator=(const InputInfo &other);
virtual ~InputInfo() {}
@@ -36,21 +36,21 @@ class MTV_PUBLIC InputInfo
{ return name == _name; }
public:
- QString name; ///< input name
- uint sourceid; ///< associated channel listings source
- uint inputid; ///< unique key in DB for this input
- uint cardid; ///< card id associated with input
- uint mplexid; ///< mplexid restriction if applicable
- uint livetvorder; ///< order for live TV use
+ QString name; ///< input name
+ uint mainsourceid; ///< associated channel listings source
+ uint inputid; ///< unique key in DB for this input
+ uint cardid; ///< card id associated with input
+ uint mplexid; ///< mplexid restriction if applicable
+ uint livetvorder; ///< order for live TV use
};
class MTV_PUBLIC TunedInputInfo : public InputInfo
{
public:
TunedInputInfo() : chanid(0) { }
TunedInputInfo(const QString &name,
- uint _sourceid, uint _inputid,
- uint _cardid, uint _mplexid, uint _livetvorder,
+ uint _mainsourceid, uint _inputid,
+ uint _cardid, uint _mplexid, uint _livetvorder,
uint _chanid);
TunedInputInfo(const TunedInputInfo &other);
TunedInputInfo &operator=(const TunedInputInfo &other);
@@ -76,11 +76,11 @@ class MTV_PUBLIC ChannelInputInfo : public InputInfo
videoModeV4L1(0), videoModeV4L2(0) {}
ChannelInputInfo(QString _name, QString _startChanNum,
QString _tuneToChannel, QString _externalChanger,
- uint _sourceid, uint _cardid,
+ uint _mainsourceid, uint _cardid,
uint _inputid, uint _mplexid,
uint _livetvorder,
const DBChanInfoList &_channels) :
- InputInfo(_name, _sourceid, _inputid, _cardid, _mplexid, _livetvorder),
+ InputInfo(_name, _mainsourceid, _inputid, _cardid, _mplexid, _livetvorder),
startChanNum(_startChanNum),
tuneToChannel(_tuneToChannel), externalChanger(_externalChanger),
channels(_channels),
View
2 mythtv/libs/libmythtv/iptvchannel.cpp
@@ -143,7 +143,7 @@ IPTVChannelInfo IPTVChannel::GetChanInfo(
LOG(VB_GENERAL, LOG_ERR, msg);
return dummy;
}
- sourceid = (*it)->sourceid;
+ sourceid = (*it)->mainsourceid;
}
MSqlQuery query(MSqlQuery::InitCon());
View
24 mythtv/libs/libmythtv/tv_play.cpp
@@ -1836,7 +1836,7 @@ void TV::ShowOSDAskAllow(PlayerContext *ctx)
(*it).is_conflicting = true;
else if (!CardUtil::IsTunerShared(cardid, (*it).info->GetCardID()))
(*it).is_conflicting = true;
- else if ((busy_input.sourceid == (uint)(*it).info->GetSourceID()) &&
+ else if ((busy_input.mainsourceid == (uint)(*it).info->GetSourceID()) &&
(busy_input.mplexid == (uint)(*it).info->QueryMplexID()))
(*it).is_conflicting = false;
else
@@ -6473,11 +6473,11 @@ void TV::SwitchSource(PlayerContext *ctx, uint source_direction)
for (uint i = 0; i < inputs.size(); i++)
{
// prefer the current card's input in sources list
- if ((sources.find(inputs[i].sourceid) == sources.end()) ||
+ if ((sources.find(inputs[i].mainsourceid) == sources.end()) ||
((cardid == inputs[i].cardid) &&
- (cardid != sources[inputs[i].sourceid].cardid)))
+ (cardid != sources[inputs[i].mainsourceid].cardid)))
{
- sources[inputs[i].sourceid] = inputs[i];
+ sources[inputs[i].mainsourceid] = inputs[i];
}
}
}
@@ -7986,7 +7986,7 @@ QSet<uint> TV::IsTunableOn(
for (uint j = 0; j < inputs.size(); j++)
{
- if (inputs[j].sourceid != sourceid)
+ if (inputs[j].mainsourceid != sourceid)
continue;
if (inputs[j].mplexid &&
@@ -11231,8 +11231,8 @@ void TV::FillOSDMenuSource(const PlayerContext *ctx, OSD *osd,
continue;
for (uint i = 0; i < inputs.size(); i++)
- if (!sources.contains(inputs[i].sourceid))
- sources[inputs[i].sourceid] = inputs[i];
+ if (!sources.contains(inputs[i].mainsourceid))
+ sources[inputs[i].mainsourceid] = inputs[i];
}
// Get other sources available on this card
vector<uint> currentinputs = CardUtil::GetInputIDs(cardid);
@@ -11243,9 +11243,9 @@ void TV::FillOSDMenuSource(const PlayerContext *ctx, OSD *osd,
InputInfo info;
info.inputid = currentinputs[i];
if (CardUtil::GetInputInfo(info))
- if (!sources.contains(info.sourceid) &&
+ if (!sources.contains(info.mainsourceid) &&
info.livetvorder)
- sources[info.sourceid] = info;
+ sources[info.mainsourceid] = info;
}
}
// delete current source from list
@@ -11275,7 +11275,7 @@ void TV::FillOSDMenuSource(const PlayerContext *ctx, OSD *osd,
for (uint i = 0; i < inputs.size(); i++)
{
if ((inputs[i].cardid == cardid) &&
- (inputs[i].sourceid == sourceid))
+ (inputs[i].mainsourceid == sourceid))
{
testsize = 1;
break;
@@ -11326,7 +11326,7 @@ void TV::FillOSDMenuSource(const PlayerContext *ctx, OSD *osd,
{
// don't add current input to list
if ((inputs[i].cardid == cardid) &&
- (inputs[i].sourceid == sourceid))
+ (inputs[i].mainsourceid == sourceid))
{
continue;
}
@@ -11350,7 +11350,7 @@ void TV::FillOSDMenuSource(const PlayerContext *ctx, OSD *osd,
QMap<uint,InputInfo>::const_iterator sit = sources.begin();
for (; sit != sources.end(); ++sit)
{
- osd->DialogAddButton(SourceUtil::GetSourceName((*sit).sourceid),
+ osd->DialogAddButton(SourceUtil::GetSourceName((*sit).mainsourceid),
QString("SWITCHTOINPUT_%1").arg((*sit).inputid));
}
}
View
2 mythtv/libs/libmythtv/tv_rec.cpp
@@ -502,7 +502,7 @@ RecStatusType TVRec::StartRecording(const ProgramInfo *rcinfo)
}
if (is_busy &&
- ((sourceid != busy_input.sourceid) ||
+ ((sourceid != busy_input.mainsourceid) ||
(mplexid != busy_input.mplexid)))
{
states.push_back((TVState) RemoteGetState(cardids[i]));
View
6 mythtv/programs/mythbackend/services/capture.cpp
@@ -283,11 +283,13 @@ int Capture::AddCardInput ( const uint nCardId,
const uint nSchedOrder,
const uint nLiveTVOrder)
{
+// FIXME: SourceID has been removed from the cardinput table and is now in the videosourcemap table. Need to update this code.
+/*
if ( nCardId < 1 || nSourceId < 1 || sInputName.isEmpty() )
throw( QString( "This API requires at least a card ID, a source ID, "
"and an input name." ));
-
- int nResult = CardUtil::CreateCardInput(nCardId, nSourceId, sInputName,
+*/
+ int nResult = CardUtil::CreateCardInput(nCardId, /*nSourceId,*/ sInputName,
sExternalCommand, sChangerDevice, sChangerModel,
sHostName, sTuneChan, sStartChan, sDisplayName,
bDishnetEIT, nRecPriority, nQuicktune, nSchedOrder,

0 comments on commit 218e9b0

Please sign in to comment.