MythTV  0.26-pre
cetonchannel.cpp
Go to the documentation of this file.
00001 
00008 // MythTV includes
00009 #include "cetonstreamhandler.h"
00010 #include "cetonchannel.h"
00011 #include "videosource.h"
00012 #include "mythlogging.h"
00013 #include "channelutil.h"
00014 #include "mythdbcon.h"
00015 
00016 #define LOC QString("CetonChan(%1): ").arg(GetDevice())
00017 
00018 CetonChannel::CetonChannel(TVRec *parent, const QString &device) :
00019     DTVChannel(parent), _device_id(device), _stream_handler(NULL)
00020 {
00021 }
00022 
00023 CetonChannel::~CetonChannel(void)
00024 {
00025     Close();
00026 }
00027 
00028 bool CetonChannel::Open(void)
00029 {
00030     LOG(VB_CHANNEL, LOG_INFO, LOC + "Opening Ceton channel");
00031 
00032     if (IsOpen())
00033         return true;
00034 
00035     _stream_handler = CetonStreamHandler::Get(_device_id);
00036 
00037     tunerType = DTVTunerType::kTunerTypeATSC;
00038     _tuner_types.push_back(tunerType);
00039 
00040     if (!InitializeInputs())
00041     {
00042         Close();
00043         return false;
00044     }
00045 
00046     return _stream_handler->IsConnected();
00047 }
00048 
00049 void CetonChannel::Close(void)
00050 {
00051     LOG(VB_CHANNEL, LOG_INFO, LOC + "Closing Ceton channel");
00052 
00053     if (!IsOpen())
00054         return; // this caller didn't have it open in the first place..
00055 
00056     CetonStreamHandler::Return(_stream_handler);
00057 }
00058 
00059 bool CetonChannel::EnterPowerSavingMode(void)
00060 {
00061     if (IsOpen())
00062         return _stream_handler->EnterPowerSavingMode();
00063     else
00064         return true;
00065 }
00066 
00067 bool CetonChannel::IsOpen(void) const
00068 {
00069       return _stream_handler;
00070 }
00071 
00073 bool CetonChannel::Tune(const QString &freqid, int /*finetune*/)
00074 {
00075     return _stream_handler->TuneVChannel(freqid);
00076 }
00077 
00078 static QString format_modulation(const DTVMultiplex &tuning)
00079 {
00080     if (DTVModulation::kModulationQAM256 == tuning.modulation)
00081         return "qam_256";
00082     else if (DTVModulation::kModulationQAM64 == tuning.modulation)
00083         return "qam_64";
00084     //note...ceton also supports NTSC-M, but not sure what to use that for
00085     else if (DTVModulation::kModulation8VSB == tuning.modulation)
00086         return "8vsb";
00087 
00088     return "unknown";
00089 }
00090 
00091 bool CetonChannel::Tune(const DTVMultiplex &tuning, QString /*inputname*/)
00092 {
00093     QString modulation = format_modulation(tuning);
00094 
00095     LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tuning to %1 %2")
00096         .arg(tuning.frequency).arg(modulation));
00097 
00098     if (_stream_handler->TuneFrequency(tuning.frequency, modulation))
00099     {
00100         SetSIStandard(tuning.sistandard);
00101         return true;
00102     }
00103 
00104     return false;
00105 }
00106 
00107 bool CetonChannel::SetChannelByString(const QString &channum)
00108 {
00109     bool ok = DTVChannel::SetChannelByString(channum);
00110 
00111     if (ok)
00112     {
00113         if (_stream_handler->IsCableCardInstalled())
00114             currentProgramNum = _stream_handler->GetProgramNumber();
00115         else
00116             _stream_handler->TuneProgram(currentProgramNum);
00117     }
00118     return ok;
00119 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends