MythTV  0.26-pre
dvbchannel.h
Go to the documentation of this file.
00001 // -*- Mode: c++ -*-
00002 /*
00003  *  Copyright (C) Kenneth Aafloy 2003
00004  *
00005  *  Copyright notice is in dvbchannel.cpp of the MythTV project.
00006  */
00007 
00008 #ifndef DVBCHANNEL_H
00009 #define DVBCHANNEL_H
00010 
00011 #include <QObject>
00012 #include <QString>
00013 #include <QMap>
00014 
00015 #include "mythcontext.h"
00016 #include "mythdbcon.h"
00017 #include "dtvchannel.h"
00018 #include "dtvconfparserhelpers.h" // for DTVTunerType
00019 #include "streamlisteners.h"
00020 #include "diseqc.h"
00021 
00022 class TVRec;
00023 class DVBCam;
00024 class DVBRecorder;
00025 class DVBChannel;
00026 
00027 typedef QMap<const DVBChannel*,bool> IsOpenMap;
00028 
00029 class DVBChannel : public DTVChannel
00030 {
00031   public:
00032     DVBChannel(const QString &device, TVRec *parent = NULL);
00033     ~DVBChannel();
00034 
00035     bool Open(void) { return Open(this); }
00036     void Close(void) { Close(this); }
00037 
00038     bool Init(QString &inputname, QString &startchannel, bool setchan);
00039 
00040     // Sets
00041     void SetPMT(const ProgramMapTable*);
00042     void SetTimeOffset(double offset);
00043     void SetSlowTuning(uint how_slow_in_ms)
00044         { tuning_delay = how_slow_in_ms; }
00045 
00046     // Gets
00047     bool IsOpen(void) const;
00048     int  GetFd(void)                    const { return fd_frontend; }
00049     bool IsTuningParamsProbeSupported(void) const;
00050 
00051     QString GetDevice(void)             const { return device; }
00053     QString GetCardNum(void)            const { return device; };
00055     QString GetFrontendName(void)       const;
00056     bool IsMaster(void)                 const;
00058     bool HasCRCBug(void)                const { return has_crc_bug; }
00059     uint GetMinSignalMonitorDelay(void) const { return sigmon_delay; }
00061     const DiSEqCDevRotor *GetRotor(void) const;
00062 
00064     bool HasLock(bool *ok = NULL) const;
00066     double GetSignalStrength(bool *ok = NULL) const;
00074     double GetSNR(bool *ok = NULL) const;
00076     double GetBitErrorRate(bool *ok = NULL) const;
00078     double GetUncorrectedBlockCount(bool *ok = NULL) const;
00079 
00080     // Commands
00081     bool SwitchToInput(const QString &inputname, const QString &chan);
00082     bool SwitchToInput(int newcapchannel, bool setstarting);
00083     bool Tune(const DTVMultiplex &tuning, QString inputname);
00084     bool Tune(const DTVMultiplex &tuning, uint inputid,
00085               bool force_reset = false, bool same_input = false);
00086     bool Retune(void);
00087 
00088     bool ProbeTuningParams(DTVMultiplex &tuning) const;
00089 
00090   private:
00091     bool Open(DVBChannel*);
00092     void Close(DVBChannel*);
00093 
00094     int  GetChanID(void) const;
00095 
00096     void CheckOptions(DTVMultiplex &t) const;
00097     void CheckFrequency(uint64_t frequency) const;
00098     bool CheckModulation(DTVModulation modulation) const;
00099     bool CheckCodeRate(DTVCodeRate rate) const;
00100 
00101     typedef DVBChannel* DVBChannelP;
00102     DVBChannel *GetMasterLock(void);
00103     static void ReturnMasterLock(DVBChannelP &dvbm);
00104 
00105     typedef const DVBChannel* DVBChannelCP;
00106     const DVBChannel *GetMasterLock(void) const;
00107     static void ReturnMasterLock(DVBChannelCP &dvbm);
00108 
00109   private:
00110     IsOpenMap         is_open;
00111 
00112     // Data
00113     DiSEqCDev         diseqc_dev;
00114     DiSEqCDevSettings diseqc_settings;
00115     DiSEqCDevTree    *diseqc_tree;
00116     DVBCam           *dvbcam; 
00117 
00118     // Device info
00119     QString           frontend_name;
00120     uint64_t          capabilities;
00121     uint64_t          ext_modulations;
00122     uint64_t          frequency_minimum;
00123     uint64_t          frequency_maximum;
00124     uint              symbol_rate_minimum;
00125     uint              symbol_rate_maximum;
00126 
00127     // Tuning State
00128     mutable QMutex    tune_lock;
00129     mutable QMutex    hw_lock;
00131     DTVMultiplex      desired_tuning;
00133     DTVMultiplex      prev_tuning;
00134 
00135     uint              last_lnb_dev_id;
00136 
00137     uint              tuning_delay;
00138     uint              sigmon_delay;
00139     bool              first_tune;  
00140 
00141     // Other State
00142     int               fd_frontend; 
00143     QString           device;      
00144     bool              has_crc_bug; 
00145 };
00146 
00147 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends