add support for read signal quality, power and biterror rate from python
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 3 Dec 2005 21:16:59 +0000 (21:16 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 3 Dec 2005 21:16:59 +0000 (21:16 +0000)
lib/dvb/frontend.cpp
lib/dvb/frontend.h
lib/dvb/idvb.h
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h
lib/service/servicemp3.cpp
lib/service/servicemp3.h

index 8d035bf..a26f6bd 100644 (file)
@@ -376,6 +376,35 @@ void eDVBFrontend::timeout()
                m_tuning = 0;
 }
 
+int eDVBFrontend::readFrontendData(int type)
+{
+       switch(type)
+       {
+               case bitErrorRate:
+               {
+                       uint32_t ber=0;
+                       if (ioctl(m_fd, FE_READ_BER, &ber) < 0 && errno != ERANGE)
+                               eDebug("FE_READ_BER failed (%m)");
+                       return ber;
+               }
+               case signalPower:
+               {
+                       uint16_t snr=0;
+                       if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
+                               eDebug("FE_READ_SNR failed (%m)");
+                       return snr;
+               }
+               case signalQuality:
+               {
+                       uint16_t strength=0;
+                       if (ioctl(m_fd, FE_READ_SIGNAL_STRENGTH, &strength) < 0 && errno != ERANGE)
+                               eDebug("FE_READ_SIGNAL_STRENGTH failed (%m)");
+                       return strength;
+               }
+       }
+       return 0;
+}
+
 #ifndef FP_IOCTL_GET_ID
 #define FP_IOCTL_GET_ID 0
 #endif
index d06da32..8da0829 100644 (file)
@@ -91,7 +91,9 @@ public:
        RESULT setSecSequence(const eSecCommandList &list);
        RESULT getData(int num, int &data);
        RESULT setData(int num, int val);
-       
+
+       int readFrontendData(int type); // bitErrorRate, signalPower, signalQuality
+
        int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm);
        
        int getID() { return m_fe; }
index a14e0af..22eccbd 100644 (file)
@@ -344,6 +344,12 @@ public:
        virtual RESULT sendToneburst(int burst)=0;
        virtual RESULT setSEC(iDVBSatelliteEquipmentControl *sec)=0;
        virtual RESULT setSecSequence(const eSecCommandList &list)=0;
+
+       enum {
+               bitErrorRate, signalPower, signalQuality
+       };
+       virtual int readFrontendData(int type)=0;
+
        virtual RESULT getData(int num, int &data)=0;
        virtual RESULT setData(int num, int val)=0;
        
index 232e66f..dfd0669 100644 (file)
@@ -224,6 +224,19 @@ public:
 
 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
 
+class iFrontendStatusInformation: public iObject
+{
+public:
+       enum {
+               bitErrorRate,
+               signalPower,
+               signalQuality
+       };
+       virtual int getFrontendInfo(int w)=0;
+};
+
+TEMPLATE_TYPEDEF(ePtr<iFrontendStatusInformation>, iFrontendStatusInformationPtr);
+
 class iPauseableService: public iObject
 {
 public:
@@ -287,6 +300,7 @@ public:
        virtual SWIG_VOID(RESULT) pause(ePtr<iPauseableService> &SWIG_OUTPUT)=0;
        virtual SWIG_VOID(RESULT) info(ePtr<iServiceInformation> &SWIG_OUTPUT)=0;
        virtual SWIG_VOID(RESULT) audioTracks(ePtr<iAudioTrackSelection> &SWIG_OUTPUT)=0;
+       virtual SWIG_VOID(RESULT) frontendStatusInfo(ePtr<iFrontendStatusInformation> &SWIG_OUTPUT)=0;
 };
 
 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
index 96f942a..9e77a7a 100644 (file)
@@ -681,6 +681,12 @@ RESULT eDVBServicePlay::getPlayPosition(pts_t &pos)
        return pvr_channel->getCurrentPosition(demux, pos);
 }
 
+RESULT eDVBServicePlay::frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr)
+{
+       ptr = this;
+       return 0;
+}
+
 RESULT eDVBServicePlay::info(ePtr<iServiceInformation> &ptr)
 {
        ptr = this;
@@ -811,6 +817,17 @@ int eDVBServicePlay::selectAudioStream(int i)
        return 0;
 }
 
+int eDVBServicePlay::getFrontendInfo(int w)
+{
+       eUsePtr<iDVBChannel> channel;
+       if(m_service_handler.getChannel(channel))
+               return 0;
+       ePtr<iDVBFrontend> fe;
+       if(channel->getFrontend(fe))
+               return 0;
+       return fe->readFrontendData(w);
+}
+
 DEFINE_REF(eDVBServicePlay)
 
 eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB");
index 44d920f..4b6ef3e 100644 (file)
@@ -54,7 +54,7 @@ private:
 
 class eDVBServicePlay: public iPlayableService, public iPauseableService, 
                public iSeekableService, public Object, public iServiceInformation, 
-               public iAudioTrackSelection
+               public iAudioTrackSelection, public iFrontendStatusInformation
 {
 DECLARE_REF(eDVBServicePlay);
 public:
@@ -68,6 +68,7 @@ public:
        RESULT pause(ePtr<iPauseableService> &ptr);
        RESULT info(ePtr<iServiceInformation> &ptr);
        RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
+       RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr);
        
                // iPauseableService
        RESULT pause();
@@ -90,6 +91,9 @@ public:
        RESULT selectTrack(unsigned int i);
        RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
 
+               // iFrontendStatusInformation
+       int getFrontendInfo(int w);
+
 private:
        friend class eServiceFactoryDVB;
        eServiceReference m_reference;
index dc038a8..8f99947 100644 (file)
@@ -149,6 +149,7 @@ RESULT eServiceMP3::stop()
 RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
 RESULT eServiceMP3::seek(ePtr<iSeekableService> &ptr) { ptr = 0; return -1; }
 
+RESULT eServiceMP3::frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr) { ptr = 0; return -1; }
 RESULT eServiceMP3::audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; };
 
                // iPausableService
index bf18e92..9f1a8e9 100644 (file)
@@ -58,6 +58,7 @@ public:
        RESULT pause(ePtr<iPauseableService> &ptr);
        RESULT seek(ePtr<iSeekableService> &ptr);
        RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
+       RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr);
 
                // iPausableService
        RESULT pause();