remove python-specific code from the c++ core
authorpieterg <pieterg@users.sourceforge.net>
Sat, 13 Aug 2011 16:48:15 +0000 (18:48 +0200)
committerpieterg <pieterg@users.sourceforge.net>
Fri, 3 May 2013 17:55:46 +0000 (19:55 +0200)
Replace the python object interface by functions returning c++ objects.
Keep the core clean, let swig create python wrappers.

25 files changed:
lib/dvb/Makefile.inc
lib/dvb/frontend.cpp
lib/dvb/frontend.h
lib/dvb/frontendparms.cpp [new file with mode: 0644]
lib/dvb/frontendparms.h
lib/dvb/idvb.h
lib/dvb/pmt.cpp
lib/dvb/pmtparse.cpp
lib/dvb/pmtparse.h
lib/dvb/scan.cpp
lib/python/Makefile.inc
lib/python/enigma_python.i
lib/python/python_dvb.i [new file with mode: 0644]
lib/python/python_helpers.cpp [new file with mode: 0644]
lib/python/python_helpers.h [new file with mode: 0644]
lib/python/python_service.i [new file with mode: 0644]
lib/service/iservice.h
lib/service/service.cpp
lib/service/servicedvb.cpp
lib/service/servicedvb.h
lib/service/servicedvbrecord.cpp
lib/service/servicedvbrecord.h
lib/service/servicem2ts.cpp
lib/service/servicemp3.cpp
lib/service/servicemp3.h

index e43f7fd..0d8b1d6 100644 (file)
@@ -14,6 +14,7 @@ dvb_libenigma_dvb_a_SOURCES = \
        dvb/esection.cpp \
        dvb/fastscan.cpp \
        dvb/frontend.cpp \
+       dvb/frontendparms.cpp \
        dvb/metaparser.cpp \
        dvb/pesparse.cpp \
        dvb/pmt.cpp \
index 768bd3e..a6c6ba1 100644 (file)
 #define I2C_SLAVE_FORCE        0x0706
 #endif
 
-#include <linux/dvb/frontend.h>
-
-#include <dvbsi++/satellite_delivery_system_descriptor.h>
-#include <dvbsi++/cable_delivery_system_descriptor.h>
-#include <dvbsi++/terrestrial_delivery_system_descriptor.h>
-
 #define eDebugNoSimulate(x...) \
        do { \
                if (!m_simulate) \
@@ -1060,624 +1054,97 @@ int eDVBFrontend::readFrontendData(int type)
        return 0;
 }
 
-void PutToDict(ePyObject &dict, const char*key, long value)
-{
-       ePyObject item = PyInt_FromLong(value);
-       if (item)
-       {
-               if (PyDict_SetItemString(dict, key, item))
-                       eDebug("put %s to dict failed", key);
-               Py_DECREF(item);
-       }
-       else
-               eDebug("could not create PyObject for %s", key);
-}
-
-void PutToDict(ePyObject &dict, const char*key, ePyObject item)
+void eDVBFrontend::getFrontendStatus(ePtr<iDVBFrontendStatus> &dest)
 {
-       if (item)
-       {
-               if (PyDict_SetItemString(dict, key, item))
-                       eDebug("put %s to dict failed", key);
-               Py_DECREF(item);
-       }
-       else
-               eDebug("invalid PyObject for %s", key);
+       ePtr<eDVBFrontend> fe = this;
+       dest = new eDVBFrontendStatus(fe);
 }
 
-void PutToDict(ePyObject &dict, const char*key, const char *value)
+void eDVBFrontend::getTransponderData(ePtr<iDVBTransponderData> &dest, bool original)
 {
-       ePyObject item = PyString_FromString(value);
-       if (item)
+       int type = -1;
+       struct dtv_property p[16];
+       struct dtv_properties cmdseq;
+       oparm.getSystem(type);
+       cmdseq.props = p;
+       cmdseq.num = 0;
+       if (m_simulate || m_fd == -1 || original)
        {
-               if (PyDict_SetItemString(dict, key, item))
-                       eDebug("put %s to dict failed", key);
-               Py_DECREF(item);
+               original = true;
        }
        else
-               eDebug("could not create PyObject for %s", key);
-}
-
-void PutSatelliteDataToDict(ePyObject &dict, iDVBFrontendParameters *oparm)
-{
-       if (oparm)
        {
-               eDVBFrontendParametersSatellite feparm;
-               oparm->getDVBS(feparm);
-
-               PutToDict(dict, "tuner_type", "DVB-S");
-               PutToDict(dict, "frequency", feparm.frequency);
-               PutToDict(dict, "symbol_rate", feparm.symbol_rate);
-               PutToDict(dict, "orbital_position", feparm.orbital_position);
-               PutToDict(dict, "inversion", feparm.inversion);
-               PutToDict(dict, "fec_inner", feparm.fec);
-               PutToDict(dict, "modulation", feparm.modulation);
-               PutToDict(dict, "polarization", feparm.polarisation);
-               if (feparm.system == eDVBFrontendParametersSatellite::System_DVB_S2)
+               p[cmdseq.num++].cmd = DTV_DELIVERY_SYSTEM;
+               p[cmdseq.num++].cmd = DTV_FREQUENCY;
+               p[cmdseq.num++].cmd = DTV_INVERSION;
+               p[cmdseq.num++].cmd = DTV_MODULATION;
+               if (type == feSatellite)
                {
-                       PutToDict(dict, "rolloff", feparm.rolloff);
-                       PutToDict(dict, "pilot", feparm.pilot);
+                       p[cmdseq.num++].cmd = DTV_SYMBOL_RATE;
+                       p[cmdseq.num++].cmd = DTV_INNER_FEC;
+                       p[cmdseq.num++].cmd = DTV_ROLLOFF;
+                       p[cmdseq.num++].cmd = DTV_PILOT;
                }
-               PutToDict(dict, "system", feparm.system);
-       }
-}
-
-void PutTerrestrialDataToDict(ePyObject &dict, iDVBFrontendParameters *oparm)
-{
-       if (oparm)
-       {
-               eDVBFrontendParametersTerrestrial feparm;
-               oparm->getDVBT(feparm);
-
-               PutToDict(dict, "tuner_type", "DVB-T");
-               PutToDict(dict, "frequency", feparm.frequency);
-               PutToDict(dict, "bandwidth", feparm.bandwidth);
-               PutToDict(dict, "code_rate_lp", feparm.code_rate_LP);
-               PutToDict(dict, "code_rate_hp", feparm.code_rate_HP);
-               PutToDict(dict, "constellation", feparm.modulation);
-               PutToDict(dict, "transmission_mode", feparm.transmission_mode);
-               PutToDict(dict, "guard_interval", feparm.guard_interval);
-               PutToDict(dict, "hierarchy_information", feparm.hierarchy);
-               PutToDict(dict, "inversion", feparm.inversion);
-               PutToDict(dict, "system", feparm.system);
-               PutToDict(dict, "plp_id", feparm.plpid);
-       }
-}
-
-void PutCableDataToDict(ePyObject &dict, iDVBFrontendParameters *oparm)
-{
-       if (oparm)
-       {
-               eDVBFrontendParametersCable feparm;
-               oparm->getDVBC(feparm);
-
-               PutToDict(dict, "tuner_type", "DVB-C");
-               PutToDict(dict, "frequency", feparm.frequency);
-               PutToDict(dict, "symbol_rate", feparm.symbol_rate);
-               PutToDict(dict, "modulation", feparm.modulation);
-               PutToDict(dict, "inversion", feparm.inversion);
-               PutToDict(dict, "fec_inner", feparm.fec_inner);
-               PutToDict(dict, "system", feparm.system);
-       }
-}
-
-void PutATSCDataToDict(ePyObject &dict, eDVBFrontendParameters *oparm)
-{
-       if (oparm)
-       {
-               eDVBFrontendParametersATSC feparm;
-               oparm->getATSC(feparm);
-
-               PutToDict(dict, "tuner_type", "ATSC");
-               PutToDict(dict, "frequency", feparm.frequency);
-               PutToDict(dict, "modulation", feparm.modulation);
-               PutToDict(dict, "inversion", feparm.inversion);
-               PutToDict(dict, "system", feparm.system);
-       }
-}
-
-static void fillDictWithSatelliteData(ePyObject dict, struct dtv_property *p, unsigned int propertycount, long freq_offset, eDVBFrontendParameters &oparm)
-{
-       long tmp = 0;
-       long system = eDVBFrontendParametersSatellite::System_DVB_S;
-       eDVBFrontendParametersSatellite parm;
-       oparm.getDVBS(parm);
-
-       PutToDict(dict, "orbital_position", parm.orbital_position);
-       PutToDict(dict, "polarization", parm.polarisation);
-
-       for (unsigned int i = 0; i < propertycount; i++)
-       {
-               switch (p[i].cmd)
+               else if (type == feCable)
                {
-               case DTV_FREQUENCY:
-                       PutToDict(dict, "frequency", p[i].u.data + freq_offset);
-                       break;
-               case DTV_SYMBOL_RATE:
-                       PutToDict(dict, "symbol_rate", p[i].u.data);
-                       break;
-               case DTV_INNER_FEC:
-                       switch (p[i].u.data)
-                       {
-                               case FEC_1_2: tmp = eDVBFrontendParametersSatellite::FEC_1_2; break;
-                               case FEC_2_3: tmp = eDVBFrontendParametersSatellite::FEC_2_3; break;
-                               case FEC_3_4: tmp = eDVBFrontendParametersSatellite::FEC_3_4; break;
-                               case FEC_3_5: tmp = eDVBFrontendParametersSatellite::FEC_3_5; break;
-                               case FEC_4_5: tmp = eDVBFrontendParametersSatellite::FEC_4_5; break;
-                               case FEC_5_6: tmp = eDVBFrontendParametersSatellite::FEC_5_6; break;
-                               case FEC_6_7: tmp = eDVBFrontendParametersSatellite::FEC_6_7; break;
-                               case FEC_7_8: tmp = eDVBFrontendParametersSatellite::FEC_7_8; break;
-                               case FEC_8_9: tmp = eDVBFrontendParametersSatellite::FEC_8_9; break;
-                               case FEC_9_10: tmp = eDVBFrontendParametersSatellite::FEC_9_10; break;
-                               case FEC_NONE: tmp = eDVBFrontendParametersSatellite::FEC_None; break;
-                               default: eDebug("got unsupported FEC from frontend! report as FEC_AUTO!\n");
-                               case FEC_AUTO: tmp = eDVBFrontendParametersSatellite::FEC_Auto; break;
-                       }
-                       PutToDict(dict, "fec_inner", tmp);
-                       break;
-               case DTV_INVERSION:
-                       switch (p[i].u.data)
-                       {
-                               case INVERSION_OFF: tmp = eDVBFrontendParametersSatellite::Inversion_Off; break;
-                               case INVERSION_ON: tmp = eDVBFrontendParametersSatellite::Inversion_On; break;
-                               default: eDebug("got unsupported inversion from frontend! report as INVERSION_AUTO!\n");
-                               case INVERSION_AUTO: tmp = eDVBFrontendParametersSatellite::Inversion_Unknown; break;
-                       }
-                       PutToDict(dict, "inversion", tmp);
-                       break;
-               case DTV_DELIVERY_SYSTEM:
-                       switch (p[i].u.data)
-                       {
-                               default: eDebug("got unsupported system from frontend! report as DVBS!");
-                               case SYS_DVBS: tmp = eDVBFrontendParametersSatellite::System_DVB_S; break;
-                               case SYS_DVBS2: tmp = eDVBFrontendParametersSatellite::System_DVB_S2; break;
-                       }
-                       PutToDict(dict, "system", tmp);
-                       system = tmp;
-                       break;
-               case DTV_MODULATION:
-                       switch (p[i].u.data)
-                       {
-                               default: eDebug("got unsupported modulation from frontend! report as QPSK!");
-                               case QPSK: tmp = eDVBFrontendParametersSatellite::Modulation_QPSK; break;
-                               case PSK_8: tmp = eDVBFrontendParametersSatellite::Modulation_8PSK; break;
-                       }
-                       PutToDict(dict, "modulation", tmp);
-                       break;
-               case DTV_ROLLOFF:
-                       if (system == eDVBFrontendParametersSatellite::System_DVB_S2)
-                       {
-                               switch (p[i].u.data)
-                               {
-                                       case ROLLOFF_20: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_20; break;
-                                       case ROLLOFF_25: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_25; break;
-                                       case ROLLOFF_35: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_35; break;
-                                       default:
-                                       case ROLLOFF_AUTO: tmp = eDVBFrontendParametersSatellite::RollOff_auto; break;
-                               }
-                               PutToDict(dict, "rolloff", tmp);
-                       }
-                       break;
-               case DTV_PILOT:
-                       if (system == eDVBFrontendParametersSatellite::System_DVB_S2)
-                       {
-                               switch (p[i].u.data)
-                               {
-                                       case PILOT_OFF: tmp = eDVBFrontendParametersSatellite::Pilot_Off; break;
-                                       case PILOT_ON: tmp = eDVBFrontendParametersSatellite::Pilot_On; break;
-                                       default:
-                                       case PILOT_AUTO: tmp = eDVBFrontendParametersSatellite::Pilot_Unknown; break;
-                               }
-                               PutToDict(dict, "pilot", tmp);
-                       }
-                       break;
+                       p[cmdseq.num++].cmd = DTV_SYMBOL_RATE;
+                       p[cmdseq.num++].cmd = DTV_INNER_FEC;
                }
-       }
-}
-
-static void fillDictWithCableData(ePyObject dict, struct dtv_property *p, unsigned int propertycount)
-{
-       long tmp = 0;
-       for (unsigned int i = 0; i < propertycount; i++)
-       {
-               switch (p[i].cmd)
+               else if (type == feTerrestrial)
                {
-               case DTV_FREQUENCY:
-                       PutToDict(dict, "frequency", p[i].u.data / 1000);
-                       break;
-               case DTV_SYMBOL_RATE:
-                       PutToDict(dict, "symbol_rate", p[i].u.data);
-                       break;
-               case DTV_INNER_FEC:
-                       switch (p[i].u.data)
-                       {
-                               case FEC_NONE: tmp = eDVBFrontendParametersCable::FEC_None; break;
-                               case FEC_1_2: tmp = eDVBFrontendParametersCable::FEC_1_2; break;
-                               case FEC_2_3: tmp = eDVBFrontendParametersCable::FEC_2_3; break;
-                               case FEC_3_4: tmp = eDVBFrontendParametersCable::FEC_3_4; break;
-                               case FEC_5_6: tmp = eDVBFrontendParametersCable::FEC_5_6; break;
-                               case FEC_6_7: tmp = eDVBFrontendParametersCable::FEC_6_7; break;
-                               case FEC_7_8: tmp = eDVBFrontendParametersCable::FEC_7_8; break;
-                               case FEC_8_9: tmp = eDVBFrontendParametersCable::FEC_7_8; break;
-                               default:
-                               case FEC_AUTO: tmp = eDVBFrontendParametersCable::FEC_Auto; break;
-                       }
-                       PutToDict(dict, "fec_inner", tmp);
-                       break;
-               case DTV_MODULATION:
-                       switch (p[i].u.data)
-                       {
-                               case QAM_16: tmp = eDVBFrontendParametersCable::Modulation_QAM16; break;
-                               case QAM_32: tmp = eDVBFrontendParametersCable::Modulation_QAM32; break;
-                               case QAM_64: tmp = eDVBFrontendParametersCable::Modulation_QAM64; break;
-                               case QAM_128: tmp = eDVBFrontendParametersCable::Modulation_QAM128; break;
-                               case QAM_256: tmp = eDVBFrontendParametersCable::Modulation_QAM256; break;
-                               default:
-                               case QAM_AUTO:   tmp = eDVBFrontendParametersCable::Modulation_Auto; break;
-                       }
-                       PutToDict(dict, "modulation", tmp);
-                       break;
-               case DTV_INVERSION:
-                       switch (p[i].u.data)
-                       {
-                               case INVERSION_OFF: tmp = eDVBFrontendParametersCable::Inversion_Off; break;
-                               case INVERSION_ON: tmp = eDVBFrontendParametersCable::Inversion_On; break;
-                               case INVERSION_AUTO: tmp = eDVBFrontendParametersCable::Inversion_Unknown; break;
-                       }
-                       PutToDict(dict, "inversion", tmp);
-                       break;
-               case DTV_DELIVERY_SYSTEM:
-#ifdef SYS_DVBC_ANNEX_C
-                       switch (p[i].u.data)
-                       {
-                               case SYS_DVBC_ANNEX_A: tmp = eDVBFrontendParametersCable::System_DVB_C_ANNEX_A; break;
-                               case SYS_DVBC_ANNEX_C: tmp = eDVBFrontendParametersCable::System_DVB_C_ANNEX_C; break;
-                       }
-#else
-                       tmp = eDVBFrontendParametersCable::System_DVB_C_ANNEX_A;
-#endif
-                       PutToDict(dict, "system", tmp);
-                       break;
+                       p[cmdseq.num++].cmd = DTV_BANDWIDTH_HZ;
+                       p[cmdseq.num++].cmd = DTV_CODE_RATE_HP;
+                       p[cmdseq.num++].cmd = DTV_CODE_RATE_LP;
+                       p[cmdseq.num++].cmd = DTV_TRANSMISSION_MODE;
+                       p[cmdseq.num++].cmd = DTV_GUARD_INTERVAL;
+                       p[cmdseq.num++].cmd = DTV_HIERARCHY;
                }
-       }
-}
-
-static void fillDictWithTerrestrialData(ePyObject dict, struct dtv_property *p, unsigned int propertycount)
-{
-       long tmp = 0;
-       for (unsigned int i = 0; i < propertycount; i++)
-       {
-               switch (p[i].cmd)
+               else if (type == feATSC)
                {
-                       case DTV_FREQUENCY:
-                               PutToDict(dict, "frequency", p[i].u.data);
-                               break;
-                       case DTV_SYMBOL_RATE:
-                               PutToDict(dict, "symbol_rate", p[i].u.data);
-                               break;
-                       case DTV_BANDWIDTH_HZ:
-                               PutToDict(dict, "bandwidth", p[i].u.data);
-                               break;
-                       case DTV_CODE_RATE_LP:
-                               switch (p[i].u.data)
-                               {
-                                       case FEC_1_2: tmp = eDVBFrontendParametersTerrestrial::FEC_1_2; break;
-                                       case FEC_2_3: tmp = eDVBFrontendParametersTerrestrial::FEC_2_3; break;
-                                       case FEC_3_4: tmp = eDVBFrontendParametersTerrestrial::FEC_3_4; break;
-                                       case FEC_5_6: tmp = eDVBFrontendParametersTerrestrial::FEC_5_6; break;
-                                       case FEC_7_8: tmp = eDVBFrontendParametersTerrestrial::FEC_7_8; break;
-                                       default:
-                                       case FEC_AUTO: tmp = eDVBFrontendParametersTerrestrial::FEC_Auto; break;
-                               }
-                               PutToDict(dict, "code_rate_lp", tmp);
-                               break;
-                       case DTV_CODE_RATE_HP:
-                               switch (p[i].u.data)
-                               {
-                                       case FEC_1_2: tmp = eDVBFrontendParametersTerrestrial::FEC_1_2; break;
-                                       case FEC_2_3: tmp = eDVBFrontendParametersTerrestrial::FEC_2_3; break;
-                                       case FEC_3_4: tmp = eDVBFrontendParametersTerrestrial::FEC_3_4; break;
-                                       case FEC_5_6: tmp = eDVBFrontendParametersTerrestrial::FEC_5_6; break;
-                                       case FEC_7_8: tmp = eDVBFrontendParametersTerrestrial::FEC_7_8; break;
-                                       default:
-                                       case FEC_AUTO: tmp = eDVBFrontendParametersTerrestrial::FEC_Auto; break;
-                               }
-                               PutToDict(dict, "code_rate_hp", tmp);
-                               break;
-                       case DTV_MODULATION:
-                               switch (p[i].u.data)
-                               {
-                                       case QPSK: tmp = eDVBFrontendParametersTerrestrial::Modulation_QPSK; break;
-                                       case QAM_16: tmp = eDVBFrontendParametersTerrestrial::Modulation_QAM16; break;
-                                       case QAM_64: tmp = eDVBFrontendParametersTerrestrial::Modulation_QAM64; break;
-                                       case QAM_256: tmp = eDVBFrontendParametersTerrestrial::Modulation_QAM256; break;
-                                       default:
-                                       case QAM_AUTO: tmp = eDVBFrontendParametersTerrestrial::Modulation_Auto; break;
-                               }
-                               PutToDict(dict, "constellation", tmp);
-                               break;
-                       case DTV_TRANSMISSION_MODE:
-                               switch (p[i].u.data)
-                               {
-                                       case TRANSMISSION_MODE_2K: tmp = eDVBFrontendParametersTerrestrial::TransmissionMode_2k; break;
-                                       case TRANSMISSION_MODE_8K: tmp = eDVBFrontendParametersTerrestrial::TransmissionMode_8k; break;
-                                       default:
-                                       case TRANSMISSION_MODE_AUTO: tmp = eDVBFrontendParametersTerrestrial::TransmissionMode_Auto; break;
-                               }
-                               PutToDict(dict, "transmission_mode", tmp);
-                               break;
-                       case DTV_GUARD_INTERVAL:
-                               switch (p[i].u.data)
-                               {
-                                       case GUARD_INTERVAL_1_32: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_32; break;
-                                       case GUARD_INTERVAL_1_16: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_16; break;
-                                       case GUARD_INTERVAL_1_8: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_8; break;
-                                       case GUARD_INTERVAL_1_4: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_4; break;
-                                       default:
-                                       case GUARD_INTERVAL_AUTO: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_Auto; break;
-                               }
-                               PutToDict(dict, "guard_interval", tmp);
-                               break;
-                       case DTV_HIERARCHY:
-                               switch (p[i].u.data)
-                               {
-                                       case HIERARCHY_NONE: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_None; break;
-                                       case HIERARCHY_1: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_1; break;
-                                       case HIERARCHY_2: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_2; break;
-                                       case HIERARCHY_4: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_4; break;
-                                       default:
-                                       case HIERARCHY_AUTO: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_Auto; break;
-                               }
-                               PutToDict(dict, "hierarchy_information", tmp);
-                               break;
-                       case DTV_INVERSION:
-                               switch (p[i].u.data)
-                               {
-                                       case INVERSION_OFF: tmp = eDVBFrontendParametersTerrestrial::Inversion_Off; break;
-                                       case INVERSION_ON: tmp = eDVBFrontendParametersTerrestrial::Inversion_On; break;
-                                       case INVERSION_AUTO: tmp = eDVBFrontendParametersTerrestrial::Inversion_Unknown; break;
-                               }
-                               PutToDict(dict, "inversion", tmp);
-                               break;
-                       case DTV_DELIVERY_SYSTEM:
-                               switch (p[i].u.data)
-                               {
-                                       default:
-                                       case SYS_DVBT: tmp = eDVBFrontendParametersTerrestrial::System_DVB_T; break;
-                                       case SYS_DVBT2: tmp = eDVBFrontendParametersTerrestrial::System_DVB_T2; break;
-                               }
-                               PutToDict(dict, "system", tmp);
-                               break;
-               }
-       }
-}
-
-static void fillDictWithATSCData(ePyObject dict, struct dtv_property *p, unsigned int propertycount)
-{
-       long tmp = 0;
-       for (unsigned int i = 0; i < propertycount; i++)
-       {
-               switch (p[i].cmd)
-               {
-                       case DTV_FREQUENCY:
-                               PutToDict(dict, "frequency", p[i].u.data / 1000);
-                               break;
-                       case DTV_MODULATION:
-                               switch (p[i].u.data)
-                               {
-                                       case QAM_16: tmp = eDVBFrontendParametersATSC::Modulation_QAM16; break;
-                                       case QAM_32: tmp = eDVBFrontendParametersATSC::Modulation_QAM32; break;
-                                       case QAM_64: tmp = eDVBFrontendParametersATSC::Modulation_QAM64; break;
-                                       case QAM_128: tmp = eDVBFrontendParametersATSC::Modulation_QAM128; break;
-                                       case QAM_256: tmp = eDVBFrontendParametersATSC::Modulation_QAM256; break;
-                                       default:
-                                       case QAM_AUTO:   tmp = eDVBFrontendParametersATSC::Modulation_Auto; break;
-                                       case VSB_8:   tmp = eDVBFrontendParametersATSC::Modulation_VSB_8; break;
-                                       case VSB_16:   tmp = eDVBFrontendParametersATSC::Modulation_VSB_16; break;
-                               }
-                               PutToDict(dict, "modulation", tmp);
-                               break;
-                       case DTV_INVERSION:
-                               switch (p[i].u.data)
-                               {
-                                       case INVERSION_OFF: tmp = eDVBFrontendParametersATSC::Inversion_Off; break;
-                                       case INVERSION_ON: tmp = eDVBFrontendParametersATSC::Inversion_On; break;
-                                       case INVERSION_AUTO: tmp = eDVBFrontendParametersATSC::Inversion_Unknown; break;
-                               }
-                               PutToDict(dict, "inversion", tmp);
-                               break;
-                       case DTV_DELIVERY_SYSTEM:
-                               switch (p[i].u.data)
-                               {
-                                       case SYS_ATSC: tmp = eDVBFrontendParametersATSC::System_ATSC; break;
-                                       case SYS_DVBC_ANNEX_B: tmp = eDVBFrontendParametersATSC::System_DVB_C_ANNEX_B; break;
-                               }
-                               PutToDict(dict, "system", tmp);
-                               break;
                }
-       }
-}
-
-void eDVBFrontend::getFrontendStatus(ePyObject dest)
-{
-       if (dest && PyDict_Check(dest))
-       {
-               int status = 0;
-               int acg = 0;
-               int ber = 0;
-               int signalquality = 0;
-               int signalqualitydb = 0;
-               const char *tmp = "UNKNOWN";
-               switch (m_state)
-               {
-                       case stateIdle:
-                               tmp="IDLE";
-                               break;
-                       case stateTuning:
-                               tmp="TUNING";
-                               break;
-                       case stateFailed:
-                               tmp="FAILED";
-                               break;
-                       case stateLock:
-                               tmp="LOCKED";
-                               break;
-                       case stateLostLock:
-                               tmp="LOSTLOCK";
-                               break;
-                       default:
-                               break;
-               }
-               if (m_state != stateTuning)
+               if (ioctl(m_fd, FE_GET_PROPERTY, &cmdseq) < 0)
                {
-                       int snr = 0;
-                       /* we are not tuning, get the remaining tunerstatus info */
-                       status = readFrontendData(iFrontendInformation_ENUMS::frontendStatus);
-                       snr = readFrontendData(iFrontendInformation_ENUMS::snrValue);
-                       calculateSignalQuality(snr, signalquality, signalqualitydb);
-                       acg = readFrontendData(iFrontendInformation_ENUMS::signalPower);
-                       ber = readFrontendData(iFrontendInformation_ENUMS::bitErrorRate);
-               }
-               PutToDict(dest, "tuner_state", tmp);
-               PutToDict(dest, "tuner_locked", !!(status & FE_HAS_LOCK));
-               PutToDict(dest, "tuner_synced", !!(status & FE_HAS_SYNC));
-               PutToDict(dest, "tuner_bit_error_rate", ber);
-               PutToDict(dest, "tuner_signal_quality", signalquality);
-               if (signalqualitydb == 0x12345678) /* not yet supported */
-               {
-                       ePyObject obj = Py_None;
-                       Py_INCREF(obj);
-                       PutToDict(dest, "tuner_signal_quality_db", obj);
-               }
-               else
-               {
-                       PutToDict(dest, "tuner_signal_quality_db", signalqualitydb);
+                       eDebug("FE_GET_PROPERTY failed (%m)");
+                       original = true;
                }
-               PutToDict(dest, "tuner_signal_power", acg);
        }
-}
-
-void eDVBFrontend::getTransponderData(ePyObject dest, bool original)
-{
-       if (dest && PyDict_Check(dest))
+       switch (type)
        {
-               int type = -1;
-               struct dtv_property p[16];
-               struct dtv_properties cmdseq;
-               oparm.getSystem(type);
-               cmdseq.props = p;
-               cmdseq.num = 0;
-               if (m_simulate || m_fd == -1 || original)
+       case feSatellite:
                {
-                       original = true;
+                       eDVBFrontendParametersSatellite s;
+                       oparm.getDVBS(s);
+                       dest = new eDVBSatelliteTransponderData(cmdseq.props, cmdseq.num, s, m_data[FREQ_OFFSET], original);
+                       break;
                }
-               else
+       case feCable:
                {
-                       p[cmdseq.num++].cmd = DTV_DELIVERY_SYSTEM;
-                       p[cmdseq.num++].cmd = DTV_FREQUENCY;
-                       p[cmdseq.num++].cmd = DTV_INVERSION;
-                       p[cmdseq.num++].cmd = DTV_MODULATION;
-                       if (type == feSatellite)
-                       {
-                               p[cmdseq.num++].cmd = DTV_SYMBOL_RATE;
-                               p[cmdseq.num++].cmd = DTV_INNER_FEC;
-                               p[cmdseq.num++].cmd = DTV_ROLLOFF;
-                               p[cmdseq.num++].cmd = DTV_PILOT;
-                       }
-                       else if (type == feCable)
-                       {
-                               p[cmdseq.num++].cmd = DTV_SYMBOL_RATE;
-                               p[cmdseq.num++].cmd = DTV_INNER_FEC;
-                       }
-                       else if (type == feTerrestrial)
-                       {
-                               p[cmdseq.num++].cmd = DTV_BANDWIDTH_HZ;
-                               p[cmdseq.num++].cmd = DTV_CODE_RATE_HP;
-                               p[cmdseq.num++].cmd = DTV_CODE_RATE_LP;
-                               p[cmdseq.num++].cmd = DTV_TRANSMISSION_MODE;
-                               p[cmdseq.num++].cmd = DTV_GUARD_INTERVAL;
-                               p[cmdseq.num++].cmd = DTV_HIERARCHY;
-                       }
-                       else if (type == feATSC)
-                       {
-                       }
-                       if (ioctl(m_fd, FE_GET_PROPERTY, &cmdseq) < 0)
-                       {
-                               eDebug("FE_GET_PROPERTY failed (%m)");
-                               original = true;
-                       }
+                       eDVBFrontendParametersCable c;
+                       oparm.getDVBC(c);
+                       dest = new eDVBCableTransponderData(cmdseq.props, cmdseq.num, c, original);
+                       break;
                }
-               if (original)
+       case feTerrestrial:
                {
-                       switch (type)
-                       {
-                               case feSatellite:
-                                       PutSatelliteDataToDict(dest, &oparm);
-                                       break;
-                               case feCable:
-                                       PutCableDataToDict(dest, &oparm);
-                                       break;
-                               case feTerrestrial:
-                                       PutTerrestrialDataToDict(dest, &oparm);
-                                       break;
-                               case feATSC:
-                                       PutATSCDataToDict(dest, &oparm);
-                                       break;
-                       }
+                       eDVBFrontendParametersTerrestrial t;
+                       oparm.getDVBT(t);
+                       dest = new eDVBTerrestrialTransponderData(cmdseq.props, cmdseq.num, t, original);
+                       break;
                }
-               else
+       case feATSC:
                {
-                       switch (type)
-                       {
-                               case feSatellite:
-                                       fillDictWithSatelliteData(dest, cmdseq.props, cmdseq.num, m_data[FREQ_OFFSET], oparm);
-                                       break;
-                               case feCable:
-                                       fillDictWithCableData(dest, cmdseq.props, cmdseq.num);
-                                       break;
-                               case feTerrestrial:
-                                       fillDictWithTerrestrialData(dest, cmdseq.props, cmdseq.num);
-                                       break;
-                               case feATSC:
-                                       fillDictWithATSCData(dest, cmdseq.props, cmdseq.num);
-                                       break;
-                       }
+                       eDVBFrontendParametersATSC a;
+                       oparm.getATSC(a);
+                       dest = new eDVBATSCTransponderData(cmdseq.props, cmdseq.num, a, original);
+                       break;
                }
        }
 }
 
-void eDVBFrontend::getFrontendData(ePyObject dest)
+void eDVBFrontend::getFrontendData(ePtr<iDVBFrontendData> &dest)
 {
-       if (dest && PyDict_Check(dest))
-       {
-               const char *tmp=0;
-               PutToDict(dest, "tuner_number", m_slotid);
-               if (supportsDeliverySystem(SYS_DVBS, true) || supportsDeliverySystem(SYS_DVBS2, true))
-               {
-                       tmp = "DVB-S";
-               }
-#ifdef SYS_DVBC_ANNEX_A
-               else if (supportsDeliverySystem(SYS_DVBC_ANNEX_A, true) || supportsDeliverySystem(SYS_DVBC_ANNEX_C, true))
-#else
-               else if (supportsDeliverySystem(SYS_DVBC_ANNEX_AC, true))
-#endif
-               {
-                       tmp = "DVB-C";
-               }
-               else if (supportsDeliverySystem(SYS_DVBT, true) || supportsDeliverySystem(SYS_DVBT2, true))
-               {
-                       tmp = "DVB-T";
-               }
-               else if (supportsDeliverySystem(SYS_ATSC, true) || supportsDeliverySystem(SYS_DVBC_ANNEX_B, true))
-               {
-                       tmp = "ATSC-T";
-               }
-               else
-               {
-                       tmp = "UNKNOWN";
-               }
-               PutToDict(dest, "tuner_type", tmp);
-       }
+       ePtr<eDVBFrontend> fe = this;
+       dest = new eDVBFrontendData(fe);
 }
 
 #ifndef FP_IOCTL_GET_ID
index 82f35f7..2110c69 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <map>
 #include <lib/dvb/idvb.h>
+#include <lib/dvb/frontendparms.h>
 
 class eDVBFrontendParameters: public iDVBFrontendParameters
 {
@@ -137,9 +138,9 @@ public:
        RESULT setData(int num, long val);
 
        int readFrontendData(int type); // iFrontendInformation_ENUMS
-       void getFrontendStatus(ePyObject dest);
-       void getTransponderData(ePyObject dest, bool original);
-       void getFrontendData(ePyObject dest);
+       void getFrontendStatus(ePtr<iDVBFrontendStatus> &dest);
+       void getTransponderData(ePtr<iDVBTransponderData> &dest, bool original);
+       void getFrontendData(ePtr<iDVBFrontendData> &dest);
 
        int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm);
        int getDVBID() { return m_dvbid; }
@@ -161,9 +162,4 @@ public:
 
 #endif // SWIG
 
-void PutToDict(ePyObject &dict, const char*key, long value);
-void PutSatelliteDataToDict(ePyObject &dict, iDVBFrontendParameters *feparm);
-void PutTerrestrialDataToDict(ePyObject &dict, iDVBFrontendParameters *feparm);
-void PutCableDataToDict(ePyObject &dict, iDVBFrontendParameters *feparm);
-
 #endif
diff --git a/lib/dvb/frontendparms.cpp b/lib/dvb/frontendparms.cpp
new file mode 100644 (file)
index 0000000..d12e11a
--- /dev/null
@@ -0,0 +1,649 @@
+#include <lib/dvb/dvb.h>
+#include <lib/dvb/frontendparms.h>
+#include <lib/base/eerror.h>
+#include <lib/base/nconfig.h> // access to python config
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+
+DEFINE_REF(eDVBFrontendStatus);
+
+eDVBFrontendStatus::eDVBFrontendStatus(ePtr<eDVBFrontend> &fe)
+: frontend(fe)
+{
+}
+
+int eDVBFrontendStatus::getState() const
+{
+       int result;
+       if (!frontend) return -1;
+       if (frontend->getState(result) < 0) return -1;
+       return result;
+};
+
+std::string eDVBFrontendStatus::getStateDescription() const
+{
+       switch (getState())
+       {
+       case iDVBFrontend_ENUMS::stateIdle:
+               return "IDLE";
+       case iDVBFrontend_ENUMS::stateTuning:
+               return "TUNING";
+       case iDVBFrontend_ENUMS::stateFailed:
+               return "FAILED";
+       case iDVBFrontend_ENUMS::stateLock:
+               return "LOCKED";
+       case iDVBFrontend_ENUMS::stateLostLock:
+               return "LOSTLOCK";
+       default:
+               break;
+       }
+       return "UNKNOWN";
+}
+
+int eDVBFrontendStatus::getLocked() const
+{
+       if (!frontend) return 0;
+       return frontend->readFrontendData(iFrontendInformation_ENUMS::lockState);
+}
+
+int eDVBFrontendStatus::getSynced() const
+{
+       if (!frontend) return 0;
+       return frontend->readFrontendData(iFrontendInformation_ENUMS::syncState);
+}
+
+int eDVBFrontendStatus::getBER() const
+{
+       if (!frontend || getState() == iDVBFrontend_ENUMS::stateTuning) return 0;
+       return frontend->readFrontendData(iFrontendInformation_ENUMS::bitErrorRate);
+}
+
+int eDVBFrontendStatus::getSNR() const
+{
+       if (!frontend || getState() == iDVBFrontend_ENUMS::stateTuning) return 0;
+       return frontend->readFrontendData(iFrontendInformation_ENUMS::signalQuality);
+}
+
+int eDVBFrontendStatus::getSNRdB() const
+{
+       int value;
+       if (!frontend || getState() == iDVBFrontend_ENUMS::stateTuning) return 0;
+       value = frontend->readFrontendData(iFrontendInformation_ENUMS::signalQualitydB);
+       if (value == 0x12345678)
+       {
+               return -1; /* not supported */
+       }
+       return value;
+}
+
+int eDVBFrontendStatus::getSignalPower() const
+{
+       if (!frontend || getState() == iDVBFrontend_ENUMS::stateTuning) return 0;
+       return frontend->readFrontendData(iFrontendInformation_ENUMS::signalPower);
+}
+
+eDVBTransponderData::eDVBTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, bool original)
+: originalValues(original)
+{
+       for (unsigned int i = 0; i < propertycount; i++)
+       {
+               dtvProperties.push_back(dtvproperties[i]);
+       }
+}
+
+int eDVBTransponderData::getProperty(unsigned int cmd) const
+{
+       for (unsigned int i = 0; i < dtvProperties.size(); i++)
+       {
+               if (dtvProperties[i].cmd == cmd)
+               {
+                       return dtvProperties[i].u.data;
+               }
+       }
+       return -1;
+}
+
+int eDVBTransponderData::getInversion() const
+{
+       return getProperty(DTV_INVERSION);
+}
+
+unsigned int eDVBTransponderData::getFrequency() const
+{
+       return getProperty(DTV_FREQUENCY);
+}
+
+unsigned int eDVBTransponderData::getSymbolRate() const
+{
+       return getProperty(DTV_SYMBOL_RATE);
+}
+
+int eDVBTransponderData::getOrbitalPosition() const
+{
+       return -1;
+}
+
+int eDVBTransponderData::getFecInner() const
+{
+       return getProperty(DTV_INNER_FEC);
+}
+
+int eDVBTransponderData::getModulation() const
+{
+       return getProperty(DTV_MODULATION);
+}
+
+int eDVBTransponderData::getPolarization() const
+{
+       return -1;
+}
+
+int eDVBTransponderData::getRolloff() const
+{
+       return getProperty(DTV_ROLLOFF);
+}
+
+int eDVBTransponderData::getPilot() const
+{
+       return getProperty(DTV_PILOT);
+}
+
+int eDVBTransponderData::getSystem() const
+{
+       return getProperty(DTV_DELIVERY_SYSTEM);
+}
+
+int eDVBTransponderData::getBandwidth() const
+{
+       return getProperty(DTV_BANDWIDTH_HZ);
+}
+
+int eDVBTransponderData::getCodeRateLp() const
+{
+       return getProperty(DTV_CODE_RATE_LP);
+}
+
+int eDVBTransponderData::getCodeRateHp() const
+{
+       return getProperty(DTV_CODE_RATE_HP);
+}
+
+int eDVBTransponderData::getConstellation() const
+{
+       return getProperty(DTV_MODULATION);
+}
+
+int eDVBTransponderData::getTransmissionMode() const
+{
+       return getProperty(DTV_TRANSMISSION_MODE);
+}
+
+int eDVBTransponderData::getGuardInterval() const
+{
+       return getProperty(DTV_GUARD_INTERVAL);
+}
+
+int eDVBTransponderData::getHierarchyInformation() const
+{
+       return getProperty(DTV_HIERARCHY);
+}
+
+DEFINE_REF(eDVBSatelliteTransponderData);
+
+eDVBSatelliteTransponderData::eDVBSatelliteTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersSatellite &transponderparms, int frequencyoffset, bool original)
+: eDVBTransponderData(dtvproperties, propertycount, original), transponderParameters(transponderparms), frequencyOffset(frequencyoffset)
+{
+}
+
+std::string eDVBSatelliteTransponderData::getTunerType() const
+{
+       return "DVB-S";
+}
+
+int eDVBSatelliteTransponderData::getInversion() const
+{
+       if (originalValues) return transponderParameters.inversion;
+
+       switch (eDVBTransponderData::getInversion())
+       {
+       case INVERSION_OFF: return eDVBFrontendParametersSatellite::Inversion_Off;
+       case INVERSION_ON: return eDVBFrontendParametersSatellite::Inversion_On;
+       default: eDebug("got unsupported inversion from frontend! report as INVERSION_AUTO!\n");
+       case INVERSION_AUTO: return eDVBFrontendParametersSatellite::Inversion_Unknown;
+       }
+}
+
+unsigned int eDVBSatelliteTransponderData::getFrequency() const
+{
+       if (originalValues) return transponderParameters.frequency;
+
+       return eDVBTransponderData::getFrequency() + frequencyOffset;
+}
+
+unsigned int eDVBSatelliteTransponderData::getSymbolRate() const
+{
+       if (originalValues) return transponderParameters.symbol_rate;
+
+       return eDVBTransponderData::getSymbolRate();
+}
+
+int eDVBSatelliteTransponderData::getOrbitalPosition() const
+{
+       return transponderParameters.orbital_position;
+}
+
+int eDVBSatelliteTransponderData::getFecInner() const
+{
+       if (originalValues) return transponderParameters.fec;
+
+       switch (eDVBTransponderData::getFecInner())
+       {
+       case FEC_1_2: return eDVBFrontendParametersSatellite::FEC_1_2;
+       case FEC_2_3: return eDVBFrontendParametersSatellite::FEC_2_3;
+       case FEC_3_4: return eDVBFrontendParametersSatellite::FEC_3_4;
+       case FEC_3_5: return eDVBFrontendParametersSatellite::FEC_3_5;
+       case FEC_4_5: return eDVBFrontendParametersSatellite::FEC_4_5;
+       case FEC_5_6: return eDVBFrontendParametersSatellite::FEC_5_6;
+       case FEC_6_7: return eDVBFrontendParametersSatellite::FEC_6_7;
+       case FEC_7_8: return eDVBFrontendParametersSatellite::FEC_7_8;
+       case FEC_8_9: return eDVBFrontendParametersSatellite::FEC_8_9;
+       case FEC_9_10: return eDVBFrontendParametersSatellite::FEC_9_10;
+       case FEC_NONE: return eDVBFrontendParametersSatellite::FEC_None;
+       default: eDebug("got unsupported FEC from frontend! report as FEC_AUTO!\n");
+       case FEC_AUTO: return eDVBFrontendParametersSatellite::FEC_Auto;
+       }
+}
+
+int eDVBSatelliteTransponderData::getModulation() const
+{
+       if (originalValues) return transponderParameters.modulation;
+
+       switch (dtvProperties[1].u.data)
+       {
+       default: eDebug("got unsupported modulation from frontend! report as QPSK!");
+       case QPSK: return eDVBFrontendParametersSatellite::Modulation_QPSK;
+       case PSK_8: return eDVBFrontendParametersSatellite::Modulation_8PSK;
+       }
+}
+
+int eDVBSatelliteTransponderData::getPolarization() const
+{
+       return transponderParameters.polarisation;
+}
+
+int eDVBSatelliteTransponderData::getRolloff() const
+{
+       if (originalValues) return transponderParameters.rolloff;
+
+       switch (eDVBTransponderData::getRolloff())
+       {
+       case ROLLOFF_20: return eDVBFrontendParametersSatellite::RollOff_alpha_0_20;
+       case ROLLOFF_25: return eDVBFrontendParametersSatellite::RollOff_alpha_0_25;
+       case ROLLOFF_35: return eDVBFrontendParametersSatellite::RollOff_alpha_0_35;
+       default:
+       case ROLLOFF_AUTO: return eDVBFrontendParametersSatellite::RollOff_auto;
+       }
+}
+
+int eDVBSatelliteTransponderData::getPilot() const
+{
+       if (originalValues) return transponderParameters.pilot;
+
+       switch (eDVBTransponderData::getPilot())
+       {
+       case PILOT_OFF: return eDVBFrontendParametersSatellite::Pilot_Off;
+       case PILOT_ON: return eDVBFrontendParametersSatellite::Pilot_On;
+       default:
+       case PILOT_AUTO: return eDVBFrontendParametersSatellite::Pilot_Unknown;
+       }
+}
+
+int eDVBSatelliteTransponderData::getSystem() const
+{
+       if (originalValues) return transponderParameters.system;
+
+       switch (eDVBTransponderData::getSystem())
+       {
+       default: eDebug("got unsupported system from frontend! report as DVBS!");
+       case SYS_DVBS: return eDVBFrontendParametersSatellite::System_DVB_S;
+       case SYS_DVBS2: return eDVBFrontendParametersSatellite::System_DVB_S2;
+       }
+}
+
+DEFINE_REF(eDVBCableTransponderData);
+
+eDVBCableTransponderData::eDVBCableTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersCable &transponderparms, bool original)
+ : eDVBTransponderData(dtvproperties, propertycount, original), transponderParameters(transponderparms)
+{
+}
+
+std::string eDVBCableTransponderData::getTunerType() const
+{
+       return "DVB-C";
+}
+
+int eDVBCableTransponderData::getInversion() const
+{
+       if (originalValues) return transponderParameters.inversion;
+
+       switch (eDVBTransponderData::getInversion())
+       {
+       case INVERSION_OFF: return eDVBFrontendParametersCable::Inversion_Off;
+       case INVERSION_ON: return eDVBFrontendParametersCable::Inversion_On;
+       default:
+       case INVERSION_AUTO: return eDVBFrontendParametersCable::Inversion_Unknown;
+       }
+}
+
+unsigned int eDVBCableTransponderData::getFrequency() const
+{
+       if (originalValues) return transponderParameters.frequency;
+
+       return eDVBTransponderData::getFrequency() / 1000;
+}
+
+unsigned int eDVBCableTransponderData::getSymbolRate() const
+{
+       if (originalValues) return transponderParameters.symbol_rate;
+
+       return eDVBTransponderData::getSymbolRate();
+}
+
+int eDVBCableTransponderData::getFecInner() const
+{
+       if (originalValues) return transponderParameters.fec_inner;
+
+       switch (eDVBTransponderData::getFecInner())
+       {
+       case FEC_NONE: return eDVBFrontendParametersCable::FEC_None;
+       case FEC_1_2: return eDVBFrontendParametersCable::FEC_1_2;
+       case FEC_2_3: return eDVBFrontendParametersCable::FEC_2_3;
+       case FEC_3_4: return eDVBFrontendParametersCable::FEC_3_4;
+       case FEC_5_6: return eDVBFrontendParametersCable::FEC_5_6;
+       case FEC_6_7: return eDVBFrontendParametersCable::FEC_6_7;
+       case FEC_7_8: return eDVBFrontendParametersCable::FEC_7_8;
+       case FEC_8_9: return eDVBFrontendParametersCable::FEC_7_8;
+       default:
+       case FEC_AUTO: return eDVBFrontendParametersCable::FEC_Auto;
+       }
+}
+
+int eDVBCableTransponderData::getModulation() const
+{
+       if (originalValues) return transponderParameters.modulation;
+
+       switch (eDVBTransponderData::getModulation())
+       {
+       case QAM_16: return eDVBFrontendParametersCable::Modulation_QAM16;
+       case QAM_32: return eDVBFrontendParametersCable::Modulation_QAM32;
+       case QAM_64: return eDVBFrontendParametersCable::Modulation_QAM64;
+       case QAM_128: return eDVBFrontendParametersCable::Modulation_QAM128;
+       case QAM_256: return eDVBFrontendParametersCable::Modulation_QAM256;
+       default:
+       case QAM_AUTO: return eDVBFrontendParametersCable::Modulation_Auto;
+       }
+}
+
+int eDVBCableTransponderData::getSystem() const
+{
+       if (originalValues) return transponderParameters.system;
+
+#ifdef SYS_DVBC_ANNEX_C
+       switch (eDVBTransponderData::getSystem())
+       {
+       default:
+       case SYS_DVBC_ANNEX_A: return eDVBFrontendParametersCable::System_DVB_C_ANNEX_A;
+       case SYS_DVBC_ANNEX_C: return eDVBFrontendParametersCable::System_DVB_C_ANNEX_C;
+       }
+#else
+       return eDVBFrontendParametersCable::System_DVB_C_ANNEX_A;
+#endif
+}
+
+DEFINE_REF(eDVBTerrestrialTransponderData);
+
+eDVBTerrestrialTransponderData::eDVBTerrestrialTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersTerrestrial &transponderparms, bool original)
+ : eDVBTransponderData(dtvproperties, propertycount, original), transponderParameters(transponderparms)
+{
+}
+
+std::string eDVBTerrestrialTransponderData::getTunerType() const
+{
+       return "DVB-T";
+}
+
+int eDVBTerrestrialTransponderData::getInversion() const
+{
+       if (originalValues) return transponderParameters.inversion;
+
+       switch (eDVBTransponderData::getInversion())
+       {
+       case INVERSION_OFF: return eDVBFrontendParametersTerrestrial::Inversion_Off;
+       case INVERSION_ON: return eDVBFrontendParametersTerrestrial::Inversion_On;
+       default:
+       case INVERSION_AUTO: return eDVBFrontendParametersTerrestrial::Inversion_Unknown;
+       }
+}
+
+unsigned int eDVBTerrestrialTransponderData::getFrequency() const
+{
+       if (originalValues) return transponderParameters.frequency;
+
+       return eDVBTransponderData::getFrequency();
+}
+
+int eDVBTerrestrialTransponderData::getBandwidth() const
+{
+       if (originalValues) return transponderParameters.bandwidth;
+
+       return eDVBTransponderData::getBandwidth();
+}
+
+int eDVBTerrestrialTransponderData::getCodeRateLp() const
+{
+       if (originalValues) return transponderParameters.code_rate_LP;
+
+       switch (eDVBTransponderData::getCodeRateLp())
+       {
+       case FEC_1_2: return eDVBFrontendParametersTerrestrial::FEC_1_2;
+       case FEC_2_3: return eDVBFrontendParametersTerrestrial::FEC_2_3;
+       case FEC_3_4: return eDVBFrontendParametersTerrestrial::FEC_3_4;
+       case FEC_5_6: return eDVBFrontendParametersTerrestrial::FEC_5_6;
+       case FEC_7_8: return eDVBFrontendParametersTerrestrial::FEC_7_8;
+       default:
+       case FEC_AUTO: return eDVBFrontendParametersTerrestrial::FEC_Auto;
+       }
+}
+
+int eDVBTerrestrialTransponderData::getCodeRateHp() const
+{
+       if (originalValues) return transponderParameters.code_rate_HP;
+
+       switch (eDVBTransponderData::getCodeRateHp())
+       {
+       case FEC_1_2: return eDVBFrontendParametersTerrestrial::FEC_1_2;
+       case FEC_2_3: return eDVBFrontendParametersTerrestrial::FEC_2_3;
+       case FEC_3_4: return eDVBFrontendParametersTerrestrial::FEC_3_4;
+       case FEC_5_6: return eDVBFrontendParametersTerrestrial::FEC_5_6;
+       case FEC_7_8: return eDVBFrontendParametersTerrestrial::FEC_7_8;
+       default:
+       case FEC_AUTO: return eDVBFrontendParametersTerrestrial::FEC_Auto;
+       }
+}
+
+int eDVBTerrestrialTransponderData::getConstellation() const
+{
+       if (originalValues) return transponderParameters.modulation;
+
+       switch (eDVBTransponderData::getConstellation())
+       {
+       case QPSK: return eDVBFrontendParametersTerrestrial::Modulation_QPSK;
+       case QAM_16: return eDVBFrontendParametersTerrestrial::Modulation_QAM16;
+       case QAM_64: return eDVBFrontendParametersTerrestrial::Modulation_QAM64;
+       case QAM_256: return eDVBFrontendParametersTerrestrial::Modulation_QAM256;
+       default:
+       case QAM_AUTO: return eDVBFrontendParametersTerrestrial::Modulation_Auto;
+       }
+}
+
+int eDVBTerrestrialTransponderData::getTransmissionMode() const
+{
+       if (originalValues) return transponderParameters.transmission_mode;
+
+       switch (eDVBTransponderData::getTransmissionMode())
+       {
+       case TRANSMISSION_MODE_2K: return eDVBFrontendParametersTerrestrial::TransmissionMode_2k;
+       case TRANSMISSION_MODE_8K: return eDVBFrontendParametersTerrestrial::TransmissionMode_8k;
+       default:
+       case TRANSMISSION_MODE_AUTO: return eDVBFrontendParametersTerrestrial::TransmissionMode_Auto;
+       }
+}
+
+int eDVBTerrestrialTransponderData::getGuardInterval() const
+{
+       if (originalValues) return transponderParameters.guard_interval;
+
+       switch (eDVBTransponderData::getGuardInterval())
+       {
+       case GUARD_INTERVAL_1_32: return eDVBFrontendParametersTerrestrial::GuardInterval_1_32;
+       case GUARD_INTERVAL_1_16: return eDVBFrontendParametersTerrestrial::GuardInterval_1_16;
+       case GUARD_INTERVAL_1_8: return eDVBFrontendParametersTerrestrial::GuardInterval_1_8;
+       case GUARD_INTERVAL_1_4: return eDVBFrontendParametersTerrestrial::GuardInterval_1_4;
+       default:
+       case GUARD_INTERVAL_AUTO: return eDVBFrontendParametersTerrestrial::GuardInterval_Auto;
+       }
+}
+
+int eDVBTerrestrialTransponderData::getHierarchyInformation() const
+{
+       if (originalValues) return transponderParameters.hierarchy;
+
+       switch (eDVBTransponderData::getHierarchyInformation())
+       {
+       case HIERARCHY_NONE: return eDVBFrontendParametersTerrestrial::Hierarchy_None;
+       case HIERARCHY_1: return eDVBFrontendParametersTerrestrial::Hierarchy_1;
+       case HIERARCHY_2: return eDVBFrontendParametersTerrestrial::Hierarchy_2;
+       case HIERARCHY_4: return eDVBFrontendParametersTerrestrial::Hierarchy_4;
+       default:
+       case HIERARCHY_AUTO: return eDVBFrontendParametersTerrestrial::Hierarchy_Auto;
+       }
+}
+
+int eDVBTerrestrialTransponderData::getSystem() const
+{
+       if (originalValues) return transponderParameters.system;
+
+       switch (eDVBTransponderData::getSystem())
+       {
+       default:
+       case SYS_DVBT: return eDVBFrontendParametersTerrestrial::System_DVB_T;
+       case SYS_DVBT2: return eDVBFrontendParametersTerrestrial::System_DVB_T2;
+       }
+}
+
+DEFINE_REF(eDVBATSCTransponderData);
+
+eDVBATSCTransponderData::eDVBATSCTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersATSC &transponderparms, bool original)
+ : eDVBTransponderData(dtvproperties, propertycount, original), transponderParameters(transponderparms)
+{
+}
+
+std::string eDVBATSCTransponderData::getTunerType() const
+{
+       return "ATSC";
+}
+
+int eDVBATSCTransponderData::getInversion() const
+{
+       if (originalValues) return transponderParameters.inversion;
+
+       switch (eDVBTransponderData::getInversion())
+       {
+       case INVERSION_OFF: return eDVBFrontendParametersATSC::Inversion_Off;
+       case INVERSION_ON: return eDVBFrontendParametersATSC::Inversion_On;
+       default:
+       case INVERSION_AUTO: return eDVBFrontendParametersATSC::Inversion_Unknown;
+       }
+}
+
+unsigned int eDVBATSCTransponderData::getFrequency() const
+{
+       if (originalValues) return transponderParameters.frequency;
+
+       return eDVBTransponderData::getFrequency() / 1000;
+}
+
+int eDVBATSCTransponderData::getModulation() const
+{
+       if (originalValues) return transponderParameters.modulation;
+
+       switch (eDVBTransponderData::getModulation())
+       {
+       case QAM_16: return eDVBFrontendParametersATSC::Modulation_QAM16;
+       case QAM_32: return eDVBFrontendParametersATSC::Modulation_QAM32;
+       case QAM_64: return eDVBFrontendParametersATSC::Modulation_QAM64;
+       case QAM_128: return eDVBFrontendParametersATSC::Modulation_QAM128;
+       case QAM_256: return eDVBFrontendParametersATSC::Modulation_QAM256;
+       default:
+       case QAM_AUTO: return eDVBFrontendParametersATSC::Modulation_Auto;
+       case VSB_8: return eDVBFrontendParametersATSC::Modulation_VSB_8;
+       case VSB_16: return eDVBFrontendParametersATSC::Modulation_VSB_16;
+       }
+}
+
+int eDVBATSCTransponderData::getSystem() const
+{
+       if (originalValues) return transponderParameters.system;
+
+       switch (eDVBTransponderData::getSystem())
+       {
+       default:
+       case SYS_ATSC: return eDVBFrontendParametersATSC::System_ATSC;
+       case SYS_DVBC_ANNEX_B: return eDVBFrontendParametersATSC::System_DVB_C_ANNEX_B;
+       }
+}
+
+DEFINE_REF(eDVBFrontendData);
+
+eDVBFrontendData::eDVBFrontendData(ePtr<eDVBFrontend> &fe)
+: frontend(fe)
+{
+}
+
+int eDVBFrontendData::getNumber() const
+{
+       if (!frontend) return -1;
+       return frontend->readFrontendData(iFrontendInformation_ENUMS::frontendNumber);
+}
+
+std::string eDVBFrontendData::getTypeDescription() const
+{
+       std::string result = "UNKNOWN";
+       if (frontend)
+       {
+               if (frontend->supportsDeliverySystem(SYS_DVBS, true) || frontend->supportsDeliverySystem(SYS_DVBS2, true))
+               {
+                       result = "DVB-S";
+               }
+#ifdef SYS_DVBC_ANNEX_A
+               else if (frontend->supportsDeliverySystem(SYS_DVBC_ANNEX_A, true) || frontend->supportsDeliverySystem(SYS_DVBC_ANNEX_C, true))
+#else
+               else if (frontend->supportsDeliverySystem(SYS_DVBC_ANNEX_AC, true))
+#endif
+               {
+                       result = "DVB-C";
+               }
+               else if (frontend->supportsDeliverySystem(SYS_DVBT, true) || frontend->supportsDeliverySystem(SYS_DVBT2, true))
+               {
+                       result = "DVB-T";
+               }
+               else if (frontend->supportsDeliverySystem(SYS_ATSC, true) || frontend->supportsDeliverySystem(SYS_DVBC_ANNEX_B, true))
+               {
+                       result = "ATSC";
+               }
+       }
+       return result;
+}
index 26ac535..a8eab36 100644 (file)
@@ -1,11 +1,16 @@
 #ifndef __lib_dvb_frontendparms_h
 #define __lib_dvb_frontendparms_h
 
+#include <vector>
+
+#include <dvbsi++/satellite_delivery_system_descriptor.h>
+#include <dvbsi++/cable_delivery_system_descriptor.h>
+#include <dvbsi++/terrestrial_delivery_system_descriptor.h>
+
 #include <lib/python/swig.h>
+#include <lib/dvb/idvb.h>
 
-class SatelliteDeliverySystemDescriptor;
-class CableDeliverySystemDescriptor;
-class TerrestrialDeliverySystemDescriptor;
+#include <linux/dvb/frontend.h>
 
 struct eDVBFrontendParametersSatellite
 {
@@ -152,4 +157,149 @@ struct eDVBFrontendParametersATSC
 };
 SWIG_ALLOW_OUTPUT_SIMPLE(eDVBFrontendParametersATSC);
 
+#ifndef SWIG
+
+class eDVBFrontend;
+
+class eDVBFrontendStatus : public iDVBFrontendStatus
+{
+       DECLARE_REF(eDVBFrontendStatus);
+
+       ePtr<eDVBFrontend> frontend;
+
+public:
+       eDVBFrontendStatus(ePtr<eDVBFrontend> &fe);
+
+       int getState() const;
+       std::string getStateDescription() const;
+       int getLocked() const;
+       int getSynced() const;
+       int getBER() const;
+       int getSNR() const;
+       int getSNRdB() const;
+       int getSignalPower() const;
+};
+
+class eDVBTransponderData : public iDVBTransponderData
+{
+protected:
+       std::vector<struct dtv_property> dtvProperties;
+       bool originalValues;
+       int getProperty(unsigned int cmd) const;
+
+public:
+       eDVBTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, bool original);
+
+       int getInversion() const;
+       unsigned int getFrequency() const;
+       unsigned int getSymbolRate() const;
+       int getOrbitalPosition() const;
+       int getFecInner() const;
+       int getModulation() const;
+       int getPolarization() const;
+       int getRolloff() const;
+       int getPilot() const;
+       int getSystem() const;
+       int getBandwidth() const;
+       int getCodeRateLp() const;
+       int getCodeRateHp() const;
+       int getConstellation() const;
+       int getTransmissionMode() const;
+       int getGuardInterval() const;
+       int getHierarchyInformation() const;
+};
+
+class eDVBSatelliteTransponderData : public eDVBTransponderData
+{
+       DECLARE_REF(eDVBSatelliteTransponderData);
+
+       eDVBFrontendParametersSatellite transponderParameters;
+       int frequencyOffset;
+
+public:
+       eDVBSatelliteTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersSatellite &transponderparms, int frequencyoffset, bool original);
+
+       std::string getTunerType() const;
+       int getInversion() const;
+       unsigned int getFrequency() const;
+       unsigned int getSymbolRate() const;
+       int getOrbitalPosition() const;
+       int getFecInner() const;
+       int getModulation() const;
+       int getPolarization() const;
+       int getRolloff() const;
+       int getPilot() const;
+       int getSystem() const;
+};
+
+class eDVBCableTransponderData : public eDVBTransponderData
+{
+       DECLARE_REF(eDVBCableTransponderData);
+
+       eDVBFrontendParametersCable transponderParameters;
+
+public:
+       eDVBCableTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersCable &transponderparms, bool original);
+
+       std::string getTunerType() const;
+       int getInversion() const;
+       unsigned int getFrequency() const;
+       unsigned int getSymbolRate() const;
+       int getFecInner() const;
+       int getModulation() const;
+       int getSystem() const;
+};
+
+class eDVBTerrestrialTransponderData : public eDVBTransponderData
+{
+       DECLARE_REF(eDVBTerrestrialTransponderData);
+
+       eDVBFrontendParametersTerrestrial transponderParameters;
+
+public:
+       eDVBTerrestrialTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersTerrestrial &transponderparms, bool original);
+
+       std::string getTunerType() const;
+       int getInversion() const;
+       unsigned int getFrequency() const;
+       int getBandwidth() const;
+       int getCodeRateLp() const;
+       int getCodeRateHp() const;
+       int getConstellation() const;
+       int getTransmissionMode() const;
+       int getGuardInterval() const;
+       int getHierarchyInformation() const;
+       int getSystem() const;
+};
+
+class eDVBATSCTransponderData : public eDVBTransponderData
+{
+       DECLARE_REF(eDVBATSCTransponderData);
+
+       eDVBFrontendParametersATSC transponderParameters;
+
+public:
+       eDVBATSCTransponderData(struct dtv_property *dtvproperties, unsigned int propertycount, eDVBFrontendParametersATSC &transponderparms, bool original);
+
+       std::string getTunerType() const;
+       int getInversion() const;
+       unsigned int getFrequency() const;
+       int getModulation() const;
+       int getSystem() const;
+};
+
+class eDVBFrontendData : public iDVBFrontendData
+{
+       DECLARE_REF(eDVBFrontendData);
+
+       ePtr<eDVBFrontend> frontend;
+
+public:
+       eDVBFrontendData(ePtr<eDVBFrontend> &fe);
+
+       int getNumber() const;
+       std::string getTypeDescription() const;
+};
+#endif
+
 #endif
index 124d128..00a44c0 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/video.h>
-#include <lib/dvb/frontendparms.h>
 #include <lib/base/object.h>
 #include <lib/base/ebase.h>
 #include <lib/base/elock.h>
@@ -305,7 +304,7 @@ public:
        RESULT getName(const eServiceReference &ref, std::string &name);
        RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr, time_t start_time);
        int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate=false);
-       PyObject *getInfoObject(const eServiceReference &ref, int);  // implemented in lib/service/servicedvb.h
+       ePtr<iDVBTransponderData> getTransponderData(const eServiceReference &ref);
 
                /* for filtering: */
        int checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query);
@@ -385,6 +384,11 @@ public:
 
 #endif  // SWIG
 
+class eDVBFrontendParametersSatellite;
+class eDVBFrontendParametersCable;
+class eDVBFrontendParametersTerrestrial;
+class eDVBFrontendParametersATSC;
+
 class iDVBFrontendParameters: public iObject
 {
 #ifdef SWIG
@@ -438,7 +442,64 @@ public:
        enum { voltageOff, voltage13, voltage18, voltage13_5, voltage18_5 };
 };
 
-SWIG_IGNORE(iDVBFrontend);
+class iDVBFrontendStatus:  public iDVBFrontend_ENUMS, public iObject
+{
+#ifdef SWIG
+       iDVBFrontendStatus();
+       ~iDVBFrontendStatus();
+#endif
+public:
+       virtual int getState() const = 0;
+       virtual std::string getStateDescription() const = 0;
+       virtual int getLocked() const = 0;
+       virtual int getSynced() const = 0;
+       virtual int getBER() const = 0;
+       virtual int getSNR() const = 0;
+       virtual int getSNRdB() const = 0;
+       virtual int getSignalPower() const = 0;
+};
+SWIG_TEMPLATE_TYPEDEF(ePtr<iDVBFrontendStatus>, iDVBFrontendStatusPtr);
+
+class iDVBTransponderData: public iObject
+{
+#ifdef SWIG
+       iDVBTransponderData();
+       ~iDVBTransponderData();
+#endif
+public:
+       virtual std::string getTunerType() const = 0;
+       virtual int getInversion() const = 0;
+       virtual unsigned int getFrequency() const = 0;
+       virtual unsigned int getSymbolRate() const = 0;
+       virtual int getOrbitalPosition() const = 0;
+       virtual int getFecInner() const = 0;
+       virtual int getModulation() const = 0;
+       virtual int getPolarization() const = 0;
+       virtual int getRolloff() const = 0;
+       virtual int getPilot() const = 0;
+       virtual int getSystem() const = 0;
+       virtual int getBandwidth() const = 0;
+       virtual int getCodeRateLp() const = 0;
+       virtual int getCodeRateHp() const = 0;
+       virtual int getConstellation() const = 0;
+       virtual int getTransmissionMode() const = 0;
+       virtual int getGuardInterval() const = 0;
+       virtual int getHierarchyInformation() const = 0;
+};
+SWIG_TEMPLATE_TYPEDEF(ePtr<iDVBTransponderData>, iDVBTransponderDataPtr);
+
+class iDVBFrontendData: public iDVBFrontend_ENUMS, public iObject
+{
+#ifdef SWIG
+       iDVBFrontendData();
+       ~iDVBFrontendData();
+#endif
+public:
+       virtual int getNumber() const = 0;
+       virtual std::string getTypeDescription() const = 0;
+};
+SWIG_TEMPLATE_TYPEDEF(ePtr<iDVBFrontendData>, iDVBFrontendDataPtr);
+
 class iDVBFrontend: public iDVBFrontend_ENUMS, public iObject
 {
 public:
@@ -458,9 +519,9 @@ public:
        virtual RESULT setSecSequence(eSecCommandList &list)=0;
 #endif
        virtual int readFrontendData(int type)=0;
-       virtual void getFrontendStatus(SWIG_PYOBJECT(ePyObject) dest)=0;
-       virtual void getTransponderData(SWIG_PYOBJECT(ePyObject) dest, bool original)=0;
-       virtual void getFrontendData(SWIG_PYOBJECT(ePyObject) dest)=0;
+       virtual void getFrontendStatus(ePtr<iDVBFrontendStatus> &dest)=0;
+       virtual void getTransponderData(ePtr<iDVBTransponderData> &dest, bool original)=0;
+       virtual void getFrontendData(ePtr<iDVBFrontendData> &dest)=0;
 #ifndef SWIG
        virtual RESULT getData(int num, long &data)=0;
        virtual RESULT setData(int num, long val)=0;
index 0d34df8..5ee7e8c 100755 (executable)
@@ -360,6 +360,7 @@ int eDVBServicePMTHandler::getProgramInfo(program &program)
        int cached_vpid = -1;
        int cached_tpid = -1;
        int ret = -1;
+       uint8_t adapter, demux;
 
        if (m_have_cached_program)
        {
@@ -369,6 +370,14 @@ int eDVBServicePMTHandler::getProgramInfo(program &program)
 
        eDVBPMTParser::clearProgramInfo(program);
 
+       if (m_demux)
+       {
+               m_demux->getCAAdapterID(adapter);
+               program.adapterId = adapter;
+               m_demux->getCADemuxID(demux);
+               program.demuxId = demux;
+       }
+
        if ( m_service && !m_service->cacheEmpty() )
        {
                cached_vpid = m_service->getCacheEntry(eDVBService::cVPID);
@@ -862,54 +871,3 @@ void eDVBServicePMTHandler::free()
        m_pvr_channel = 0;
        m_demux = 0;
 }
-
-static PyObject *createTuple(int pid, const char *type)
-{
-       PyObject *r = PyTuple_New(2);
-       PyTuple_SET_ITEM(r, 0, PyInt_FromLong(pid));
-       PyTuple_SET_ITEM(r, 1, PyString_FromString(type));
-       return r;
-}
-
-static inline void PyList_AppendSteal(PyObject *list, PyObject *item)
-{
-       PyList_Append(list, item);
-       Py_DECREF(item);
-}
-
-extern void PutToDict(ePyObject &dict, const char*key, ePyObject item); // defined in dvb/frontend.cpp
-
-PyObject *eDVBServicePMTHandler::program::createPythonObject()
-{
-       ePyObject r = PyDict_New();
-       ePyObject l = PyList_New(0);
-
-       PyList_AppendSteal(l, createTuple(0, "pat"));
-
-       if (pmtPid != -1)
-               PyList_AppendSteal(l, createTuple(pmtPid, "pmt"));
-
-       for (std::vector<eDVBServicePMTHandler::videoStream>::const_iterator
-                       i(videoStreams.begin()); 
-                       i != videoStreams.end(); ++i)
-               PyList_AppendSteal(l, createTuple(i->pid, "video"));
-
-       for (std::vector<eDVBServicePMTHandler::audioStream>::const_iterator
-                       i(audioStreams.begin()); 
-                       i != audioStreams.end(); ++i)
-               PyList_AppendSteal(l, createTuple(i->pid, "audio"));
-
-       for (std::vector<eDVBServicePMTHandler::subtitleStream>::const_iterator
-                       i(subtitleStreams.begin());
-                       i != subtitleStreams.end(); ++i)
-               PyList_AppendSteal(l, createTuple(i->pid, "subtitle"));
-
-       PyList_AppendSteal(l, createTuple(pcrPid, "pcr"));
-
-       if (textPid != -1)
-               PyList_AppendSteal(l, createTuple(textPid, "text"));
-
-       PutToDict(r, "pids", l);
-
-       return r;
-}
index 2cb73c0..a0c1674 100644 (file)
@@ -30,6 +30,8 @@ void eDVBPMTParser::clearProgramInfo(program &program)
        program.aitPid = -1;
        program.dsmccPid = -1;
        program.serviceId = -1;
+       program.adapterId = -1;
+       program.demuxId = -1;
 
        program.defaultAudioStream = 0;
        program.defaultSubtitleStream = -1;
@@ -418,3 +420,111 @@ int eDVBPMTParser::getProgramInfo(program &program)
        }
        return ret;
 }
+
+DEFINE_REF(eDVBPMTParser::eStreamData);
+
+eDVBPMTParser::eStreamData::eStreamData(eDVBPMTParser::program &program)
+{
+       for (std::vector<eDVBPMTParser::videoStream>::const_iterator i(program.videoStreams.begin()); i != program.videoStreams.end(); ++i)
+               videoStreams.push_back(i->pid);
+       for (std::vector<eDVBPMTParser::audioStream>::const_iterator i(program.audioStreams.begin()); i != program.audioStreams.end(); ++i)
+               audioStreams.push_back(i->pid);
+       for (std::vector<eDVBPMTParser::subtitleStream>::const_iterator i(program.subtitleStreams.begin()); i != program.subtitleStreams.end(); ++i)
+               subtitleStreams.push_back(i->pid);
+       pcrPid = program.pcrPid;
+       pmtPid = program.pmtPid;
+       textPid = program.textPid;
+       aitPid = program.aitPid;
+       adapterId = program.adapterId;
+       demuxId = program.demuxId;
+       serviceId = program.serviceId;
+}
+
+RESULT eDVBPMTParser::eStreamData::getAllPids(std::vector<int> &result) const
+{
+       int pid;
+       getVideoPids(result);
+       getAudioPids(result);
+       getSubtitlePids(result);
+       if (getPcrPid(pid) >= 0) result.push_back(pid);
+       if (getPatPid(pid) >= 0) result.push_back(pid);
+       if (getPmtPid(pid) >= 0) result.push_back(pid);
+       if (getTxtPid(pid) >= 0) result.push_back(pid);
+       if (getAitPid(pid) >= 0) result.push_back(pid);
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getVideoPids(std::vector<int> &result) const
+{
+       for (unsigned int i = 0; i < videoStreams.size(); i++)
+       {
+               result.push_back(videoStreams[i]);
+       }
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getAudioPids(std::vector<int> &result) const
+{
+       for (unsigned int i = 0; i < audioStreams.size(); i++)
+       {
+               result.push_back(audioStreams[i]);
+       }
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getSubtitlePids(std::vector<int> &result) const
+{
+       for (unsigned int i = 0; i < subtitleStreams.size(); i++)
+       {
+               result.push_back(subtitleStreams[i]);
+       }
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getPmtPid(int &result) const
+{
+       result = pmtPid;
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getPatPid(int &result) const
+{
+       result = 0;
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getPcrPid(int &result) const
+{
+       result = pcrPid;
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getTxtPid(int &result) const
+{
+       result = textPid;
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getAitPid(int &result) const
+{
+       result = aitPid;
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getServiceId(int &result) const
+{
+       result = serviceId;
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getAdapterId(int &result) const
+{
+       result = adapterId;
+       return 0;
+}
+
+RESULT eDVBPMTParser::eStreamData::getDemuxId(int &result) const
+{
+       result = demuxId;
+       return 0;
+}
index 6db37a0..877e239 100644 (file)
@@ -86,8 +86,32 @@ public:
                int aitPid;
                int dsmccPid;
                int serviceId;
+               int adapterId;
+               int demuxId;
                bool isCrypted() { return !caids.empty(); }
-               PyObject *createPythonObject();
+       };
+
+       class eStreamData : public iStreamData
+       {
+               DECLARE_REF(eStreamData);
+               std::vector<int> videoStreams;
+               std::vector<int> audioStreams;
+               std::vector<int> subtitleStreams;
+               int pcrPid, pmtPid, textPid, aitPid, serviceId, adapterId, demuxId;
+       public:
+               eStreamData(struct program &program);
+               RESULT getAllPids(std::vector<int> &result) const;
+               RESULT getVideoPids(std::vector<int> &result) const;
+               RESULT getAudioPids(std::vector<int> &result) const;
+               RESULT getSubtitlePids(std::vector<int> &result) const;
+               RESULT getPmtPid(int &result) const;
+               RESULT getPatPid(int &result) const;
+               RESULT getPcrPid(int &result) const;
+               RESULT getTxtPid(int &result) const;
+               RESULT getAitPid(int &result) const;
+               RESULT getServiceId(int &result) const;
+               RESULT getAdapterId(int &result) const;
+               RESULT getDemuxId(int &result) const;
        };
 
        virtual int getProgramInfo(program &program);
index 4e9830f..f9923a3 100644 (file)
@@ -12,6 +12,7 @@
 #include <lib/dvb/scan.h>
 #include <lib/dvb/frontend.h>
 #include <lib/dvb/db.h>
+#include <lib/dvb/frontendparms.h>
 #include <lib/base/eenv.h>
 #include <lib/base/eerror.h>
 #include <lib/base/estring.h>
index 1b9164d..c8b0daa 100644 (file)
@@ -3,13 +3,15 @@ noinst_LIBRARIES += python/libenigma_python.a
 python_libenigma_python_a_SOURCES = \
        python/connections.cpp \
        python/python.cpp \
-       python/pythonconfig.cpp
+       python/pythonconfig.cpp \
+       python/python_helpers.cpp
 
 pythonincludedir = $(pkgincludedir)/lib/python
 pythoninclude_HEADERS = \
        python/connections.h \
        python/python.h \
        python/pythonconfig.h \
+       python/python_helpers.h \
        python/swig.h
 
 nodist_python_libenigma_python_a_SOURCES = \
@@ -19,7 +21,9 @@ noinst_PYTHON += \
        python/enigma_py_patcher.py
 
 EXTRA_DIST += \
-       python/enigma_python.i
+       python/enigma_python.i \
+       python/python_service.i \
+       python/python_dvb.i
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/python/enigma_python.Pcpp@am__quote@
 
index 566efce..67ee7b2 100644 (file)
@@ -106,6 +106,7 @@ is usually caused by not marking PSignals as immutable.
 #include <lib/dvb_ci/dvbci.h>
 #include <lib/dvb_ci/dvbci_ui.h>
 #include <lib/python/python.h>
+#include <lib/python/python_helpers.h>
 #include <lib/gdi/picload.h>
 %}
 
@@ -145,6 +146,9 @@ typedef long time_t;
 %include <lib/base/eenv.h>
 %include <lib/base/eerror.h>
 
+%include <lib/python/python_dvb.i>
+%include <lib/python/python_service.i>
+
 %immutable eSocketNotifier::activated;
 %include <lib/base/ebase.h>
 %include <lib/base/smartptr.h>
diff --git a/lib/python/python_dvb.i b/lib/python/python_dvb.i
new file mode 100644 (file)
index 0000000..d606e2e
--- /dev/null
@@ -0,0 +1,35 @@
+%{
+#include <lib/python/swig.h>
+#include <lib/python/python_helpers.h>
+%}
+
+%extend iDVBFrontend {
+void getFrontendStatus(ePyObject dest)
+{
+       ePtr<iDVBFrontendStatus> status;
+       self->getFrontendStatus(status);
+       frontendStatusToDict(dest, status);
+}
+
+void getTransponderData(ePyObject dest, bool original)
+{
+       ePtr<iDVBTransponderData> data;
+       self->getTransponderData(data, original);
+       transponderDataToDict(dest, data);
+}
+
+void getFrontendData(ePyObject dest)
+{
+       ePtr<iDVBFrontendData> data;
+       self->getFrontendData(data);
+       frontendDataToDict(dest, data);
+}
+};
+
+%ignore iDVBFrontend::getFrontendStatus;
+%ignore iDVBFrontend::getTransponderData;
+%ignore iDVBFrontend::getFrontendData;
+
+%ignore iDVBFrontendStatus;
+%ignore iDVBTransponderData;
+%ignore iDVBFrontendData;
diff --git a/lib/python/python_helpers.cpp b/lib/python/python_helpers.cpp
new file mode 100644 (file)
index 0000000..1464315
--- /dev/null
@@ -0,0 +1,166 @@
+#include <lib/python/python_helpers.h>
+
+void PutToDict(ePyObject &dict, const char *key, long value)
+{
+       ePyObject item = PyInt_FromLong(value);
+       if (item)
+       {
+               if (PyDict_SetItemString(dict, key, item))
+                       eDebug("put %s to dict failed", key);
+               Py_DECREF(item);
+       }
+       else
+               eDebug("could not create PyObject for %s", key);
+}
+
+void PutToDict(ePyObject &dict, const char *key, ePyObject item)
+{
+       if (item)
+       {
+               if (PyDict_SetItemString(dict, key, item))
+                       eDebug("put %s to dict failed", key);
+               Py_DECREF(item);
+       }
+       else
+               eDebug("invalid PyObject for %s", key);
+}
+
+void PutToDict(ePyObject &dict, const char *key, const char *value)
+{
+       ePyObject item = PyString_FromString(value);
+       if (item)
+       {
+               if (PyDict_SetItemString(dict, key, item))
+                       eDebug("put %s to dict failed", key);
+               Py_DECREF(item);
+       }
+       else
+               eDebug("could not create PyObject for %s", key);
+}
+
+static PyObject *createTuple(int pid, const char *type)
+{
+       PyObject *r = PyTuple_New(2);
+       PyTuple_SET_ITEM(r, 0, PyInt_FromLong(pid));
+       PyTuple_SET_ITEM(r, 1, PyString_FromString(type));
+       return r;
+}
+
+static inline void PyList_AppendSteal(PyObject *list, PyObject *item)
+{
+       PyList_Append(list, item);
+       Py_DECREF(item);
+}
+
+void frontendDataToDict(ePyObject &dest, ePtr<iDVBFrontendData> data)
+{
+       if (dest && PyDict_Check(dest))
+       {
+               PutToDict(dest, "tuner_number", data->getNumber());
+               PutToDict(dest, "tuner_type", data->getTypeDescription().c_str());
+       }
+}
+
+void frontendStatusToDict(ePyObject &dest, ePtr<iDVBFrontendStatus> status)
+{
+       if (dest && PyDict_Check(dest))
+       {
+               PutToDict(dest, "tuner_state", status->getStateDescription().c_str());
+               PutToDict(dest, "tuner_locked", status->getLocked());
+               PutToDict(dest, "tuner_synced", status->getSynced());
+               PutToDict(dest, "tuner_bit_error_rate", status->getBER());
+               PutToDict(dest, "tuner_signal_quality", status->getSNR());
+               int snrdb = status->getSNRdB();
+               if (snrdb >= 0) PutToDict(dest, "tuner_signal_quality_db", snrdb);
+               PutToDict(dest, "tuner_signal_power", status->getSignalPower());
+       }
+}
+
+void transponderDataToDict(ePyObject &dest, ePtr<iDVBTransponderData> data)
+{
+       if (dest && PyDict_Check(dest))
+       {
+               int value;
+               PutToDict(dest, "tuner_type", data->getTunerType().c_str());
+               PutToDict(dest, "frequency", data->getFrequency());
+               PutToDict(dest, "symbol_rate", data->getSymbolRate());
+               value = data->getOrbitalPosition();
+               if (value >= 0) PutToDict(dest, "orbital_position", value);
+               value = data->getInversion();
+               if (value >= 0) PutToDict(dest, "inversion", value);
+               value = data->getFecInner();
+               if (value >= 0) PutToDict(dest, "fec_inner", value);
+               value = data->getModulation();
+               if (value >= 0) PutToDict(dest, "modulation", value);
+               value = data->getPolarization();
+               if (value >= 0) PutToDict(dest, "polarization", value);
+               value = data->getRolloff();
+               if (value >= 0) PutToDict(dest, "rolloff", value);
+               value = data->getPilot();
+               if (value >= 0) PutToDict(dest, "pilot", value);
+               value = data->getSystem();
+               if (value >= 0) PutToDict(dest, "system", value);
+
+               /* additional terrestrial fields */
+               value = data->getBandwidth();
+               if (value >= 0) PutToDict(dest, "bandwidth", value);
+               value = data->getCodeRateLp();
+               if (value >= 0) PutToDict(dest, "code_rate_lp", value);
+               value = data->getCodeRateHp();
+               if (value >= 0) PutToDict(dest, "code_rate_hp", value);
+               value = data->getConstellation();
+               if (value >= 0) PutToDict(dest, "constellation", value);
+               value = data->getTransmissionMode();
+               if (value >= 0) PutToDict(dest, "transmission_mode", value);
+               value = data->getGuardInterval();
+               if (value >= 0) PutToDict(dest, "guard_interval", value);
+               value = data->getHierarchyInformation();
+               if (value >= 0) PutToDict(dest, "hierarchy_information", value);
+       }
+}
+
+void streamingDataToDict(ePyObject &dest, ePtr<iStreamData> data)
+{
+       if (dest && PyDict_Check(dest))
+       {
+               int pmt, pcr, txt, adapter, demux;
+               std::vector<int> video, audio, subtitle;
+               unsigned int i;
+               ePyObject l = PyList_New(0);
+               PyList_AppendSteal(l, createTuple(0, "pat"));
+
+               data->getPmtPid(pmt);
+               if (pmt != -1)
+                       PyList_AppendSteal(l, createTuple(pmt, "pmt"));
+
+               data->getVideoPids(video);
+               for (i = 0; i < video.size(); i++)
+               {
+                       PyList_AppendSteal(l, createTuple(video[i], "video"));
+               }
+               data->getAudioPids(audio);
+               for (i = 0; i < audio.size(); i++)
+               {
+                       PyList_AppendSteal(l, createTuple(audio[i], "audio"));
+               }
+               data->getSubtitlePids(subtitle);
+               for (i = 0; i < subtitle.size(); i++)
+               {
+                       PyList_AppendSteal(l, createTuple(subtitle[i], "subtitle"));
+               }
+
+               data->getPcrPid(pcr);
+               PyList_AppendSteal(l, createTuple(pcr, "pcr"));
+
+               data->getTxtPid(txt);
+               if (txt != -1)
+                       PyList_AppendSteal(l, createTuple(txt, "text"));
+
+               PutToDict(dest, "pids", l);
+
+               data->getAdapterId(adapter);
+               PutToDict(dest, "adapter", adapter);
+               data->getDemuxId(demux);
+               PutToDict(dest, "demux", demux);
+       }
+}
diff --git a/lib/python/python_helpers.h b/lib/python/python_helpers.h
new file mode 100644 (file)
index 0000000..df6b259
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _python_helpers
+#define _python_helpers
+
+#include <lib/python/python.h>
+#include <lib/dvb/idvb.h>
+#include <lib/service/iservice.h>
+
+void PutToDict(ePyObject &dict, const char *key, long value);
+void PutToDict(ePyObject &dict, const char *key, ePyObject item);
+void PutToDict(ePyObject &dict, const char *key, const char *value);
+
+void frontendDataToDict(ePyObject &dest, ePtr<iDVBFrontendData> data);
+void frontendStatusToDict(ePyObject &dest, ePtr<iDVBFrontendStatus> status);
+void transponderDataToDict(ePyObject &dest, ePtr<iDVBTransponderData> data);
+void streamingDataToDict(ePyObject &dest, ePtr<iStreamData> data);
+
+#endif
diff --git a/lib/python/python_service.i b/lib/python/python_service.i
new file mode 100644 (file)
index 0000000..e808291
--- /dev/null
@@ -0,0 +1,114 @@
+%{
+#include <lib/python/swig.h>
+#include <lib/python/python_helpers.h>
+%}
+
+%extend iServiceInformation {
+PyObject *getInfoObject(int w)
+{
+       switch (w)
+       {
+               case iServiceInformation::sTransponderData:
+               {
+                       ePyObject ret = PyDict_New();
+                       if (ret)
+                       {
+                               ePtr<iDVBTransponderData> data = self->getTransponderData();
+                               transponderDataToDict(ret, data);
+                       }
+                       return ret;
+               }
+               case iServiceInformation::sFileSize:
+                       return PyLong_FromLongLong(self->getFileSize());
+       }
+       Py_INCREF(Py_None);
+       return Py_None;
+}
+};
+
+%ignore iServiceInformation::getInfoObject;
+
+%extend iStaticServiceInformation {
+PyObject *getInfoObject(const eServiceReference &ref, int w)
+{
+       Py_INCREF(Py_None);
+       return Py_None;
+}
+};
+
+%ignore iStaticServiceInformation::getInfoObject;
+
+%extend iStreamableService {
+PyObject *getStreamingData()
+{
+       ePyObject ret = PyDict_New();
+       if (ret)
+       {
+               ePtr<iStreamData> data = self->getStreamingData();
+               streamingDataToDict(ret, data);
+       }
+       return ret;
+}
+};
+
+%ignore iStreamableService::getStreamingData;
+
+%extend iFrontendInformation {
+PyObject *getFrontendData()
+{
+       ePyObject ret = PyDict_New();
+       if (ret)
+       {
+               ePtr<iDVBFrontendData> data = self->getFrontendData();
+               frontendDataToDict(ret, data);
+       }
+       return ret;
+}
+
+PyObject *getFrontendStatus()
+{
+       ePyObject ret = PyDict_New();
+       if (ret)
+       {
+               ePtr<iDVBFrontendStatus> status = self->getFrontendStatus();
+               frontendStatusToDict(ret, status);
+       }
+       return ret;
+}
+
+PyObject *getTransponderData(bool original)
+{
+       ePyObject ret = PyDict_New();
+       if (ret)
+       {
+               ePtr<iDVBTransponderData> data = self->getTransponderData(original);
+               transponderDataToDict(ret, data);
+       }
+       return ret;
+}
+
+PyObject *getAll(bool original)
+{
+       ePyObject ret = PyDict_New();
+       if (ret)
+       {
+               ePtr<iDVBFrontendData> data = self->getFrontendData();
+               frontendDataToDict(ret, data);
+               ePtr<iDVBFrontendStatus> status = self->getFrontendStatus();
+               frontendStatusToDict(ret, status);
+               ePtr<iDVBTransponderData> tpdata = self->getTransponderData(original);
+               transponderDataToDict(ret, tpdata);
+       }
+       return ret;
+}
+};
+
+%ignore iFrontendInformation::getFrontendData;
+%ignore iFrontendInformation::getFrontendStatus;
+%ignore iFrontendInformation::getTransponderData;
+%ignore iFrontendInformation::getAll;
+
+%ignore iStreamData;
+%ignore iDVBFrontendStatus;
+%ignore iDVBTransponderData;
+%ignore iDVBFrontendData;
index 8ced51d..e58e548 100644 (file)
@@ -7,6 +7,7 @@
 #include <string>
 #include <connection.h>
 #include <list>
+#include <vector>
 
 class eServiceEvent;
 
@@ -236,8 +237,8 @@ typedef long long pts_t;
           Hide the result only if there is another way to check for failure! */
 
 class eServiceEvent;
+class iDVBTransponderData;
 
-SWIG_IGNORE(iStaticServiceInformation);
 class iStaticServiceInformation: public iObject
 {
 #ifdef SWIG
@@ -255,7 +256,9 @@ public:
 
        virtual int getInfo(const eServiceReference &ref, int w);
        virtual std::string getInfoString(const eServiceReference &ref,int w);
-       virtual PyObject *getInfoObject(const eServiceReference &ref, int w);
+       void getInfoObject() {}
+       virtual ePtr<iDVBTransponderData> getTransponderData(const eServiceReference &ref);
+       virtual long long getFileSize(const eServiceReference &ref);
 
        virtual int setInfo(const eServiceReference &ref, int w, int v);
        virtual int setInfoString(const eServiceReference &ref, int w, const char *v);
@@ -393,7 +396,6 @@ we like to write iServiceInformation.sVideoType.
 So until swig have no Solution for this Problem we call in lib/python/Makefile.am a python script named
 enigma_py_patcher.py to remove the "_ENUMS" strings in enigma.py at all needed locations. */
 
-SWIG_IGNORE(iServiceInformation);
 class iServiceInformation: public iServiceInformation_ENUMS, public iObject
 {
 #ifdef SWIG
@@ -406,7 +408,9 @@ public:
 
        virtual int getInfo(int w);
        virtual std::string getInfoString(int w);
-       virtual PyObject *getInfoObject(int w);
+       void getInfoObject() {}
+       virtual ePtr<iDVBTransponderData> getTransponderData();
+       virtual long long getFileSize();
 
        virtual int setInfo(int w, int v);
        virtual int setInfoString(int w, const char *v);
@@ -434,7 +438,10 @@ public:
        };
 };
 
-SWIG_IGNORE(iFrontendInformation);
+class iDVBFrontendData;
+class iDVBFrontendStatus;
+class iDVBTransponderData;
+
 class iFrontendInformation: public iFrontendInformation_ENUMS, public iObject
 {
 #ifdef SWIG
@@ -443,10 +450,10 @@ class iFrontendInformation: public iFrontendInformation_ENUMS, public iObject
 #endif
 public:
        virtual int getFrontendInfo(int w)=0;
-       virtual PyObject *getFrontendData()=0;
-       virtual PyObject *getFrontendStatus()=0;
-       virtual PyObject *getTransponderData(bool original)=0;
-       virtual PyObject *getAll(bool original)=0; // a sum of getFrontendData/Status/TransponderData
+       virtual ePtr<iDVBFrontendData> getFrontendData()=0;
+       virtual ePtr<iDVBFrontendStatus> getFrontendStatus()=0;
+       virtual ePtr<iDVBTransponderData> getTransponderData(bool original)=0;
+       void getAll() {}
 };
 SWIG_TEMPLATE_TYPEDEF(ePtr<iFrontendInformation>, iFrontendInformationPtr);
 
@@ -751,7 +758,27 @@ public:
 };
 SWIG_TEMPLATE_TYPEDEF(ePtr<iServiceOfflineOperations>, iServiceOfflineOperationsPtr);
 
-SWIG_IGNORE(iStreamableService);
+class iStreamData: public iObject
+{
+#ifdef SWIG
+       iStreamData();
+       ~iStreamData();
+#endif
+public:
+       virtual SWIG_VOID(RESULT) getAllPids(std::vector<int> &result) const = 0;
+       virtual SWIG_VOID(RESULT) getVideoPids(std::vector<int> &result) const = 0;
+       virtual SWIG_VOID(RESULT) getAudioPids(std::vector<int> &result) const = 0;
+       virtual SWIG_VOID(RESULT) getSubtitlePids(std::vector<int> &result) const = 0;
+       virtual SWIG_VOID(RESULT) getPmtPid(int &result) const = 0;
+       virtual SWIG_VOID(RESULT) getPatPid(int &result) const = 0;
+       virtual SWIG_VOID(RESULT) getPcrPid(int &result) const = 0;
+       virtual SWIG_VOID(RESULT) getTxtPid(int &result) const = 0;
+       virtual SWIG_VOID(RESULT) getServiceId(int &result) const = 0;
+       virtual SWIG_VOID(RESULT) getAdapterId(int &result) const = 0;
+       virtual SWIG_VOID(RESULT) getDemuxId(int &result) const = 0;
+};
+SWIG_TEMPLATE_TYPEDEF(ePtr<iStreamData>, iStreamDataPtr);
+
 class iStreamableService: public iObject
 {
 #ifdef SWIG
@@ -759,14 +786,7 @@ class iStreamableService: public iObject
        ~iStreamableService();
 #endif
 public:
-               /* returns a dict:
-                       { "demux": <n>,
-                         "pids": [(x,type),(y,type),(z,type),..],
-                         ...
-                       }
-                       with type being "video", "audio", "pmt", "pat"...
-               */
-       virtual PyObject *getStreamingData()=0;
+       virtual ePtr<iStreamData> getStreamingData() = 0;
 };
 SWIG_TEMPLATE_TYPEDEF(ePtr<iStreamableService>, iStreamableServicePtr);
 
index 38754aa..423f162 100644 (file)
@@ -1,10 +1,9 @@
 #include <lib/base/eerror.h>
 #include <lib/base/estring.h>
-#include <lib/python/python.h>
 #include <lib/service/service.h>
 #include <lib/base/init_num.h>
 #include <lib/base/init.h>
-#include <lib/python/python.h>
+#include <lib/dvb/idvb.h>
 
 static std::string encode(const std::string s)
 {
@@ -281,34 +280,46 @@ std::string iStaticServiceInformation::getInfoString(const eServiceReference &re
        return "";
 }
 
-PyObject *iStaticServiceInformation::getInfoObject(const eServiceReference &ref, int w)
+ePtr<iDVBTransponderData> iStaticServiceInformation::getTransponderData(const eServiceReference &ref)
 {
-       Py_RETURN_NONE;
+       ePtr<iDVBTransponderData> retval;
+       return retval;
 }
 
-int iServiceInformation::getInfo(int w)
+long long iStaticServiceInformation::getFileSize(const eServiceReference &ref)
 {
-       return -1;
+       return 0;
 }
 
-std::string iServiceInformation::getInfoString(int w)
+int iStaticServiceInformation::setInfo(const eServiceReference &ref, int w, int v)
 {
-       return "";
+       return -1;
 }
 
-PyObject* iServiceInformation::getInfoObject(int w)
+int iStaticServiceInformation::setInfoString(const eServiceReference &ref, int w, const char *v)
 {
-       Py_RETURN_NONE;
+       return -1;
 }
 
-int iStaticServiceInformation::setInfo(const eServiceReference &ref, int w, int v)
+int iServiceInformation::getInfo(int w)
 {
        return -1;
 }
 
-int iStaticServiceInformation::setInfoString(const eServiceReference &ref, int w, const char *v)
+std::string iServiceInformation::getInfoString(int w)
 {
-       return -1;
+       return "";
+}
+
+ePtr<iDVBTransponderData> iServiceInformation::getTransponderData()
+{
+       ePtr<iDVBTransponderData> retval;
+       return retval;
+}
+
+long long iServiceInformation::getFileSize()
+{
+       return 0;
 }
 
 int iServiceInformation::setInfo(int w, int v)
index d14bfa4..e47776d 100644 (file)
@@ -39,7 +39,7 @@ public:
        RESULT getName(const eServiceReference &ref, std::string &name);
        int getLength(const eServiceReference &ref);
        int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate=false);
-       PyObject *getInfoObject(const eServiceReference &ref, int);
+       ePtr<iDVBTransponderData> getTransponderData(const eServiceReference &ref);
 };
 
 DEFINE_REF(eStaticServiceDVBInformation);
@@ -98,61 +98,66 @@ int eStaticServiceDVBInformation::isPlayable(const eServiceReference &ref, const
        return 0;
 }
 
-PyObject *eStaticServiceDVBInformation::getInfoObject(const eServiceReference &r, int what)
+ePtr<iDVBTransponderData> eStaticServiceDVBInformation::getTransponderData(const eServiceReference &r)
 {
+       ePtr<iDVBTransponderData> retval;
        if (r.type == eServiceReference::idDVB)
        {
                const eServiceReferenceDVB &ref = (const eServiceReferenceDVB&)r;
-               switch(what)
+               ePtr<eDVBResourceManager> res;
+               if (!eDVBResourceManager::getInstance(res))
                {
-                       case iServiceInformation::sTransponderData:
+                       ePtr<iDVBChannelList> db;
+                       if (!res->getChannelList(db))
                        {
-                               ePtr<eDVBResourceManager> res;
-                               if (!eDVBResourceManager::getInstance(res))
+                               eDVBChannelID chid;
+                               ref.getChannelID(chid);
+                               ePtr<iDVBFrontendParameters> feparm;
+                               if (!db->getChannelFrontendData(chid, feparm))
                                {
-                                       ePtr<iDVBChannelList> db;
-                                       if (!res->getChannelList(db))
+                                       int system;
+                                       if (!feparm->getSystem(system))
                                        {
-                                               eDVBChannelID chid;
-                                               ref.getChannelID(chid);
-                                               ePtr<iDVBFrontendParameters> feparm;
-                                               if (!db->getChannelFrontendData(chid, feparm))
+                                               switch (system)
                                                {
-                                                       int system;
-                                                       if (!feparm->getSystem(system))
+                                                       case iDVBFrontend::feSatellite:
+                                                       {
+                                                               eDVBFrontendParametersSatellite s;
+                                                               feparm->getDVBS(s);
+                                                               retval = new eDVBSatelliteTransponderData(NULL, 0, s, 0, true);
+                                                               break;
+                                                       }
+                                                       case iDVBFrontend::feTerrestrial:
+                                                       {
+                                                               eDVBFrontendParametersTerrestrial t;
+                                                               feparm->getDVBT(t);
+                                                               retval = new eDVBTerrestrialTransponderData(NULL, 0, t, true);
+                                                               break;
+                                                       }
+                                                       case iDVBFrontend::feCable:
+                                                       {
+                                                               eDVBFrontendParametersCable c;
+                                                               feparm->getDVBC(c);
+                                                               retval = new eDVBCableTransponderData(NULL, 0, c, true);
+                                                               break;
+                                                       }
+                                                       case iDVBFrontend::feATSC:
                                                        {
-                                                               ePyObject dict = PyDict_New();
-                                                               switch (system)
-                                                               {
-                                                                       case iDVBFrontend::feSatellite:
-                                                                       {
-                                                                               PutSatelliteDataToDict(dict, feparm);
-                                                                               break;
-                                                                       }
-                                                                       case iDVBFrontend::feTerrestrial:
-                                                                       {
-                                                                               PutTerrestrialDataToDict(dict, feparm);
-                                                                               break;
-                                                                       }
-                                                                       case iDVBFrontend::feCable:
-                                                                       {
-                                                                               PutCableDataToDict(dict, feparm);
-                                                                               break;
-                                                                       }
-                                                                       default:
-                                                                               eDebug("unknown frontend type %d", system);
-                                                                               Py_DECREF(dict);
-                                                                               break;
-                                                               }
-                                                               return dict;
+                                                               eDVBFrontendParametersATSC a;
+                                                               feparm->getATSC(a);
+                                                               retval = new eDVBATSCTransponderData(NULL, 0, a, true);
+                                                               break;
                                                        }
+                                                       default:
+                                                               eDebug("unknown frontend type %d", system);
+                                                               break;
                                                }
                                        }
                                }
                        }
                }
        }
-       Py_RETURN_NONE;
+       return retval;
 }
 
 DEFINE_REF(eStaticServiceDVBBouquetInformation);
@@ -299,7 +304,8 @@ public:
        int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate) { return 1; }
        int getInfo(const eServiceReference &ref, int w);
        std::string getInfoString(const eServiceReference &ref,int w);
-       PyObject *getInfoObject(const eServiceReference &r, int what);
+       ePtr<iDVBTransponderData> getTransponderData(const eServiceReference &r);
+       long long getFileSize(const eServiceReference &r);
 };
 
 DEFINE_REF(eStaticServiceDVBPVRInformation);
@@ -429,15 +435,15 @@ std::string eStaticServiceDVBPVRInformation::getInfoString(const eServiceReferen
        }
 }
 
-PyObject *eStaticServiceDVBPVRInformation::getInfoObject(const eServiceReference &r, int what)
+ePtr<iDVBTransponderData> eStaticServiceDVBPVRInformation::getTransponderData(const eServiceReference &r)
 {
-       switch (what)
-       {
-       case iServiceInformation::sFileSize:
-               return PyLong_FromLongLong(m_parser.m_filesize);
-       default:
-               Py_RETURN_NONE;
-       }
+       ePtr<iDVBTransponderData> retval;
+       return retval;
+}
+
+long long eStaticServiceDVBPVRInformation::getFileSize(const eServiceReference &ref)
+{
+       return m_parser.m_filesize;
 }
 
 RESULT eStaticServiceDVBPVRInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt, time_t start_time)
@@ -1913,20 +1919,9 @@ std::string eDVBServicePlay::getInfoString(int w)
        return iServiceInformation::getInfoString(w);
 }
 
-PyObject *eDVBServicePlay::getInfoObject(int w)
+ePtr<iDVBTransponderData> eDVBServicePlay::getTransponderData()
 {
-       switch (w)
-       {
-       case sCAIDs:
-               return m_service_handler.getCaIds();
-       case sCAIDPIDs:
-               return m_service_handler.getCaIds(true);
-       case sTransponderData:
-               return eStaticServiceDVBInformation().getInfoObject(m_reference, w);
-       default:
-               break;
-       }
-       return iServiceInformation::getInfoObject(w);
+       return eStaticServiceDVBInformation().getTransponderData(m_reference);
 }
 
 int eDVBServicePlay::getNumberOfTracks()
@@ -2212,75 +2207,41 @@ int eDVBServiceBase::getFrontendInfo(int w)
        return fe->readFrontendData(w);
 }
 
-PyObject *eDVBServiceBase::getFrontendData()
-{
-       ePyObject ret = PyDict_New();
-       if (ret)
-       {
-               eUsePtr<iDVBChannel> channel;
-               if(!m_service_handler.getChannel(channel))
-               {
-                       ePtr<iDVBFrontend> fe;
-                       if(!channel->getFrontend(fe))
-                               fe->getFrontendData(ret);
-               }
-       }
-       else
-               Py_RETURN_NONE;
-       return ret;
-}
-
-PyObject *eDVBServiceBase::getFrontendStatus()
+ePtr<iDVBFrontendData> eDVBServiceBase::getFrontendData()
 {
-       ePyObject ret = PyDict_New();
-       if (ret)
+       ePtr<iDVBFrontendData> ret;
+       eUsePtr<iDVBChannel> channel;
+       if(!m_service_handler.getChannel(channel))
        {
-               eUsePtr<iDVBChannel> channel;
-               if(!m_service_handler.getChannel(channel))
-               {
-                       ePtr<iDVBFrontend> fe;
-                       if(!channel->getFrontend(fe))
-                               fe->getFrontendStatus(ret);
-               }
+               ePtr<iDVBFrontend> fe;
+               if(!channel->getFrontend(fe))
+                       fe->getFrontendData(ret);
        }
-       else
-               Py_RETURN_NONE;
        return ret;
 }
 
-PyObject *eDVBServiceBase::getTransponderData(bool original)
+ePtr<iDVBFrontendStatus> eDVBServiceBase::getFrontendStatus()
 {
-       ePyObject ret = PyDict_New();
-       if (ret)
+       ePtr<iDVBFrontendStatus> ret;
+       eUsePtr<iDVBChannel> channel;
+       if(!m_service_handler.getChannel(channel))
        {
-               eUsePtr<iDVBChannel> channel;
-               if(!m_service_handler.getChannel(channel))
-               {
-                       ePtr<iDVBFrontend> fe;
-                       if(!channel->getFrontend(fe))
-                               fe->getTransponderData(ret, original);
-               }
+               ePtr<iDVBFrontend> fe;
+               if(!channel->getFrontend(fe))
+                       fe->getFrontendStatus(ret);
        }
-       else
-               Py_RETURN_NONE;
        return ret;
 }
 
-PyObject *eDVBServiceBase::getAll(bool original)
+ePtr<iDVBTransponderData> eDVBServiceBase::getTransponderData(bool original)
 {
-       ePyObject ret = getTransponderData(original);
-       if (ret != Py_None)
+       ePtr<iDVBTransponderData> ret;
+       eUsePtr<iDVBChannel> channel;
+       if(!m_service_handler.getChannel(channel))
        {
-               eUsePtr<iDVBChannel> channel;
-               if(!m_service_handler.getChannel(channel))
-               {
-                       ePtr<iDVBFrontend> fe;
-                       if(!channel->getFrontend(fe))
-                       {
-                               fe->getFrontendData(ret);
-                               fe->getFrontendStatus(ret);
-                       }
-               }
+               ePtr<iDVBFrontend> fe;
+               if(!channel->getFrontend(fe))
+                       fe->getTransponderData(ret, original);
        }
        return ret;
 }
@@ -3434,41 +3395,23 @@ RESULT eDVBServicePlay::stream(ePtr<iStreamableService> &ptr)
        return 0;
 }
 
-PyObject *eDVBServicePlay::getStreamingData()
+ePtr<iStreamData> eDVBServicePlay::getStreamingData()
 {
+       ePtr<iStreamData> retval;
        eDVBServicePMTHandler::program program;
-       if (m_service_handler.getProgramInfo(program))
-       {
-               Py_RETURN_NONE;
-       }
-
-       ePyObject r = program.createPythonObject();
-       ePtr<iDVBDemux> demux;
-       if (!m_service_handler.getDataDemux(demux))
+       if (!m_service_handler.getProgramInfo(program))
        {
-               uint8_t demux_id, adapter_id;
-               if (!demux->getCADemuxID(demux_id))
-                       PutToDict(r, "demux", demux_id);
-               if (!demux->getCAAdapterID(adapter_id))
-                       PutToDict(r, "adapter", adapter_id);
+               retval = new eDVBServicePMTHandler::eStreamData(program);
        }
-
-       return r;
+       return retval;
 }
 
 
 DEFINE_REF(eDVBServicePlay)
 
-PyObject *eDVBService::getInfoObject(const eServiceReference &ref, int w)
+ePtr<iDVBTransponderData> eDVBService::getTransponderData(const eServiceReference &ref)
 {
-       switch (w)
-       {
-       case iServiceInformation::sTransponderData:
-               return eStaticServiceDVBInformation().getInfoObject(ref, w);
-       default:
-               break;
-       }
-       return iStaticServiceInformation::getInfoObject(ref, w);
+       return eStaticServiceDVBInformation().getTransponderData(ref);
 }
 
 eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB");
index ba00c47..28fb0cc 100644 (file)
@@ -75,10 +75,9 @@ protected:
 public:
                // iFrontendInformation
        int getFrontendInfo(int w);
-       PyObject *getFrontendData();
-       PyObject *getFrontendStatus();
-       PyObject *getTransponderData(bool);
-       PyObject *getAll(bool original); // a sum of getFrontendData/Status/TransponderData
+       ePtr<iDVBFrontendData> getFrontendData();
+       ePtr<iDVBFrontendStatus> getFrontendStatus();
+       ePtr<iDVBTransponderData> getTransponderData(bool);
 };
 
 class eSubtitleWidget;
@@ -135,7 +134,7 @@ public:
        RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
        int getInfo(int w);
        std::string getInfoString(int w);
-       PyObject *getInfoObject(int w);
+       ePtr<iDVBTransponderData> getTransponderData();
 
                // iAudioTrackSelection 
        int getNumberOfTracks();
@@ -186,7 +185,7 @@ public:
        
                // iStreamableService
        RESULT stream(ePtr<iStreamableService> &ptr);
-       PyObject *getStreamingData();
+       ePtr<iStreamData> getStreamingData();
 
 protected:
        friend class eServiceFactoryDVB;
index cf90a4d..5c6e923 100644 (file)
@@ -493,28 +493,16 @@ RESULT eDVBServiceRecord::stream(ePtr<iStreamableService> &ptr)
        return 0;
 }
 
-extern void PutToDict(ePyObject &dict, const char*key, long val);  // defined in dvb/frontend.cpp
-
-PyObject *eDVBServiceRecord::getStreamingData()
+ePtr<iStreamData> eDVBServiceRecord::getStreamingData()
 {
+       ePtr<iStreamData> retval;
        eDVBServicePMTHandler::program program;
-       if (!m_tuned || m_service_handler.getProgramInfo(program))
-       {
-               Py_RETURN_NONE;
-       }
-
-       ePyObject r = program.createPythonObject();
-       ePtr<iDVBDemux> demux;
-       if (!m_service_handler.getDataDemux(demux))
+       if (m_tuned && !m_service_handler.getProgramInfo(program))
        {
-               uint8_t demux_id, adapter_id;
-               if (!demux->getCADemuxID(demux_id))
-                       PutToDict(r, "demux", demux_id);
-               if (!demux->getCAAdapterID(adapter_id))
-                       PutToDict(r, "adapter", adapter_id);
+               retval = new eDVBServicePMTHandler::eStreamData(program);
        }
 
-       return r;
+       return retval;
 }
 
 void eDVBServiceRecord::recordEvent(int event)
index 8a72acc..6728e0d 100644 (file)
@@ -29,7 +29,7 @@ public:
        RESULT subServices(ePtr<iSubserviceList> &ptr);
 
                // iStreamableService
-       PyObject *getStreamingData();
+       ePtr<iStreamData> getStreamingData();
 
                // iSubserviceList
        int getNumberOfSubservices();
index 6b8667c..da7ea04 100644 (file)
@@ -41,7 +41,6 @@ public:
        int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate) { return 1; }
        int getInfo(const eServiceReference &ref, int w);
        std::string getInfoString(const eServiceReference &ref,int w);
-       PyObject *getInfoObject(const eServiceReference &r, int what);
 };
 
 DEFINE_REF(eStaticServiceM2TSInformation);
@@ -137,17 +136,6 @@ std::string eStaticServiceM2TSInformation::getInfoString(const eServiceReference
        }
 }
 
-PyObject *eStaticServiceM2TSInformation::getInfoObject(const eServiceReference &r, int what)
-{
-       switch (what)
-       {
-       case iServiceInformation::sFileSize:
-               return PyLong_FromLongLong(m_parser.m_filesize);
-       default:
-               Py_RETURN_NONE;
-       }
-}
-
 RESULT eStaticServiceM2TSInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt, time_t start_time)
 {
        if (!ref.path.empty())
index 9301b6a..fb1ea72 100644 (file)
@@ -222,31 +222,33 @@ int eStaticServiceMP3Info::getInfo(const eServiceReference &ref, int w)
        case iServiceInformation::sTimeCreate:
                {
                        struct stat s;
-                       if(stat(ref.path.c_str(), &s) == 0)
+                       if (stat(ref.path.c_str(), &s) == 0)
                        {
                                return s.st_mtime;
                        }
                }
                break;
-       }
-       return iServiceInformation::resNA;
-}
-
-PyObject* eStaticServiceMP3Info::getInfoObject(const eServiceReference &ref, int w)
-{
-       switch(w)
-       {
        case iServiceInformation::sFileSize:
                {
                        struct stat s;
-                       if(stat(ref.path.c_str(), &s) == 0)
+                       if (stat(ref.path.c_str(), &s) == 0)
                        {
-                               return PyLong_FromLongLong(s.st_size);
+                               return s.st_size;
                        }
                }
                break;
        }
-       Py_RETURN_NONE;
+       return iServiceInformation::resNA;
+}
+
+long long eStaticServiceMP3Info::getFileSize(const eServiceReference &ref)
+{
+       struct stat s;
+       if (stat(ref.path.c_str(), &s) == 0)
+       {
+               return s.st_size;
+       }
+       return 0;
 }
 
 // eServiceMP3
index f98c88e..9c19fdc 100644 (file)
@@ -42,7 +42,7 @@ public:
        int getLength(const eServiceReference &ref);
        int getInfo(const eServiceReference &ref, int w);
        int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate) { return 1; }
-       PyObject* getInfoObject(const eServiceReference &ref, int w);
+       long long getFileSize(const eServiceReference &ref);
 };
 
 typedef struct _GstElement GstElement;