Skip to content

Commit

Permalink
Allow easier control of card input ordering.
Browse files Browse the repository at this point in the history
This change adds two new settings at the card input level.  These
settings allow fine-grained control of the order inputs are used for
scheduling and live TV without the need to delete and recreate the
cards and inputs in the desired order.

"Schedule Order" defines the order inputs are used when scheduling
recordings and priorities are equal.  The available input with the
lowest, positive order number is used first.  Previously, the input
with the lowest input ID was used first.  If the schedule orders for
two inputs are equal, the old behavior is used as a fallback.  Setting
the schedule order for an input to zero makes that input unavailable
for scheduling.

"Live TV Order" defines the order inputs are used when entering live
TV.  The available input with the lowest, positive order number is
used first.  Previously, the default input on the card with the lowest
(or highest if "Avoid Conflicts..." was set) card ID was used first.
If the live TV order for two inputs are equal, the order they are used
is undefined.  Setting the live TV order for an input to zero makes
that input unavailable for live TV.  This setting obsoletes the old
"Avoid conflicts between Live TV and scheduled shows" setting.

Setting either schedule order or live TV order to zero for an input
effectively restricts the use of that input to the other activity.  In
other words, it is now possible to dedicate an input exclusively to
scheduling only or live TV only.

Setting both schedule order and live TV order to zero effectively
takes that input off-line as far as MythTV is concerned.  That input
can then be safely used for other purposes outside of MythTV as long
as the user avoids conflicts with other inputs on the same card or in
the same input group.

Note: this change doesn't yet do exactly what it claims.  The input
used when entering live TV is actually the default input on the card
with the input having the lowest, positive live TV order.  This will
be corrected in a later commit.
  • Loading branch information
gigem committed Jan 15, 2012
1 parent cd88d57 commit 3281cdd
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 87 deletions.
6 changes: 3 additions & 3 deletions mythtv/bindings/perl/MythTV.pm
Expand Up @@ -106,15 +106,15 @@ package MythTV;
# Note: as of July 21, 2010, this is actually a string, to account for proto
# versions of the form "58a". This will get used if protocol versions are
# changed on a fixes branch ongoing.
our $PROTO_VERSION = "70";
our $PROTO_TOKEN = "53153836";
our $PROTO_VERSION = "71";
our $PROTO_TOKEN = "05e82186";

# currentDatabaseVersion is defined in libmythtv in
# mythtv/libs/libmythtv/dbcheck.cpp and should be the current MythTV core
# schema version supported in the main code. We need to check that the schema
# version in the database is as expected by the bindings, which are expected
# to be kept in sync with the main code.
our $SCHEMA_VERSION = "1292";
our $SCHEMA_VERSION = "1293";

# NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
# the number of items in a ProgramInfo QStringList group used by
Expand Down
4 changes: 2 additions & 2 deletions mythtv/bindings/php/MythBackend.php
Expand Up @@ -11,8 +11,8 @@ class MythBackend {

// MYTH_PROTO_VERSION is defined in libmyth in mythtv/libs/libmyth/mythcontext.h
// and should be the current MythTV protocol version.
static $protocol_version = '70';
static $protocol_token = '53153836';
static $protocol_version = '71';
static $protocol_token = '05e82186';

// The character string used by the backend to separate records
static $backend_separator = '[]:[]';
Expand Down
6 changes: 3 additions & 3 deletions mythtv/bindings/python/MythTV/static.py
Expand Up @@ -5,11 +5,11 @@
"""

OWN_VERSION = (0,25,-1,3)
SCHEMA_VERSION = 1292
SCHEMA_VERSION = 1293
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
PROTO_VERSION = '70'
PROTO_TOKEN = '53153836'
PROTO_VERSION = '71'
PROTO_TOKEN = '05e82186'
BACKEND_SEP = '[]:[]'
INSTALL_PREFIX = '/usr/local'

Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20111207-1"
#define MYTH_BINARY_VERSION "0.25.20120103-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand All @@ -35,8 +35,8 @@
* mythtv/bindings/python/MythTV/static.py (version number)
* mythtv/bindings/python/MythTV/mythproto.py (layout)
*/
#define MYTH_PROTO_VERSION "70"
#define MYTH_PROTO_TOKEN "53153836"
#define MYTH_PROTO_VERSION "71"
#define MYTH_PROTO_TOKEN "05e82186"

/** \brief Increment this whenever the MythTV core database schema changes.
*
Expand All @@ -51,7 +51,7 @@
* MythTV Python Bindings
* mythtv/bindings/python/MythTV/static.py
*/
#define MYTH_DATABASE_VERSION "1292"
#define MYTH_DATABASE_VERSION "1293"


MBASE_PUBLIC const char *GetMythSourceVersion();
Expand Down
Expand Up @@ -51,7 +51,7 @@
class SERVICE_PUBLIC CaptureServices : public Service
{
Q_OBJECT
Q_CLASSINFO( "version" , "1.2" );
Q_CLASSINFO( "version" , "1.3" );
Q_CLASSINFO( "RemoveCaptureCard_Method", "POST" )
Q_CLASSINFO( "AddCaptureCard_Method", "POST" )
Q_CLASSINFO( "UpdateCaptureCard_Method", "POST" )
Expand Down Expand Up @@ -125,7 +125,9 @@ class SERVICE_PUBLIC CaptureServices : public Service
const QString &DisplayName,
bool DishnetEIT,
const uint RecPriority,
const uint Quicktune) = 0;
const uint Quicktune,
const uint SchedOrder,
const uint LiveTVOrder) = 0;

virtual bool UpdateCardInput ( int CardInputId,
const QString &Setting,
Expand Down
26 changes: 17 additions & 9 deletions mythtv/libs/libmythtv/cardutil.cpp
Expand Up @@ -778,7 +778,8 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
query.prepare(
"SELECT sourceid, inputname, externalcommand, "
" tunechan, startchan, displayname, "
" dishnet_eit, recpriority, quicktune "
" dishnet_eit, recpriority, quicktune, "
" schedorder, livetvorder "
"FROM cardinput "
"WHERE cardinputid = :INPUTID");
query.bindValue(":INPUTID", src_inputs[i]);
Expand Down Expand Up @@ -821,10 +822,12 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
" displayname = :V5, "
" dishnet_eit = :V6, "
" recpriority = :V7, "
" quicktune = :V8 "
" quicktune = :V8, "
" schedorder = :V9, "
" livetvorder = :V10 "
"WHERE cardinputid = :INPUTID");

for (uint j = 0; j < 9; j++)
for (uint j = 0; j < 11; j++)
{
query2.bindValue(QString(":V%1").arg(j),
query.value(j).toString());
Expand Down Expand Up @@ -1169,7 +1172,7 @@ bool CardUtil::GetInputInfo(InputInfo &input, vector<uint> *groupids)
return false;

MSqlQuery query(MSqlQuery::InitCon());
query.prepare("SELECT inputname, sourceid, cardid "
query.prepare("SELECT inputname, sourceid, cardid, livetvorder "
"FROM cardinput "
"WHERE cardinputid = :INPUTID");
query.bindValue(":INPUTID", input.inputid);
Expand All @@ -1186,6 +1189,7 @@ bool CardUtil::GetInputInfo(InputInfo &input, vector<uint> *groupids)
input.name = query.value(0).toString();
input.sourceid = query.value(1).toUInt();
input.cardid = query.value(2).toUInt();
input.livetvorder = query.value(3).toUInt();

if (groupids)
*groupids = GetInputGroups(input.inputid);
Expand All @@ -1195,14 +1199,14 @@ bool CardUtil::GetInputInfo(InputInfo &input, vector<uint> *groupids)

uint CardUtil::GetCardID(uint inputid)
{
InputInfo info(QString::null, 0, inputid, 0, 0);
InputInfo info(QString::null, 0, inputid, 0, 0, 0);
GetInputInfo(info);
return info.cardid;
}

QString CardUtil::GetInputName(uint inputid)
{
InputInfo info(QString::null, 0, inputid, 0, 0);
InputInfo info(QString::null, 0, inputid, 0, 0, 0);
GetInputInfo(info);
return info.name;
}
Expand Down Expand Up @@ -1327,18 +1331,20 @@ int CardUtil::CreateCardInput(const uint cardid,
const QString &displayname,
bool dishnet_eit,
const uint recpriority,
const uint quicktune)
const uint quicktune,
const uint schedorder,
const uint livetvorder)
{
MSqlQuery query(MSqlQuery::InitCon());

query.prepare(
"INSERT INTO cardinput "
"(cardid, sourceid, inputname, externalcommand, changer_device, "
"changer_model, tunechan, startchan, displayname, dishnet_eit, "
"recpriority, quicktune) "
"recpriority, quicktune, schedorder, livetvorder) "
"VALUES (:CARDID, :SOURCEID, :INPUTNAME, :EXTERNALCOMMAND, "
":CHANGERDEVICE, :CHANGERMODEL, :TUNECHAN, :STARTCHAN, :DISPLAYNAME, "
":DISHNETEIT, :RECPRIORITY, :QUICKTUNE ) ");
":DISHNETEIT, :RECPRIORITY, :QUICKTUNE, :SCHEDORDER, :LIVETVORDER ) ");

query.bindValue(":CARDID", cardid);
query.bindValue(":SOURCEID", sourceid);
Expand All @@ -1352,6 +1358,8 @@ int CardUtil::CreateCardInput(const uint cardid,
query.bindValue(":DISHNETEIT", dishnet_eit);
query.bindValue(":RECPRIORITY", recpriority);
query.bindValue(":QUICKTUNE", quicktune);
query.bindValue(":SCHEDORDER", schedorder);
query.bindValue(":LIVETVORDER", livetvorder);

if (!query.exec())
{
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythtv/cardutil.h
Expand Up @@ -275,7 +275,9 @@ class MTV_PUBLIC CardUtil
const QString &displayname,
bool dishnet_eit,
const uint recpriority,
const uint quicktune);
const uint quicktune,
const uint schedorder,
const uint livetvorder);

static bool DeleteInput(uint inputid);

Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/channelbase.cpp
Expand Up @@ -592,7 +592,7 @@ vector<InputInfo> ChannelBase::GetFreeInputs(
info.inputid, groupids, excluded_cardids,
busygrp, busyrec, busyin, info.mplexid);

if (!is_busy_grp)
if (!is_busy_grp && info.livetvorder)
new_list.push_back(info);
}

Expand Down Expand Up @@ -921,7 +921,7 @@ bool ChannelBase::InitializeInputs(void)
"SELECT cardinputid, "
" inputname, startchan, "
" tunechan, externalcommand, "
" sourceid "
" sourceid, livetvorder "
"FROM cardinput "
"WHERE cardid = :CARDID");
query.bindValue(":CARDID", cardid);
Expand Down Expand Up @@ -953,8 +953,8 @@ bool ChannelBase::InitializeInputs(void)
query.value(1).toString(), query.value(2).toString(),
query.value(3).toString(), query.value(4).toString(),
sourceid, cardid,
query.value(0).toUInt(), 0,
channels);
query.value(0).toUInt(), query.value(5).toUInt(),
0, channels);

if (!IsExternalChannelChangeSupported() &&
!m_inputs[query.value(0).toUInt()]->externalChanger.isEmpty())
Expand Down
22 changes: 22 additions & 0 deletions mythtv/libs/libmythtv/dbcheck.cpp
Expand Up @@ -6082,6 +6082,28 @@ NULL
return false;
}

if (dbver == "1292")
{
const char *updates[] = {
"ALTER TABLE cardinput "
" ADD COLUMN schedorder INT(10) UNSIGNED NOT NULL DEFAULT '0', "
" ADD COLUMN livetvorder INT(10) UNSIGNED NOT NULL DEFAULT '0';",
"UPDATE cardinput SET schedorder = cardinputid;",
"UPDATE cardinput SET livetvorder = cardid;",
NULL
};

if (gCoreContext->GetNumSetting("LastFreeCard", 0))
{
updates[2] =
"UPDATE cardinput SET livetvorder = "
" (SELECT MAX(cardid) FROM capturecard) - cardid + 1;";
}

if (!performActualUpdate(updates, "1293", dbver))
return false;
}

return true;
}

Expand Down
20 changes: 14 additions & 6 deletions mythtv/libs/libmythtv/inputinfo.cpp
Expand Up @@ -5,12 +5,14 @@

InputInfo::InputInfo(
const QString &_name,
uint _sourceid, uint _inputid, uint _cardid, uint _mplexid) :
uint _sourceid, uint _inputid, uint _cardid, uint _mplexid,
uint _livetvorder) :
name(_name),
sourceid(_sourceid),
inputid(_inputid),
cardid(_cardid),
mplexid(_mplexid)
mplexid(_mplexid),
livetvorder(_livetvorder)
{
name.detach();
}
Expand All @@ -20,7 +22,8 @@ InputInfo::InputInfo(const InputInfo &other) :
sourceid(other.sourceid),
inputid(other.inputid),
cardid(other.cardid),
mplexid(other.mplexid)
mplexid(other.mplexid),
livetvorder(other.livetvorder)
{
name.detach();
}
Expand All @@ -33,6 +36,7 @@ InputInfo &InputInfo::operator=(const InputInfo &other)
inputid = other.inputid;
cardid = other.cardid;
mplexid = other.mplexid;
livetvorder = other.livetvorder;
return *this;
}

Expand All @@ -57,7 +61,8 @@ bool InputInfo::FromStringList(QStringList::const_iterator &it,
sourceid = (*it).toUInt(); NEXT();
inputid = (*it).toUInt(); NEXT();
cardid = (*it).toUInt(); NEXT();
mplexid = (*it).toUInt(); ++it;
mplexid = (*it).toUInt(); NEXT();
livetvorder = (*it).toUInt(); ++it;

return true;
}
Expand All @@ -70,12 +75,15 @@ void InputInfo::ToStringList(QStringList &list) const
list.push_back(QString::number(inputid));
list.push_back(QString::number(cardid));
list.push_back(QString::number(mplexid));
list.push_back(QString::number(livetvorder));
}

TunedInputInfo::TunedInputInfo(
const QString &_name,
uint _sourceid, uint _inputid, uint _cardid, uint _mplexid, uint _chanid) :
InputInfo(_name, _sourceid, _inputid, _cardid, _mplexid), chanid(_chanid)
uint _sourceid, uint _inputid, uint _cardid, uint _mplexid,
uint _livetvorder, uint _chanid) :
InputInfo(_name, _sourceid, _inputid, _cardid, _mplexid, _livetvorder),
chanid(_chanid)
{
}

Expand Down
13 changes: 9 additions & 4 deletions mythtv/libs/libmythtv/inputinfo.h
Expand Up @@ -13,9 +13,11 @@ class MTV_PUBLIC InputInfo
{
public:
InputInfo() : name(QString::null),
sourceid(0), inputid(0), cardid(0), mplexid(0) {}
sourceid(0), inputid(0), cardid(0), mplexid(0),
livetvorder(0) {}
InputInfo(const QString &name,
uint sourceid, uint inputid, uint cardid, uint mplexid);
uint sourceid, uint inputid, uint cardid, uint mplexid,
uint livetvorder);
InputInfo(const InputInfo &other);
InputInfo &operator=(const InputInfo &other);
virtual ~InputInfo() {}
Expand All @@ -39,6 +41,7 @@ class MTV_PUBLIC InputInfo
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
Expand All @@ -47,7 +50,8 @@ class MTV_PUBLIC TunedInputInfo : public InputInfo
TunedInputInfo() : chanid(0) { }
TunedInputInfo(const QString &name,
uint _sourceid, uint _inputid,
uint _cardid, uint _mplexid, uint _chanid);
uint _cardid, uint _mplexid, uint _livetvorder,
uint _chanid);
TunedInputInfo(const TunedInputInfo &other);
TunedInputInfo &operator=(const TunedInputInfo &other);
virtual ~TunedInputInfo() {}
Expand All @@ -74,8 +78,9 @@ class MTV_PUBLIC ChannelInputInfo : public InputInfo
QString _tuneToChannel, QString _externalChanger,
uint _sourceid, uint _cardid,
uint _inputid, uint _mplexid,
uint _livetvorder,
const DBChanList &_channels) :
InputInfo(_name, _sourceid, _inputid, _cardid, _mplexid),
InputInfo(_name, _sourceid, _inputid, _cardid, _mplexid, _livetvorder),
startChanNum(_startChanNum),
tuneToChannel(_tuneToChannel), externalChanger(_externalChanger),
channels(_channels),
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -10926,7 +10926,8 @@ 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.sourceid) &&
info.livetvorder)
sources[info.sourceid] = info;
}
}
Expand Down

0 comments on commit 3281cdd

Please sign in to comment.