Ticket #3842: 3843-validation-head-v1.patch

File 3843-validation-head-v1.patch, 6.7 KB (added by danielk, 18 years ago)

Reworks video source validation that is run before inserting channels. Notably firewire connected lineups have their channels inserted with SD with this patch (workaround is to disconnect Video Source for firewire and run mythfilldatabase).

  • libs/libmythtv/cardutil.h

     
    107107            (rawtype == "HDHOMERUN");
    108108    }
    109109
     110    static bool         IsTuningDigital(const QString &rawtype)
     111    {
     112        return
     113            (rawtype == "DVB")       || (rawtype == "HDTV")  ||
     114            (rawtype == "HDHOMERUN");
     115    }
     116
     117    static bool         IsTuningAnalog(const QString &rawtype)
     118    {
     119        return (rawtype == "V4L");
     120    }
     121
    110122    static int          GetCardID(const QString &videodevice,
    111123                                  QString hostname = QString::null);
    112124    static uint         GetChildCardID(uint cardid);
  • libs/libmythtv/sourceutil.h

     
    1616    static bool    GetListingsLoginData(uint sourceid,
    1717                                        QString &grabber, QString &userid,
    1818                                        QString &passwd,  QString &lineupid);
     19    static uint    GetConnectionCount(uint sourceid);
     20    static bool    IsProperlyConnected(uint sourceid, bool strich = false);
    1921    static bool    IsEncoder(uint sourceid, bool strict = false);
    2022    static bool    IsUnscanable(uint sourceid);
    2123    static bool    IsAnySourceScanable(void);
  • libs/libmythtv/datadirect.cpp

     
    686686{
    687687    int new_channels = 0;
    688688
     689    if (!SourceUtil::GetConnectionCount(sourceid))
     690    {
     691        VERBOSE(VB_IMPORTANT, LOC +
     692                "Not inserting channels into disconnected source "
     693                <<sourceid<<".");
     694    }
     695
     696    if (!SourceUtil::IsProperlyConnected(sourceid, true))
     697        return -1;
     698
    689699    // Find all the channels in the dd_v_station temp table
    690700    // where there is no channel with the same xmltvid in the
    691701    // DB using the same source.
     
    706716        return -1;
    707717    }
    708718
    709     bool is_encoder = SourceUtil::IsEncoder(sourceid, true);
     719    bool is_encoder = (SourceUtil::IsEncoder(sourceid, true) ||
     720                       SourceUtil::IsUnscanable(sourceid));
    710721
    711722    while (query.next())
    712723    {
     
    750761bool DataDirectProcessor::UpdateChannelsUnsafe(
    751762    uint sourceid, bool filter_new_channels)
    752763{
     764    if (filter_new_channels &&
     765        !SourceUtil::IsProperlyConnected(sourceid, false))
     766    {
     767        return false;
     768    }
     769
    753770    MSqlQuery dd_station_info(MSqlQuery::DDCon());
    754771    dd_station_info.prepare(
    755772        "SELECT callsign,         stationname, stationid,"
     
    770787        "    atsc_minor_chan = :MINORCHAN "
    771788        "WHERE xmltvid = :STATIONID AND sourceid = :SOURCEID");
    772789
    773     bool is_encoder = SourceUtil::IsEncoder(sourceid, true);
     790    bool is_encoder = (SourceUtil::IsEncoder(sourceid, true) ||
     791                       SourceUtil::IsUnscanable(sourceid));
    774792
    775793    while (dd_station_info.next())       
    776794    {
  • libs/libmythtv/sourceutil.cpp

     
    114114    return list;
    115115}
    116116
     117uint SourceUtil::GetConnectionCount(uint sourceid)
     118{
     119    QStringList types = get_cardtypes(sourceid);
     120    return types.size();
     121}
     122
     123bool SourceUtil::IsProperlyConnected(uint sourceid, bool strict)
     124{
     125    QStringList types = get_cardtypes(sourceid);
     126    QMap<QString,uint> counts;
     127    QStringList::const_iterator it = types.begin();
     128    for (; it != types.end(); ++it)
     129    {
     130        counts[*it]++;
     131
     132        counts[CardUtil::IsEncoder(*it)    ? "ENCODER" : "NOT_ENCODER"]++;
     133        counts[CardUtil::IsUnscanable(*it) ? "NO_SCAN" : "SCAN"]++;
     134
     135        if (CardUtil::IsTuningAnalog(*it))
     136            counts["ANALOG_TUNING"]++;
     137        else if (CardUtil::IsTuningDigital(*it))
     138            counts["DIGITAL_TUNING"]++;
     139        else
     140            counts["OTHER_TUNING"]++;
     141    }
     142
     143    bool tune_mismatch = counts["ANALOG_TUNING"]   && counts["DIGITAL_TUNING"];
     144    bool enc_mismatch  = counts["ENCODER"]         && counts["NOT_ENCODER"];
     145    bool scan_mismatch = counts["SCAN"]            && counts["NO_SCAN"];
     146    bool fw_mismatch   = (counts["FIREWIRE"] &&
     147                          (counts["FIREWIRE"] < types.size()));
     148
     149    if (tune_mismatch)
     150    {
     151        uint a = counts["ANALOG_TUNERS"];
     152        uint d = counts["DIGITAL_TUNERS"];
     153        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     154                QString("Source ID %1 ").arg(sourceid) +
     155                QString("appears to be connected\n\t\t\tto %1 analog tuner%2,")
     156                .arg(a).arg((1 == a) ? "":"s") +
     157                QString("and %1 digital tuner%2.\n\t\t\t")
     158                .arg(d).arg((1 == d) ? "":"s") +
     159                QString("Can't mix analog and digital tuning information."));
     160    }
     161
     162    if (enc_mismatch)
     163    {
     164        uint a = counts["ENCODER"];
     165        uint d = counts["NOT_ENCODER"];
     166        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     167                QString("Source ID %1 ").arg(sourceid) +
     168                QString("appears to be connected\n\t\t\tto %1 encoder%2, ")
     169                .arg(a).arg((1 == a) ? "":"s") +
     170                QString("and %1 non-encoder%2. ")
     171                .arg(d).arg((1 == d) ? "":"s") +
     172                QString("This is probably a bad idea."));
     173    }
     174
     175    if (scan_mismatch)
     176    {
     177        uint a = counts["SCAN"];
     178        uint d = counts["NO_SCAN"];
     179        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     180                QString("Source ID %1 ").arg(sourceid) +
     181                QString("appears to be connected\n\t\t\t"
     182                        "to %1 scanable input%2, ")
     183                .arg(a).arg((1 == a) ? "":"s") +
     184                QString("and %1 non-scanable input%2. ")
     185                .arg(d).arg((1 == d) ? "":"s") +
     186                QString("This may be a problem."));
     187    }
     188
     189    if (fw_mismatch)
     190    {
     191        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     192                QString(
     193                    "Source ID %1 appears to be connected\n\t\t\t"
     194                    "to both firewire and non-firewire inputs. "
     195                    "This is probably a bad idea.").arg(sourceid));
     196    }
     197
     198    if (!strict)
     199        return !tune_mismatch;
     200
     201    return !tune_mismatch && !enc_mismatch && !scan_mismatch && !fw_mismatch;
     202}
     203
    117204bool SourceUtil::IsEncoder(uint sourceid, bool strict)
    118205{
    119206    bool encoder = true;