All pastes #2067647 Raw Edit

Untitled

public text v1 · immutable
#2067647 ·published 2011-05-23 14:05 UTC
rendered paste body
diff --git a/mythtv/bindings/perl/MythTV.pm b/mythtv/bindings/perl/MythTV.pm
index f07de2d..ebaecaf 100644
--- a/mythtv/bindings/perl/MythTV.pm
+++ b/mythtv/bindings/perl/MythTV.pm
@@ -114,7 +114,7 @@ package MythTV;
 # 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 = "1273";
+    our $SCHEMA_VERSION = "1274";
 
 # NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
 # the number of items in a ProgramInfo QStringList group used by
diff --git a/mythtv/bindings/python/MythTV/static.py b/mythtv/bindings/python/MythTV/static.py
index ff5fabf..a090431 100644
--- a/mythtv/bindings/python/MythTV/static.py
+++ b/mythtv/bindings/python/MythTV/static.py
@@ -5,7 +5,7 @@ Contains any static and global variables for MythTV Python Bindings
 """
 
 OWN_VERSION = (0,25,-1,2)
-SCHEMA_VERSION = 1273
+SCHEMA_VERSION = 1274
 NVSCHEMA_VERSION = 1007
 MUSICSCHEMA_VERSION = 1018
 PROTO_VERSION = '65'
diff --git a/mythtv/libs/libmythtv/dbcheck.cpp b/mythtv/libs/libmythtv/dbcheck.cpp
index e0d17c5..be8a380 100644
--- a/mythtv/libs/libmythtv/dbcheck.cpp
+++ b/mythtv/libs/libmythtv/dbcheck.cpp
@@ -21,7 +21,7 @@ using namespace std;
    mythtv/bindings/perl/MythTV.pm
 */
 /// This is the DB schema version expected by the running MythTV instance.
-const QString currentDatabaseVersion = "1273";
+const QString currentDatabaseVersion = "1274";
 
 static bool UpdateDBVersionNumber(const QString &newnumber, QString &dbver);
 static bool performActualUpdate(
@@ -5648,6 +5648,43 @@ NULL
             return false;
     }
 
+    if (dbver == "1273")
+    {
+        const char *updates[] = {
+"UPDATE cardinput SET tunechan=NULL"
+"  WHERE inputname='DVBInput' OR inputname='MPEG2TS';"
+"UPDATE dtv_multiplex SET symbolrate = NULL"
+"  WHERE SUBSTR(modulation,1,2)='t' OR modulation LIKE '%t';",
+"UPDATE dtv_multiplex SET symbolrate = NULL"
+"  WHERE SUBSTR(modulation,1,2)='t' OR modulation LIKE '%t';",
+"UPDATE dtv_multiplex"
+"  SET bandwidth=SUBSTR(modulation,2,1)"
+"  WHERE SUBSTR(modulation,3,3)='qam' OR"
+"        SUBSTR(modulation,3,4)='qpsk';",
+"UPDATE dtv_multiplex"
+"  SET bandwidth=SUBSTR(modulation,5,1)"
+"  WHERE SUBSTR(modulation,1,4)='auto' AND"
+"        LENGTH(modulation)=6;",
+"UPDATE dtv_multiplex SET modulation='auto'"
+"  WHERE modulation LIKE 'auto%';",
+"UPDATE dtv_multiplex SET modulation='qam_16'"
+"  WHERE modulation LIKE '%qam16%';",
+"UPDATE dtv_multiplex SET modulation='qam_32'"
+"  WHERE modulation LIKE '%qam32%';",
+"UPDATE dtv_multiplex SET modulation='qam_64'"
+"  WHERE modulation LIKE '%qam64%';",
+"UPDATE dtv_multiplex SET modulation='qam_128'"
+"  WHERE modulation LIKE '%qam128%';",
+"UPDATE dtv_multiplex SET modulation='qam_256'"
+"  WHERE modulation LIKE '%qam256%';",
+NULL
+};
+        if (!performActualUpdate(updates, "1274", dbver))
+            return false;
+    }
+
+    
+
     return true;
 }
 
diff --git a/mythtv/libs/libmythtv/dtvconfparserhelpers.cpp b/mythtv/libs/libmythtv/dtvconfparserhelpers.cpp
index d6fcaca..e9d2f7d 100644
--- a/mythtv/libs/libmythtv/dtvconfparserhelpers.cpp
+++ b/mythtv/libs/libmythtv/dtvconfparserhelpers.cpp
@@ -44,6 +44,7 @@ const int DTVTunerType::kTunerTypeDVBC    = 0x0001;
 const int DTVTunerType::kTunerTypeDVBT    = 0x0002;
 const int DTVTunerType::kTunerTypeATSC    = 0x0003;
 const int DTVTunerType::kTunerTypeASI     = 0x1000;
+const int DTVTunerType::kTunerTypeOCUR    = 0x2000;
 const int DTVTunerType::kTunerTypeUnknown = 0x80000000;
 
 static QMutex dtv_tt_canonical_str_lock;
@@ -57,6 +58,7 @@ void DTVTunerType::initStr(void)
     dtv_tt_canonical_str[kTunerTypeDVBS1]   = "QPSK";
     dtv_tt_canonical_str[kTunerTypeDVBS2]   = "DVB_S2";
     dtv_tt_canonical_str[kTunerTypeASI]     = "ASI";
+    dtv_tt_canonical_str[kTunerTypeOCUR]    = "OCUR";
     dtv_tt_canonical_str[kTunerTypeUnknown] = "UNKNOWN";
 }
 
@@ -77,6 +79,7 @@ const DTVParamHelperStruct DTVTunerType::parseTable[] =
     { "ATSC",    kTunerTypeATSC    },
     { "DVB_S2",  kTunerTypeDVBS2   },
     { "ASI",     kTunerTypeASI     },
+    { "OCUR",    kTunerTypeOCUR    },
     { "UNKNOWN", kTunerTypeUnknown },
     { NULL,      kTunerTypeUnknown },
 };
diff --git a/mythtv/libs/libmythtv/dtvconfparserhelpers.h b/mythtv/libs/libmythtv/dtvconfparserhelpers.h
index e6aa1d2..d89a93a 100644
--- a/mythtv/libs/libmythtv/dtvconfparserhelpers.h
+++ b/mythtv/libs/libmythtv/dtvconfparserhelpers.h
@@ -92,6 +92,7 @@ class DTVTunerType : public DTVParamHelper
     static const int kTunerTypeATSC;  // 8-VSB, 16-VSB,
                                       // QAM-16, QAM-64, QAM-256, QPSK
     static const int kTunerTypeASI;   // baseband
+    static const int kTunerTypeOCUR;  // Virtual Channel tuning of QAM-64/256
     static const int kTunerTypeUnknown;
 
     // Note: Just because some cards sold in different regions support the same
diff --git a/mythtv/libs/libmythtv/hdhrchannel.cpp b/mythtv/libs/libmythtv/hdhrchannel.cpp
index d18be4f..6836a92 100644
--- a/mythtv/libs/libmythtv/hdhrchannel.cpp
+++ b/mythtv/libs/libmythtv/hdhrchannel.cpp
@@ -92,15 +92,84 @@ bool HDHRChannel::IsOpen(void) const
       return _stream_handler;
 }
 
+/// This is used when the tuner type is kTunerTypeOCUR
 bool HDHRChannel::Tune(const QString &freqid, int /*finetune*/)
 {
     return _stream_handler->TuneVChannel(freqid);
 }
 
+// Note: For DVB-T and DVB-C we end up always using 'auto'
+// because _tuner_types will always contain both when it
+// contains one or the other. We do try to handle all the
+// cases here though since we will at some point insert
+// the DTVTunerType into the dtv_multiplex at some point
+// and then we'll have this information.
+QString get_tune_spec(const vector<DTVTunerType> &tuner_types,
+                      const DTVMultiplex &tuning)
+{
+    bool has_dvbc = false, has_dvbt = false, has_atsc = false;
+    vector<DTVTunerType>::const_iterator it = tuner_types.begin();
+    for (; it != tuner_types.end(); ++it)
+    {
+        has_dvbc |= (DTVTunerType::kTunerTypeDVBC == *it);
+        has_dvbt |= (DTVTunerType::kTunerTypeDVBT == *it);
+        has_atsc |= (DTVTunerType::kTunerTypeATSC == *it);
+    }
+
+    QString spec;
+    if (DTVModulation::kModulationQAM256 == tuning.modulation)
+        (spec = "qam256"),(has_dvbt=false);
+    else if (DTVModulation::kModulationQAM128 == tuning.modulation)
+        (spec = "qam128"),(has_dvbt=false);
+    else if (DTVModulation::kModulationQAM64 == tuning.modulation)
+        spec = "qam64";
+    else if (DTVModulation::kModulationQAM16 == tuning.modulation)
+        (spec = "qam16"),(has_dvbc=false);
+    else if (DTVModulation::kModulationDQPSK == tuning.modulation)
+        (spec = "qpsk"),(has_dvbc=false);
+    else if (DTVModulation::kModulation8VSB == tuning.modulation)
+        spec = "8vsb";
+    else
+        spec = "auto";
+
+    if (has_atsc)
+    {
+        // older firmware does no recognize "auto"
+        spec = (spec == "auto") ? "qam" : spec;
+    }
+    else if (has_dvbc && !has_dvbt)
+    {
+        const QChar b = tuning.bandwidth.toChar();
+        if ((QChar('a') == b) || (spec == "auto"))
+            spec = "auto"; // uses bandwidth from channel map
+        else if ((QChar('a') != b) && (tuning.symbolrate > 0))
+            spec = QString("a%1%2-%3")
+                .arg(b).arg(spec).arg(tuning.symbolrate/1000);
+        else
+            spec = QString("auto%1c").arg(b);
+    }
+    else if (has_dvbt && !has_dvbc)
+    {
+        const QChar b = tuning.bandwidth.toChar();
+        if ((QChar('a') == b) || spec == "auto")
+            spec = "auto"; // uses bandwidth from channel map
+        else if (QChar('a') != b)
+            spec = QString("a%1%2").arg(b).arg(spec);
+        else
+            spec = QString("auto%1t").arg(b);
+    }
+    else
+    {
+        spec = "auto";
+    }
+
+    return spec;
+}
+
 bool HDHRChannel::Tune(const DTVMultiplex &tuning, QString /*inputname*/)
 {
-    QString chan = tuning.modulation.toString() + ':' +
-        QString::number(tuning.frequency);
+    QString chan = QString("%1:%2")
+        .arg(get_tune_spec(_tuner_types, tuning)).arg(tuning.frequency);
 
     VERBOSE(VB_CHANNEL, LOC + "Tuning to " + chan);
 
diff --git a/mythtv/libs/libmythtv/hdhrstreamhandler.cpp b/mythtv/libs/libmythtv/hdhrstreamhandler.cpp
index 95462a8..9a95957 100644
--- a/mythtv/libs/libmythtv/hdhrstreamhandler.cpp
+++ b/mythtv/libs/libmythtv/hdhrstreamhandler.cpp
@@ -260,7 +260,11 @@ bool HDHRStreamHandler::Open(void)
     {
         const char *model = hdhomerun_device_get_model_str(_hdhomerun_device);
         _tuner_types.clear();
-        if (QString(model).toLower().contains("dvb"))
+        if (QString(model).toLower().contains("cablecard"))
+        {
+            _tuner_types.push_back(DTVTunerType::kTunerTypeOCUR);
+        }
+        else if (QString(model).toLower().contains("dvb"))
         {
             _tuner_types.push_back(DTVTunerType::kTunerTypeDVBT);
             _tuner_types.push_back(DTVTunerType::kTunerTypeDVBC);
@@ -386,18 +390,6 @@ QString HDHRStreamHandler::TunerSet(
         return QString::null;
     }
 
-    // Database modulation strings and HDHR use different syntax.
-    // HACK!! Caller should be doing this. (e.g. auto in HDHRChannel::Tune())
-    //
-    if (error && name == QString("channel") && val.contains("qam_"))
-    {
-        QString newval = val;
-        newval.replace("qam_256", "qam");
-        newval.replace("qam_64", "qam");
-        VERBOSE(VB_CHANNEL, "HDHRSH::TunerSet() Failed. Trying " + newval);
-        return TunerSet(name, newval, report_error_return, print_error);
-    }
-
     if (report_error_return && error)
     {
         if (print_error)