MythTV  0.26-pre
transporteditor.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  * vim: set expandtab tabstop=4 shiftwidth=4:
00004  *
00005  * Original Project
00006  *      MythTV      http://www.mythtv.org
00007  *
00008  * Author(s):
00009  *      John Pullan         <john@pullan.org>
00010  *      Taylor Jacob        <rtjacob@earthlink.net>
00011  *      Daniel Kristjansson <danielk@cuymedia.net>
00012  *
00013  * Description:
00014  *     Collection of classes to provide dvb a transport editor
00015  *
00016  * This program is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU General Public License
00018  * as published by the Free Software Foundation; either version 2
00019  * of the License, or (at your option) any later version.
00020  *
00021  * This program is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License
00027  * along with this program; if not, write to the Free Software
00028  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00029  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
00030  *
00031  */
00032 
00033 #include <vector>
00034 using namespace std;
00035 
00036 #include "transporteditor.h"
00037 #include "videosource.h"
00038 #include "cardutil.h"
00039 #include "mythcorecontext.h"
00040 #include "mythdb.h"
00041 
00042 #define LOC QString("DTVMux: ")
00043 
00044 class MultiplexID : public AutoIncrementDBSetting
00045 {
00046   public:
00047     MultiplexID() : AutoIncrementDBSetting("dtv_multiplex", "mplexid")
00048     {
00049         setVisible(false);
00050         setName("MPLEXID");
00051     }
00052 
00053   public:
00054     QString GetColumnName(void) const { return DBStorage::GetColumnName(); }
00055 };
00056 
00057 class TransportWizard : public ConfigurationWizard
00058 {
00059   public:
00060     TransportWizard(
00061         uint mplexid, uint sourceid, CardUtil::CARD_TYPES _cardtype);
00062 
00063   private:
00064     MultiplexID *mplexid;
00065 };
00066 
00067 static QString pp_modulation(QString mod)
00068 {
00069     if (mod.right(3) == "vsb")
00070         return mod.left(mod.length() - 3) + "-VSB";
00071 
00072     if (mod.left(4) == "qam_")
00073         return "QAM-" + mod.mid(4, mod.length());
00074 
00075     if (mod == "analog")
00076         return QObject::tr("Analog");
00077 
00078     return mod.toUpper();
00079 }
00080 
00081 void TransportList::fillSelections(void)
00082 {
00083 #if 0
00084     LOG(VB_GENERAL, LOG_DEBUG, QString("TransportList::fillSelections() %1")
00085                                    .arg(sourceid));
00086 #endif
00087 
00088     clearSelections();
00089     addSelection("(" + tr("New Transport") + ")", "0");
00090 
00091     setHelpText(QObject::tr(
00092                     "This section lists each transport that MythTV "
00093                     "currently knows about. The display fields are "
00094                     "video source, modulation, frequency, and when "
00095                     "relevant symbol rate, network id, and transport id."));
00096 
00097     if (!sourceid)
00098         return;
00099 
00100     MSqlQuery query(MSqlQuery::InitCon());
00101     query.prepare(
00102         "SELECT mplexid, modulation, frequency, "
00103         "       symbolrate, networkid, transportid, constellation "
00104         "FROM dtv_multiplex, videosource "
00105         "WHERE dtv_multiplex.sourceid = :SOURCEID AND "
00106         "      dtv_multiplex.sourceid = videosource.sourceid "
00107         "ORDER by networkid, transportid, frequency, mplexid");
00108     query.bindValue(":SOURCEID", sourceid);
00109 
00110     if (!query.exec() || !query.isActive())
00111     {
00112         MythDB::DBError("TransportList::fillSelections", query);
00113         return;
00114     }
00115 
00116     while (query.next())
00117     {
00118         QString rawmod = (CardUtil::OFDM == cardtype) ?
00119             query.value(6).toString() : query.value(1).toString();
00120 
00121         QString mod = pp_modulation(rawmod);
00122         while (mod.length() < 7)
00123             mod += " ";
00124 
00125         QString rate  = query.value(3).toString();
00126         rate = (rate == "0") ? "" : QString("rate %1").arg(rate);
00127 
00128         QString netid = query.value(4).toUInt() ?
00129             QString("netid %1").arg(query.value(4).toUInt(), 5) : "";
00130 
00131         QString tid = query.value(5).toUInt() ?
00132             QString("tid %1").arg(query.value(5).toUInt(), 5) : "";
00133 
00134         QString hz = (CardUtil::QPSK == cardtype) ? "kHz" : "Hz";
00135 
00136         QString type = "";
00137         if (CardUtil::OFDM == cardtype)
00138             type = "(DVB-T)";
00139         if (CardUtil::QPSK == cardtype)
00140             type = "(DVB-S)";
00141         if (CardUtil::QAM == cardtype)
00142             type = "(DVB-C)";
00143 
00144         QString txt = QString("%1 %2 %3 %4 %5 %6 %7")
00145             .arg(mod).arg(query.value(2).toString())
00146             .arg(hz).arg(rate).arg(netid).arg(tid).arg(type);
00147 
00148         addSelection(txt, query.value(0).toString());
00149     }
00150 }
00151 
00152 static CardUtil::CARD_TYPES get_cardtype(uint sourceid)
00153 {
00154     vector<uint> cardids;
00155 
00156     // Work out what card we have.. (doesn't always work well)
00157     MSqlQuery query(MSqlQuery::InitCon());
00158     query.prepare(
00159         "SELECT capturecard.cardid "
00160         "FROM cardinput, capturecard "
00161         "WHERE capturecard.cardid = cardinput.cardid AND "
00162         "      cardinput.sourceid = :SOURCEID AND "
00163         "    capturecard.hostname = :HOSTNAME");
00164     query.bindValue(":SOURCEID", sourceid);
00165     query.bindValue(":HOSTNAME", gCoreContext->GetHostName());
00166 
00167     if (!query.exec() || !query.isActive())
00168     {
00169         MythDB::DBError("TransportWizard()", query);
00170         return CardUtil::ERROR_PROBE;
00171     }
00172     else
00173     {
00174         while (query.next())
00175             cardids.push_back(query.value(0).toUInt());
00176     }
00177 
00178     if (cardids.empty())
00179     {
00180         MythPopupBox::showOkPopup(
00181             GetMythMainWindow(), 
00182             QObject::tr("Transport Editor"), 
00183             QObject::tr(
00184                 "Sorry, the Transport Editor can only be used to "
00185                 "edit transports which are connected to a card input."));
00186 
00187         return CardUtil::ERROR_PROBE;
00188     }
00189 
00190     vector<CardUtil::CARD_TYPES> cardtypes;
00191 
00192     vector<uint>::const_iterator it = cardids.begin();
00193     for (; it != cardids.end(); ++it)
00194     {
00195         CardUtil::CARD_TYPES nType = CardUtil::ERROR_PROBE;
00196         QString cardtype = CardUtil::GetRawCardType(*it);
00197         if (cardtype == "DVB")
00198             cardtype = CardUtil::ProbeSubTypeName(*it);
00199         nType = CardUtil::toCardType(cardtype);
00200 
00201         if ((CardUtil::ERROR_OPEN    == nType) ||
00202             (CardUtil::ERROR_UNKNOWN == nType) ||
00203             (CardUtil::ERROR_PROBE   == nType))
00204         {
00205             MythPopupBox::showOkPopup(
00206                 GetMythMainWindow(), 
00207                 QObject::tr("Transport Editor"), 
00208                 QObject::tr(
00209                     "Failed to probe a capture card connected to this "
00210                     "transport's video source. Please make sure the "
00211                     "backend is not running."));
00212 
00213             return CardUtil::ERROR_PROBE;
00214         }
00215 
00216         cardtypes.push_back(nType);
00217     }
00218 
00219     // This should never happen... (unless DB has changed under us)
00220     if (cardtypes.empty())
00221         return CardUtil::ERROR_PROBE;
00222 
00223     for (uint i = 1; i < cardtypes.size(); i++)
00224     {
00225         CardUtil::CARD_TYPES typeA = cardtypes[i - 1];
00226         typeA = (CardUtil::HDHOMERUN == typeA) ? CardUtil::ATSC : typeA;
00227         typeA = (CardUtil::MPEG      == typeA) ? CardUtil::V4L  : typeA;
00228 
00229         CardUtil::CARD_TYPES typeB = cardtypes[i + 0];
00230         typeB = (CardUtil::HDHOMERUN == typeB) ? CardUtil::ATSC : typeB;
00231         typeB = (CardUtil::MPEG      == typeB) ? CardUtil::V4L  : typeB;
00232 
00233         if (typeA == typeB)
00234             continue;
00235 
00236         MythPopupBox::showOkPopup(
00237             GetMythMainWindow(), 
00238             QObject::tr("Transport Editor"), 
00239             QObject::tr(
00240                 "The Video Sources to which this Transport is connected "
00241                 "are incompatible, please create seperate video sources "
00242                 "for these cards. "));
00243 
00244         return CardUtil::ERROR_PROBE;
00245     }
00246 
00247     return cardtypes[0];
00248 }
00249 
00250 void TransportList::SetSourceID(uint _sourceid)
00251 {
00252 #if 0
00253     LOG(VB_GENERAL, LOG_DEBUG, QString("TransportList::SetSourceID(%1)")
00254                                    .arg(_sourceid));
00255 #endif
00256 
00257     if (!_sourceid)
00258     {
00259         sourceid = 0;
00260     }
00261     else
00262     {
00263         cardtype = get_cardtype(_sourceid);
00264         sourceid = ((CardUtil::ERROR_OPEN    == cardtype) ||
00265                     (CardUtil::ERROR_UNKNOWN == cardtype) ||
00266                     (CardUtil::ERROR_PROBE   == cardtype)) ? 0 : _sourceid;
00267     }
00268 
00269     fillSelections();
00270 }
00271 
00272 TransportListEditor::TransportListEditor(uint sourceid) :
00273     m_videosource(new VideoSourceSelector(sourceid, QString::null, false)),
00274     m_list(new TransportList())
00275 {
00276     setLabel(tr("Multiplex Editor"));
00277 
00278     m_list->SetSourceID(m_videosource->GetSourceID());
00279 
00280     addChild(m_videosource);
00281     addChild(m_list);
00282 
00283     connect(m_videosource, SIGNAL(valueChanged(const QString&)),
00284             m_list,        SLOT(  SetSourceID( const QString&)));
00285 
00286     connect(m_list, SIGNAL(accepted(int)),            this, SLOT(Edit()));
00287     connect(m_list, SIGNAL(menuButtonPressed(int)),   this, SLOT(Menu()));
00288     connect(m_list, SIGNAL(editButtonPressed(int)),   this, SLOT(Edit()));
00289     connect(m_list, SIGNAL(deleteButtonPressed(int)), this, SLOT(Delete()));
00290 }
00291 
00292 DialogCode TransportListEditor::exec(void)
00293 {
00294     while (ConfigurationDialog::exec() == kDialogCodeAccepted);
00295 
00296     return kDialogCodeRejected;
00297 }
00298 
00299 void TransportListEditor::Edit(void)
00300 {
00301     uint sourceid = m_videosource->getValue().toUInt();
00302     CardUtil::CARD_TYPES cardtype = get_cardtype(sourceid);
00303 
00304     if ((CardUtil::ERROR_OPEN    != cardtype) &&
00305         (CardUtil::ERROR_UNKNOWN != cardtype) &&
00306         (CardUtil::ERROR_PROBE   != cardtype))
00307     {
00308         uint mplexid = m_list->getValue().toUInt();
00309         TransportWizard wiz(mplexid, sourceid, cardtype);
00310         wiz.exec();
00311         m_list->fillSelections();
00312     }
00313 }
00314 
00315 void TransportListEditor::Delete(void)
00316 {
00317     uint mplexid = m_list->getValue().toInt();
00318 
00319     DialogCode val = MythPopupBox::Show2ButtonPopup(
00320         GetMythMainWindow(), "", 
00321         tr("Are you sure you would like to delete this transport?"), 
00322         tr("Yes, delete the transport"), 
00323         tr("No, don't"), kDialogCodeButton1);
00324 
00325     if (kDialogCodeButton0 != val)
00326         return;
00327 
00328     MSqlQuery query(MSqlQuery::InitCon());
00329     query.prepare("DELETE FROM dtv_multiplex WHERE mplexid = :MPLEXID");
00330     query.bindValue(":MPLEXID", mplexid);
00331 
00332     if (!query.exec() || !query.isActive())
00333         MythDB::DBError("TransportEditor -- delete multiplex", query);
00334 
00335     query.prepare("DELETE FROM channel WHERE mplexid = :MPLEXID");
00336     query.bindValue(":MPLEXID", mplexid);
00337 
00338     if (!query.exec() || !query.isActive())
00339         MythDB::DBError("TransportEditor -- delete channels", query);
00340 
00341     m_list->fillSelections();
00342 }
00343 
00344 void TransportListEditor::Menu(void)
00345 {
00346     uint mplexid = m_list->getValue().toInt();
00347 
00348     if (!mplexid)
00349     {
00350        Edit();
00351        return;
00352     }
00353 
00354     DialogCode val = MythPopupBox::Show2ButtonPopup(
00355         GetMythMainWindow(), 
00356         "", 
00357         tr("Transport Menu"), 
00358         tr("Edit..."), 
00359         tr("Delete..."), kDialogCodeButton0);
00360 
00361     if (kDialogCodeButton0 == val)
00362         emit Edit();
00363     else if (kDialogCodeButton1 == val)
00364         emit Delete();
00365     else
00366         m_list->setFocus();
00367 }
00368 
00369 class MuxDBStorage : public SimpleDBStorage
00370 {
00371   protected:
00372     MuxDBStorage(Setting *_setting, const MultiplexID *_id, QString _name) :
00373         SimpleDBStorage(_setting, "dtv_multiplex", _name), mplexid(_id)
00374     {
00375     }
00376 
00377     virtual QString GetSetClause(MSqlBindings &bindings) const;
00378     virtual QString GetWhereClause(MSqlBindings &bindings) const;
00379 
00380     const MultiplexID *mplexid;
00381 };
00382 
00383 QString MuxDBStorage::GetWhereClause(MSqlBindings &bindings) const
00384 {
00385     QString muxTag = ":WHERE" + mplexid->GetColumnName().toUpper();
00386 
00387     bindings.insert(muxTag, mplexid->getValue());
00388 
00389     // return query
00390     return mplexid->GetColumnName() + " = " + muxTag;
00391 }
00392 
00393 QString MuxDBStorage::GetSetClause(MSqlBindings &bindings) const
00394 {
00395     QString muxTag  = ":SET" + mplexid->GetColumnName().toUpper();
00396     QString nameTag = ":SET" + GetColumnName().toUpper();
00397 
00398     bindings.insert(muxTag,  mplexid->getValue());
00399     bindings.insert(nameTag, user->GetDBValue());
00400 
00401     // return query
00402     return (mplexid->GetColumnName() + " = " + muxTag + ", " +
00403             GetColumnName()   + " = " + nameTag);
00404 }
00405 
00406 
00407 class VideoSourceID : public IntegerSetting, public MuxDBStorage
00408 {
00409   public:
00410     VideoSourceID(const MultiplexID *id, uint _sourceid) :
00411         IntegerSetting(this),
00412         MuxDBStorage(this, id, "sourceid")
00413     {
00414         setVisible(false);
00415         setValue(_sourceid);
00416     }
00417 };
00418 
00419 class DTVStandard : public ComboBoxSetting, public MuxDBStorage
00420 {
00421   public:
00422     DTVStandard(const MultiplexID *id,
00423                 bool is_dvb_country,
00424                 bool is_atsc_country) :
00425         ComboBoxSetting(this), MuxDBStorage(this, id, "sistandard")
00426     {
00427         setLabel(QObject::tr("Digital TV Standard"));
00428         setHelpText(QObject::tr(
00429                         "Guiding standard to use for making sense of the "
00430                         "data streams after they have been demodulated, "
00431                         "error corrected and demultiplexed."));
00432         if (is_dvb_country)
00433             addSelection(QObject::tr("DVB"),       "dvb");
00434 
00435         if (is_atsc_country)
00436         {
00437             addSelection(QObject::tr("ATSC"),      "atsc");
00438             addSelection(QObject::tr("OpenCable"), "opencable");
00439         }
00440 
00441         addSelection(QObject::tr("MPEG"),      "mpeg");
00442     };
00443 };
00444 
00445 class Frequency : public LineEditSetting, public MuxDBStorage
00446 {
00447   public:
00448     Frequency(const MultiplexID *id, bool in_kHz = false) :
00449         LineEditSetting(this), MuxDBStorage(this, id, "frequency")
00450     {
00451         QString hz = (in_kHz) ? "kHz" : "Hz";
00452         setLabel(QObject::tr("Frequency") + " (" + hz + ")");
00453         setHelpText(QObject::tr(
00454                         "Frequency (Option has no default).\n"
00455                         "The frequency for this channel in") + " " + hz + ".");
00456     };
00457 };
00458 
00459 class DVBSymbolRate : public ComboBoxSetting, public MuxDBStorage
00460 {
00461   public:
00462     DVBSymbolRate(const MultiplexID *id) :
00463         ComboBoxSetting(this, true), MuxDBStorage(this, id, "symbolrate")
00464     {
00465         setLabel(QObject::tr("Symbol Rate"));
00466         setHelpText(
00467             QObject::tr(
00468                 "Symbol Rate (symbols/sec).\n"
00469                 "Most DVB-S transponders transmit at 27.5 "
00470                 "million symbols per second."));
00471         addSelection("3333000");
00472         addSelection("22000000");
00473         addSelection("27500000", "27500000", true);
00474         addSelection("28000000");
00475         addSelection("28500000");
00476         addSelection("29900000");
00477     };
00478 };
00479 
00480 class SignalPolarity : public ComboBoxSetting, public MuxDBStorage
00481 {
00482   public:
00483     SignalPolarity(const MultiplexID *id) :
00484         ComboBoxSetting(this), MuxDBStorage(this, id, "polarity")
00485     {
00486         setLabel(QObject::tr("Polarity"));
00487         setHelpText(QObject::tr("Polarity (Option has no default)"));
00488         addSelection(QObject::tr("Horizontal"),     "h");
00489         addSelection(QObject::tr("Vertical"),       "v");
00490         addSelection(QObject::tr("Right Circular"), "r");
00491         addSelection(QObject::tr("Left Circular"),  "l");
00492     };
00493 };
00494 
00495 class Modulation : public ComboBoxSetting, public MuxDBStorage
00496 {
00497   public:
00498     Modulation(const MultiplexID *id,  uint nType);
00499 };
00500 
00501 Modulation::Modulation(const MultiplexID *id,  uint nType) :
00502     ComboBoxSetting(this),
00503     MuxDBStorage(this, id, (CardUtil::OFDM == nType) ?
00504                  "constellation" : "modulation")
00505 {
00506     setLabel(QObject::tr("Modulation"));
00507     setHelpText(QObject::tr("Modulation, aka Constellation"));
00508 
00509     if (CardUtil::QPSK == nType)
00510     {
00511         // no modulation options
00512         setVisible(false);
00513     }
00514     else if ((CardUtil::QAM == nType) || (CardUtil::OFDM == nType))
00515     {
00516         addSelection(QObject::tr("QAM Auto"), "auto");
00517         addSelection("QAM-16",   "qam_16");
00518         addSelection("QAM-32",   "qam_32");
00519         addSelection("QAM-64",   "qam_64");
00520         addSelection("QAM-128",  "qam_128");
00521         addSelection("QAM-256",  "qam_256");
00522 
00523         if (CardUtil::OFDM == nType)
00524         {
00525             addSelection("QPSK", "qpsk");
00526         }
00527     }
00528     else if ((CardUtil::ATSC      == nType) ||
00529              (CardUtil::HDHOMERUN == nType))
00530     {
00531         addSelection("8-VSB",    "8vsb");
00532         addSelection("QAM-64",   "qam_64");
00533         addSelection("QAM-256",  "qam_256");
00534     }
00535     else
00536     {
00537         addSelection(QObject::tr("Analog"), "analog");
00538         setVisible(false);
00539     }
00540 };
00541 
00542 class DVBInversion : public ComboBoxSetting, public MuxDBStorage
00543 {
00544   public:
00545     DVBInversion(const MultiplexID *id) :
00546         ComboBoxSetting(this), MuxDBStorage(this, id, "inversion")
00547     {
00548         setLabel(QObject::tr("Inversion"));
00549         setHelpText(QObject::tr("Inversion (Default: Auto):\n"
00550                     "Most cards can autodetect this now, so leave it at Auto"
00551                     " unless it won't work."));
00552         addSelection(QObject::tr("Auto"), "a");
00553         addSelection(QObject::tr("On"), "1");
00554         addSelection(QObject::tr("Off"), "0");
00555     };
00556 };
00557 
00558 class DVBTBandwidth : public ComboBoxSetting, public MuxDBStorage
00559 {
00560   public:
00561     DVBTBandwidth(const MultiplexID *id) :
00562         ComboBoxSetting(this), MuxDBStorage(this, id, "bandwidth")
00563     {
00564         setLabel(QObject::tr("Bandwidth"));
00565         setHelpText(QObject::tr("Bandwidth (Default: Auto)"));
00566         addSelection(QObject::tr("Auto"), "a");
00567         addSelection(QObject::tr("6 MHz"), "6");
00568         addSelection(QObject::tr("7 MHz"), "7");
00569         addSelection(QObject::tr("8 MHz"), "8");
00570     };
00571 };
00572 
00573 class DVBForwardErrorCorrectionSelector : public ComboBoxSetting
00574 {
00575   public:
00576     DVBForwardErrorCorrectionSelector(Storage *_storage) :
00577         ComboBoxSetting(_storage)
00578     {
00579         addSelection(QObject::tr("Auto"), "auto");
00580         addSelection(QObject::tr("None"), "none");
00581         addSelection("1/2");
00582         addSelection("2/3");
00583         addSelection("3/4");
00584         addSelection("4/5");
00585         addSelection("5/6");
00586         addSelection("6/7");
00587         addSelection("7/8");
00588         addSelection("8/9");
00589     };
00590 };
00591 
00592 class DVBForwardErrorCorrection :
00593     public DVBForwardErrorCorrectionSelector, public MuxDBStorage
00594 {
00595   public:
00596     DVBForwardErrorCorrection(const MultiplexID *id) :
00597         DVBForwardErrorCorrectionSelector(this),
00598         MuxDBStorage(this, id, "fec")
00599     {
00600         setLabel(QObject::tr("FEC"));
00601         setHelpText(QObject::tr("Forward Error Correction (Default: Auto)"));
00602     };
00603 };
00604 
00605 class DVBTCoderateLP :
00606     public DVBForwardErrorCorrectionSelector, public MuxDBStorage
00607 {
00608   public:
00609     DVBTCoderateLP(const MultiplexID *id) :
00610         DVBForwardErrorCorrectionSelector(this),
00611         MuxDBStorage(this, id, "lp_code_rate")
00612     {
00613         setLabel(QObject::tr("LP Coderate"));
00614         setHelpText(QObject::tr("Low Priority Code Rate (Default: Auto)"));
00615     };
00616 };
00617 
00618 class DVBTCoderateHP :
00619     public DVBForwardErrorCorrectionSelector, public MuxDBStorage
00620 {
00621   public:
00622     DVBTCoderateHP(const MultiplexID *id) :
00623         DVBForwardErrorCorrectionSelector(this),
00624         MuxDBStorage(this, id, "hp_code_rate")
00625     {
00626         setLabel(QObject::tr("HP Coderate"));
00627         setHelpText(QObject::tr("High Priority Code Rate (Default: Auto)"));
00628     };
00629 };
00630 
00631 class DVBTGuardInterval : public ComboBoxSetting, public MuxDBStorage
00632 {
00633   public:
00634     DVBTGuardInterval(const MultiplexID *id) :
00635         ComboBoxSetting(this), MuxDBStorage(this, id, "guard_interval")
00636     {
00637         setLabel(QObject::tr("Guard Interval"));
00638         setHelpText(QObject::tr("Guard Interval (Default: Auto)"));
00639         addSelection(QObject::tr("Auto"), "auto");
00640         addSelection("1/4");
00641         addSelection("1/8");
00642         addSelection("1/16");
00643         addSelection("1/32");
00644     };
00645 };
00646 
00647 class DVBTTransmissionMode : public ComboBoxSetting, public MuxDBStorage
00648 {
00649   public:
00650     DVBTTransmissionMode(const MultiplexID *id) :
00651         ComboBoxSetting(this), MuxDBStorage(this, id, "transmission_mode")
00652     {
00653         setLabel(QObject::tr("Trans. Mode"));
00654         setHelpText(QObject::tr("Transmission Mode (Default: Auto)"));
00655         addSelection(QObject::tr("Auto"), "a");
00656         addSelection("2K", "2");
00657         addSelection("8K", "8");
00658     };
00659 };
00660 
00661 class DVBTHierarchy : public ComboBoxSetting, public MuxDBStorage
00662 {
00663   public:
00664     DVBTHierarchy(const MultiplexID *id) :
00665         ComboBoxSetting(this), MuxDBStorage(this, id, "hierarchy")
00666     {
00667         setLabel(QObject::tr("Hierarchy"));
00668         setHelpText(QObject::tr("Hierarchy (Default: Auto)"));
00669         addSelection(QObject::tr("Auto"), "a");
00670         addSelection(QObject::tr("None"), "n");
00671         addSelection("1");
00672         addSelection("2");
00673         addSelection("4");
00674     }
00675 };
00676 
00677 
00678 class TransportPage : public HorizontalConfigurationGroup
00679 {
00680   public:
00681     TransportPage(const MultiplexID *id, uint nType);
00682 
00683   protected:
00684     const MultiplexID *id;
00685 };
00686 
00687 TransportPage::TransportPage(const MultiplexID *_id, uint nType) :
00688     HorizontalConfigurationGroup(false, true, false, false), id(_id)
00689 {
00690     setLabel(QObject::tr("Transport Options"));
00691     setUseLabel(false);
00692 
00693     VerticalConfigurationGroup *left = NULL, *right = NULL;
00694 
00695     left = new VerticalConfigurationGroup(false, true, false, false);
00696 
00697     if (CardUtil::OFDM == nType)
00698     {
00699         left->addChild(new DTVStandard(id, true, false));
00700         left->addChild(new Frequency(id));
00701         left->addChild(new DVBTBandwidth(id));
00702         left->addChild(new DVBInversion(id));
00703         left->addChild(new Modulation(id, nType));
00704 
00705         right = new VerticalConfigurationGroup(false, true, false, false);
00706         right->addChild(new DVBTCoderateLP(id));
00707         right->addChild(new DVBTCoderateHP(id));
00708         right->addChild(new DVBTTransmissionMode(id));
00709         right->addChild(new DVBTGuardInterval(id));
00710         right->addChild(new DVBTHierarchy(id));
00711     }
00712     else if (CardUtil::QPSK == nType)
00713     {
00714         left->addChild(new DTVStandard(id, true, false));
00715         left->addChild(new Frequency(id, true));
00716         left->addChild(new DVBSymbolRate(id));
00717 
00718         right = new VerticalConfigurationGroup(false, true, false, false);
00719         right->addChild(new DVBInversion(id));
00720         right->addChild(new DVBForwardErrorCorrection(id));
00721         right->addChild(new SignalPolarity(id));
00722     }
00723     else if (CardUtil::QAM == nType)
00724     {
00725         left->addChild(new DTVStandard(id, true, false));
00726         left->addChild(new Frequency(id));
00727         left->addChild(new DVBSymbolRate(id));
00728 
00729         right = new VerticalConfigurationGroup(false, true, false, false);
00730         right->addChild(new Modulation(id, nType));
00731         right->addChild(new DVBInversion(id));
00732         right->addChild(new DVBForwardErrorCorrection(id));
00733     }
00734     else if (CardUtil::ATSC      == nType ||
00735              CardUtil::HDHOMERUN == nType)
00736     {
00737         left->addChild(new DTVStandard(id, false, true));
00738         left->addChild(new Frequency(id));
00739         left->addChild(new Modulation(id, nType));
00740     }
00741     else if ((CardUtil::FIREWIRE == nType) ||
00742              (CardUtil::FREEBOX  == nType))
00743     {
00744         left->addChild(new DTVStandard(id, true, true));
00745     }
00746     else if ((CardUtil::V4L  == nType) ||
00747              (CardUtil::MPEG == nType))
00748     {
00749         left->addChild(new Frequency(id));
00750         left->addChild(new Modulation(id, nType));
00751     }
00752 
00753     addChild(left);
00754 
00755     if (right)
00756         addChild(right);
00757 };
00758 
00759 TransportWizard::TransportWizard(
00760     uint _mplexid, uint _sourceid, CardUtil::CARD_TYPES _cardtype) :
00761     mplexid(new MultiplexID())
00762 {
00763     setLabel(QObject::tr("DVB Transport"));
00764 
00765     // Must be first.
00766     mplexid->setValue(_mplexid);
00767     addChild(mplexid);
00768     addChild(new VideoSourceID(mplexid, _sourceid));
00769     addChild(new TransportPage(mplexid, _cardtype));
00770 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends