commit e0e227d99a9d9cfc6ddebbc152baae719ca37cc1
Author: Mark Spieth <mspieth@digivation.com.au>
Date:   Thu Dec 22 01:03:50 2011 +1100

    opentv channel and extended eit support

diff --git a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
index de955f6e9a..363bed9fde 100644
--- a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
+++ b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
@@ -118,6 +118,7 @@ class ScannedChannelInfo
     nit_vec_t               m_nits;
     sdt_map_t               m_sdts;
     bat_vec_t               m_bats;
+    QMap<uint64_t, uint64_t> opentv_channels;
 };
 
 /** \class ChannelScanSM
@@ -158,6 +159,9 @@ ChannelScanSM::ChannelScanSM(ScanMonitor *_scan_monitor,
       m_channelTimeout(channel_timeout),
       m_inputName(std::move(_inputname)),
       m_testDecryption(test_decryption),
+      scanOpenTVBouquet(0),
+      scanOpenTVRegion(0),
+      scanOpenTVRegionMask(0),
       // Misc
       m_analogSignalHandler(new AnalogSignalHandler(this))
 {
@@ -251,6 +255,16 @@ void ChannelScanSM::SetAnalog(bool is_analog)
         m_signalMonitor->AddListener(m_analogSignalHandler);
 }
 
+void ChannelScanSM::SetOpenTV(uint openTVBouquet, uint openTVRegion)
+{
+    scanOpenTVBouquet = openTVBouquet;
+    scanOpenTVRegion = openTVRegion;
+    if (openTVRegion)
+        scanOpenTVRegionMask = 1 << openTVRegion;
+    else
+        scanOpenTVRegionMask = (uint)-1;
+}
+
 void ChannelScanSM::HandleAllGood(void)
 {
     QMutexLocker locker(&m_lock);
@@ -507,6 +521,13 @@ void ChannelScanSM::HandleBAT(const BouquetAssociationTable *bat)
 
     m_otherTableTime = m_timer.elapsed() + m_otherTableTimeout;
 
+    if (0 != bat->BouquetDescriptorsLength())
+    {
+        vector<const unsigned char*> desc =
+            MPEGDescriptor::Parse(bat->BouquetDescriptors(),
+                                  bat->BouquetDescriptorsLength());
+    }
+
     for (uint i = 0; i < bat->TransportStreamCount(); ++i)
     {
         uint tsid = bat->TSID(i);
@@ -546,6 +567,44 @@ void ChannelScanSM::HandleBAT(const BouquetAssociationTable *bat)
                    m_defAuthorities[index] = authority.DefaultAuthority();
             }
         }
+
+        if (scanOpenTVBouquet > 0)
+        {
+            const unsigned char *otv_chan_list =
+                MPEGDescriptor::Find(parsed, PrivateDescriptorID::opentv_channel_list);
+            if (otv_chan_list)
+            {
+                OpenTVChannelListDescriptor opentvChannelList(otv_chan_list);
+
+                uint64_t regionMask = (uint64_t)-1;
+                if (opentvChannelList.RegionID() > 0 && opentvChannelList.RegionID() < 32)
+                    regionMask = ((uint64_t)1) << opentvChannelList.RegionID();
+
+                for (uint j = 0; j < opentvChannelList.ChannelCount(); j++)
+                {
+                    uint64_t index = ((uint64_t)netid << 32) |
+                        bat->BouquetID() << 16 |
+                        opentvChannelList.ServiceID(j);
+                    if (!m_currentInfo)
+                        m_currentInfo = new ScannedChannelInfo();
+                    if (m_currentInfo->opentv_channels.contains(index))
+                    {
+                        m_currentInfo->opentv_channels[index] |= regionMask << 32; 
+                    }
+                    else
+                    {
+                        m_currentInfo->opentv_channels[index] = 
+                            regionMask << 32 |
+                            (opentvChannelList.ChannelID(j) << 16);
+                    }
+                    if (regionMask & scanOpenTVRegionMask)
+                    {
+                        m_currentInfo->opentv_channels[index] |= 
+                            opentvChannelList.ChannelNumber(j);
+                    }
+                }
+            }
+        }
     }
     UpdateChannelInfo(true);
 }
@@ -1652,6 +1711,23 @@ ChannelScanSM::GetChannelList(transport_scan_items_it_t trans_info,
             if (it != ukChanNums.end())
             {
                 info.m_chanNum = QString::number(*it);
+                continue;
+            }
+
+            // See if there is an openTV LCN
+            if (scanOpenTVBouquet > 0)
+            {
+                QMap<uint64_t, uint64_t>::const_iterator oit = scan_info->opentv_channels.find(
+                        ((qlonglong)info.m_origNetId<<32) | scanOpenTVBouquet << 16 | info.m_serviceId);
+                if (oit != scan_info->opentv_channels.end())
+                {
+                    uint chanNum = (*oit) & 0xffff;
+                    if (chanNum > 0)
+                    {
+                        info.m_chanNum = chanNum;
+                        continue;
+                    }
+                }
             }
         }
 
diff --git a/mythtv/libs/libmythtv/channelscan/channelscan_sm.h b/mythtv/libs/libmythtv/channelscan/channelscan_sm.h
index 46613c92b0..2a4908792a 100644
--- a/mythtv/libs/libmythtv/channelscan/channelscan_sm.h
+++ b/mythtv/libs/libmythtv/channelscan/channelscan_sm.h
@@ -121,6 +121,7 @@ class ChannelScanSM : public MPEGStreamListener,
     void SetChannelTimeout(uint val)   { m_channelTimeout = val; }
     void SetScanDTVTunerType(DTVTunerType t) { m_scanDTVTunerType = t; }
     void SetScanDTVTunerType(int t) { m_scanDTVTunerType = DTVTunerType(t); }
+    void SetOpenTV(uint openTVBouquet, uint openTVRegion);
 
     uint GetSignalTimeout(void)  const { return m_signalTimeout; }
     uint GetChannelTimeout(void) const { return m_channelTimeout; }
@@ -225,6 +226,10 @@ class ChannelScanSM : public MPEGStreamListener,
     // Optional info
     DTVTunerType      m_scanDTVTunerType  {DTVTunerType::kTunerTypeUnknown};
 
+    uint              scanOpenTVBouquet;
+    uint              scanOpenTVRegion;
+    uint              scanOpenTVRegionMask;
+
     /// The big lock
     mutable QMutex    m_lock;
 
diff --git a/mythtv/libs/libmythtv/channelscan/channelscanmiscsettings.h b/mythtv/libs/libmythtv/channelscan/channelscanmiscsettings.h
index 9f8ed5fa3f..0c36530987 100644
--- a/mythtv/libs/libmythtv/channelscan/channelscanmiscsettings.h
+++ b/mythtv/libs/libmythtv/channelscan/channelscanmiscsettings.h
@@ -443,6 +443,28 @@ class ScanRollOff: public TransMythUIComboBoxSetting
     };
 };
 
+class OpenTVBouquet: public TransTextEditSetting
+{
+  public:
+    OpenTVBouquet()
+    {
+        setLabel(QObject::tr("OpenTV Bouquet"));
+        setHelpText(QObject::tr("OpenTV Bouquet (Default: 0 = dont use)\n"
+                                "OpenTV Bouquet for channel numbers."));
+    };
+};
+
+class OpenTVRegion: public TransTextEditSetting
+{
+  public:
+    OpenTVRegion()
+    {
+        setLabel(QObject::tr("OpenTV Region"));
+        setHelpText(QObject::tr("OpenTV Region (Default: 0 = use any)\n"
+                                "OpenTV Region for preferred channel numbers when duplicates exist."));
+    };
+};
+
 class PaneError : public GroupSetting
 {
   public:
diff --git a/mythtv/libs/libmythtv/channelscan/channelscanner.cpp b/mythtv/libs/libmythtv/channelscan/channelscanner.cpp
index f20db6b584..7aa781685c 100644
--- a/mythtv/libs/libmythtv/channelscan/channelscanner.cpp
+++ b/mythtv/libs/libmythtv/channelscan/channelscanner.cpp
@@ -122,6 +122,8 @@ void ChannelScanner::Scan(
     bool           do_full_channel_search,
     bool           do_add_full_ts,
     ServiceRequirements service_requirements,
+    uint           opentvBouquet,
+    uint           opentvRegion,
     // stuff needed for particular scans
     uint           mplexid /* TransportScan */,
     const QMap<QString,QString> &startChan /* NITAddScan */,
@@ -155,6 +157,9 @@ void ChannelScanner::Scan(
 
     bool ok = false;
 
+    if (opentvBouquet)
+        m_sigmonScanner->SetOpenTV(opentvBouquet, opentvRegion);
+
     if ((ScanTypeSetting::FullScan_ATSC   == scantype) ||
         (ScanTypeSetting::FullScan_DVBC   == scantype) ||
         (ScanTypeSetting::FullScan_DVBT   == scantype) ||
diff --git a/mythtv/libs/libmythtv/channelscan/channelscanner.h b/mythtv/libs/libmythtv/channelscan/channelscanner.h
index 66e0f9b7d9..ffab7fc6d4 100644
--- a/mythtv/libs/libmythtv/channelscan/channelscanner.h
+++ b/mythtv/libs/libmythtv/channelscan/channelscanner.h
@@ -81,6 +81,8 @@ class MTV_PUBLIC ChannelScanner
               bool           do_full_channel_search,
               bool           do_add_full_ts,
               ServiceRequirements service_requirements,
+              uint           opentvBouquet,
+              uint           opentvRegion,
               // stuff needed for particular scans
               uint           mplexid,
               const QMap<QString,QString> &startChan,
diff --git a/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp b/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp
index 5e4a76e4a3..4af8114c44 100644
--- a/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp
+++ b/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp
@@ -37,6 +37,8 @@ void ScanWizard::SetupConfig(
     m_fullSearch = new FullChannelSearch();
     m_addFullTS = new AddFullTS();
     m_trustEncSI = new TrustEncSISetting();
+    opentvBouquet = new OpenTVBouquet();
+    opentvRegion = new OpenTVRegion();
 
     setLabel(tr("Channel Scan"));
 
@@ -47,6 +49,8 @@ void ScanWizard::SetupConfig(
     addChild(m_fullSearch);
     addChild(m_addFullTS);
     addChild(m_trustEncSI);
+    addChild(opentvBouquet);
+    addChild(opentvRegion);
 
     addChild(m_videoSource);
     addChild(m_input);
@@ -110,6 +114,16 @@ bool ScanWizard::DoTestDecryption(void) const
     return m_trustEncSI->boolValue();
 }
 
+uint ScanWizard::GetOpenTVBouquet(void) const
+{
+    return opentvBouquet->getValue().toUInt(0);
+}
+
+uint ScanWizard::GetOpenTVRegion(void) const
+{
+    return opentvRegion->getValue().toUInt(0);
+}
+
 void ScanWizard::SetPaneDefaults(const QString &cardid_inputname)
 {
     const int sourceid = m_videoSource->getValue().toInt();
diff --git a/mythtv/libs/libmythtv/channelscan/scanwizardconfig.h b/mythtv/libs/libmythtv/channelscan/scanwizardconfig.h
index 0b4d968d63..5a208ce221 100644
--- a/mythtv/libs/libmythtv/channelscan/scanwizardconfig.h
+++ b/mythtv/libs/libmythtv/channelscan/scanwizardconfig.h
@@ -49,6 +49,8 @@ class CompleteChannelsOnly;
 class FullChannelSearch;
 class AddFullTS;
 class TrustEncSISetting;
+class OpenTVBouquet;
+class OpenTVRegion;
 
 class PaneAll;
 class PaneATSC;
@@ -151,5 +153,4 @@ class ScanOptionalConfig : public GroupSetting
     PaneDVBUtilsImport     *m_paneDVBUtilsImport       {nullptr};
     PaneExistingScanImport *m_paneExistingScanImport   {nullptr};
 };
-
 #endif // _SCAN_WIZARD_CONFIG_H_
diff --git a/mythtv/libs/libmythtv/mpeg/dvbdescriptors.cpp b/mythtv/libs/libmythtv/mpeg/dvbdescriptors.cpp
index 23217ff699..eb2aa7c839 100644
--- a/mythtv/libs/libmythtv/mpeg/dvbdescriptors.cpp
+++ b/mythtv/libs/libmythtv/mpeg/dvbdescriptors.cpp
@@ -682,6 +682,17 @@ QString FreesatCallsignDescriptor::toString(void) const
     return ret;
 }
 
+QString OpenTVChannelListDescriptor::toString() const
+{
+    QString ret = QString("OpenTVChannelListDescriptor region: %1 sid->chan_num(id): ").arg(RegionID());
+    for (uint i = 0; i < ChannelCount(); i++)
+    {
+        ret += QString("%1->%2(%3)").arg(ServiceID(i)).arg(ChannelNumber(i)).arg(ChannelID(i));
+        ret += (i+1<ChannelCount()) ? ", " : "";
+    }
+    return ret;
+}
+
 QString CAIdentifierDescriptor::toString(void) const
 {
     QString ret = QString("CAIdentifierDescriptor ");
diff --git a/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h b/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h
index 57d2ae0db7..9b7c9b3902 100644
--- a/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h
+++ b/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h
@@ -2327,6 +2327,38 @@ class BSkyBLCNDescriptor : public MPEGDescriptor
     QString toString(void) const override; // MPEGDescriptor
 };
 
+class OpenTVChannelListDescriptor : public MPEGDescriptor
+{
+  public:
+    OpenTVChannelListDescriptor(const unsigned char *data, int len = 300) :
+        MPEGDescriptor(data, len, PrivateDescriptorID::opentv_channel_list) { }
+    //       Name             bits  loc  expected value
+    // descriptor_tag           8   0.0       0xB1
+    // descriptor_length        8   1.0
+
+    uint ChannelCount(void) const { return (DescriptorLength() - 2)/9; }
+
+    uint RegionID() const
+        { return (m_data[2] << 8) | m_data[3]; }
+
+    uint ServiceID(uint i) const
+        { return (m_data[4 + 0 + (i*9)] << 8) | m_data[4 + 1 + (i*9)]; }
+
+    uint ChannelType(uint i) const 
+        { return m_data[4 + 2 + (i*9)]; }
+
+    uint ChannelID(uint i) const
+        { return ((m_data[4 + 3 + (i*9)] << 8) | m_data[4 + 5 + (i*9)]); }
+
+    uint ChannelNumber(uint i) const
+        { return ((m_data[4 + 5 + (i*9)] << 8) | m_data[4 + 6 + (i*9)]); }
+
+    uint Flags(uint i) const
+        { return ((m_data[4 + 7 + (i*9)] << 8) | m_data[4 + 8 + (i*9)]) & 0xf; }
+
+    QString toString(void) const;
+};
+
 // ETSI TS 102 323 (TV Anytime)
 class DVBContentIdentifierDescriptor : public MPEGDescriptor
 {
diff --git a/mythtv/libs/libmythtv/mpeg/dvbstreamdata.cpp b/mythtv/libs/libmythtv/mpeg/dvbstreamdata.cpp
index 3d8fb28a14..a57c7bbc56 100644
--- a/mythtv/libs/libmythtv/mpeg/dvbstreamdata.cpp
+++ b/mythtv/libs/libmythtv/mpeg/dvbstreamdata.cpp
@@ -473,6 +473,24 @@ bool DVBStreamData::GetEITPIDChanges(const uint_vec_t &cur_pids,
             add_pids.push_back(DVB_BVLONG_EIT_PID);
         }
 
+        // opentv eit pids
+        if (m_dvbEitDishnetLong)
+        {
+            uint pid;
+            for(pid=OTV_EIT_TIT_PID_START; pid <= OTV_EIT_TIT_PID_END; pid++)
+            {
+                if (find(cur_pids.begin(), cur_pids.end(), 
+                         pid) == cur_pids.end())
+                    add_pids.push_back(pid);
+            }
+            for(pid=OTV_EIT_SUP_PID_START; pid <= OTV_EIT_SUP_PID_END; pid++)
+            {
+                if (find(cur_pids.begin(), cur_pids.end(), 
+                         pid) == cur_pids.end())
+                    add_pids.push_back(pid);
+            }
+        }
+
         if (m_desiredNetId == PREMIERE_ONID &&
             find(cur_pids.begin(), cur_pids.end(),
                  (uint) PREMIERE_EIT_DIREKT_PID) == cur_pids.end())
@@ -523,6 +541,24 @@ bool DVBStreamData::GetEITPIDChanges(const uint_vec_t &cur_pids,
             del_pids.push_back(DVB_BVLONG_EIT_PID);
         }
 
+        // opentv eit pids
+        if (m_dvbEitDishnetLong)
+        {
+            uint pid;
+            for(pid=OTV_EIT_TIT_PID_START; pid <= OTV_EIT_TIT_PID_END; pid++)
+            {
+                if (find(cur_pids.begin(), cur_pids.end(), 
+                         pid) != cur_pids.end())
+                    del_pids.push_back(pid);
+            }
+            for(pid=OTV_EIT_SUP_PID_START; pid <= OTV_EIT_SUP_PID_END; pid++)
+            {
+                if (find(cur_pids.begin(), cur_pids.end(), 
+                         pid) != cur_pids.end())
+                    del_pids.push_back(pid);
+            }
+        }
+
         if (m_desiredNetId == PREMIERE_ONID &&
             find(cur_pids.begin(), cur_pids.end(),
                  (uint) PREMIERE_EIT_DIREKT_PID) != cur_pids.end())
diff --git a/mythtv/libs/libmythtv/mpeg/mpegdescriptors.cpp b/mythtv/libs/libmythtv/mpeg/mpegdescriptors.cpp
index db8cb7fc93..dae8e1a2b5 100644
--- a/mythtv/libs/libmythtv/mpeg/mpegdescriptors.cpp
+++ b/mythtv/libs/libmythtv/mpeg/mpegdescriptors.cpp
@@ -375,6 +375,9 @@ QString MPEGDescriptor::DescriptorTagString(void) const
         case PrivateDescriptorID::premiere_content_transmission: /* 0xF2 */
             comma_list_append(str, "Possibly Premiere DE Content Transmission");
             break;
+        case PrivateDescriptorID::opentv_channel_list: /* 0xB1 */
+            comma_list_append(str, "Possibly DVB OpenTV Channel List");
+            break;
     }
 
     if (str.isEmpty())
@@ -561,6 +564,8 @@ QString MPEGDescriptor::toStringPD(uint priv_dsid) const
         SET_STRING(ComponentNameDescriptor);
     }
     // POSSIBLY UNSAFE ! -- end
+    else if (PrivateDescriptorID::opentv_channel_list == DescriptorTag())
+        SET_STRING(OpenTVChannelListDescriptor);
     else
     {
         str = QString("%1 Descriptor (0x%2) length(%3). Dumping\n")
diff --git a/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h b/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h
index f3ad43a65f..dd64a2f611 100644
--- a/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h
+++ b/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h
@@ -218,6 +218,17 @@ class PrivateDescriptorID
         premiere_content_order         = 0xF0,
         premiere_parental_information  = 0xF1,
         premiere_content_transmission  = 0xF2,
+
+        // Private -- opentv
+        opentv_titles_1                  = 0xA0, /* implemented */
+        opentv_titles_2                  = 0xA1, /* implemented */
+        opentv_titles_3                  = 0xA2, /* implemented */
+        opentv_titles_4                  = 0xA3, /* implemented */
+        opentv_summaries_1               = 0xA8, /* implemented */
+        opentv_summaries_2               = 0xA9, /* implemented */
+        opentv_summaries_3               = 0xAA, /* implemented */
+        opentv_summaries_4               = 0xAB, /* implemented */
+        opentv_channel_list              = 0xB1, /* partial */
     };
 };
 
diff --git a/mythtv/libs/libmythtv/mpeg/mpegtables.h b/mythtv/libs/libmythtv/mpeg/mpegtables.h
index 045fd475e9..39c44e8d1d 100644
--- a/mythtv/libs/libmythtv/mpeg/mpegtables.h
+++ b/mythtv/libs/libmythtv/mpeg/mpegtables.h
@@ -234,6 +234,12 @@ enum
     /// The all-ones PID value 0x1FFF indicates a Null TS Packet
     /// introduced to maintain a constant bit rate of a TS Multiplex.
     MPEG_NULL_PID      = 0x1fff,
+
+    // OpenTV EIT PIDs
+    OTV_EIT_TIT_PID_START  = 0x30,
+    OTV_EIT_TIT_PID_END    = 0x37,
+    OTV_EIT_SUP_PID_START  = 0x40,
+    OTV_EIT_SUP_PID_END    = 0x47,
 };
 
 /** \class TableID
@@ -364,6 +370,12 @@ class MTV_PUBLIC TableID
         SRVLOC   = 0xA1,
         TSS      = 0xA2,
         CMPNAME  = 0xA3,
+
+        // opentv
+        OTV_EIT_TITbeg  = 0xA0, // always on pids config (0x30-0x37)
+        OTV_EIT_TITend  = 0xA3, // always on pids config (0x30-0x37)
+        OTV_EIT_SUMbeg  = 0xA8, // always on pids config (0x40-0x47)
+        OTV_EIT_SUMend  = 0xAB, // always on pids config (0x40-0x47)
     };
 };
 
diff --git a/mythtv/libs/libmythtv/scanwizard.cpp b/mythtv/libs/libmythtv/scanwizard.cpp
index 6b6f18478d..d200ef9f11 100644
--- a/mythtv/libs/libmythtv/scanwizard.cpp
+++ b/mythtv/libs/libmythtv/scanwizard.cpp
@@ -186,6 +186,8 @@ void ScanWizard::Scan()
             DoChannelNumbersOnly(),   DoCompleteChannelsOnly(),
             DoFullChannelSearch(),
             DoAddFullTS(),            GetServiceRequirements(),
+            GetOpenTVBouquet(),       GetOpenTVRegion(),
+
             // stuff needed for particular scans
             GetMultiplex(),         start_chan,
             GetFrequencyStandard(), GetModulation(),
diff --git a/mythtv/libs/libmythtv/scanwizard.h b/mythtv/libs/libmythtv/scanwizard.h
index 1d9edab85e..4d7637890e 100644
--- a/mythtv/libs/libmythtv/scanwizard.h
+++ b/mythtv/libs/libmythtv/scanwizard.h
@@ -94,6 +94,8 @@ class MTV_PUBLIC ScanWizard : public GroupSetting
     bool    DoFullChannelSearch(void)    const;
     bool    DoAddFullTS(void)            const;
     bool    DoTestDecryption(void)       const;
+    uint    GetOpenTVBouquet(void) const;
+    uint    GetOpenTVRegion(void) const;
 
   protected:
     VideoSourceSelector  *m_videoSource   {nullptr};
@@ -107,6 +109,8 @@ class MTV_PUBLIC ScanWizard : public GroupSetting
     FullChannelSearch    *m_fullSearch    {nullptr};
     AddFullTS            *m_addFullTS     {nullptr};
     TrustEncSISetting    *m_trustEncSI    {nullptr};
+    OpenTVBouquet       *opentvBouquet;
+    OpenTVRegion        *opentvRegion;
 // End of members moved from ScanWizardConfig
 };
 
diff --git a/mythtv/programs/mythtv-setup/main.cpp b/mythtv/programs/mythtv-setup/main.cpp
index 8b2fc8ccab..5a8e4a4fd9 100644
--- a/mythtv/programs/mythtv-setup/main.cpp
+++ b/mythtv/programs/mythtv-setup/main.cpp
@@ -258,6 +258,8 @@ int main(int argc, char *argv[])
     bool    scanCompleteOnly = false;
     bool    scanFullChannelSearch = false;
     bool    addFullTS = false;
+    uint    scanOpenTVBouquet = 0;
+    uint    scanOpenTVRegion = 0;
     ServiceRequirements scanServiceRequirements = kRequireAV;
     uint    scanCardId = 0;
     QString frequencyStandard = "atsc";
@@ -351,6 +353,10 @@ int main(int argc, char *argv[])
         scanFullChannelSearch = true;
     if (cmdline.toBool("addfullts"))
         addFullTS = true;
+    if (cmdline.toBool("opentvbouquet"))
+        scanOpenTVBouquet = cmdline.toUInt("opentvbouquet");
+    if (cmdline.toBool("opentvregion"))
+        scanOpenTVRegion = cmdline.toUInt("opentvregion");
     if (cmdline.toBool("servicetype"))
     {
         scanServiceRequirements = kRequireNothing;
@@ -509,6 +515,8 @@ int main(int argc, char *argv[])
                          scanFullChannelSearch,
                          addFullTS,
                          scanServiceRequirements,
+                         scanOpenTVBouquet,
+                         scanOpenTVRegion,
                          // stuff needed for particular scans
                          /* mplexid   */ 0,
                          startChan, frequencyStandard, modulation, region);
