fixme: stopService()
[enigma2.git] / lib / dvb / pmt.h
index efe54ee..a60f37b 100644 (file)
@@ -5,18 +5,56 @@
 #include <lib/dvb/dvb.h>
 #include <lib/dvb/idemux.h>
 #include <lib/dvb/esection.h>
-#include <lib/dvb_si/pmt.h>
-#include <lib/dvb_si/pat.h>
+#include <dvbsi++/program_map_section.h>
+#include <dvbsi++/program_association_section.h>
+
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+class eDVBServicePMTHandler;
+
+class eDVBCAService: public Object
+{
+       eDVBServicePMTHandler &m_parent;
+       int m_sock, m_clilen;
+       struct sockaddr_un m_servaddr;
+       unsigned int m_sendstate;
+       unsigned char *m_capmt;
+       eTimer m_retryTimer;
+       void sendCAPMT();
+       void Connect();
+public:
+       eDVBCAService( eDVBServicePMTHandler &parent )
+               :m_parent(parent), m_sendstate(0), m_capmt(NULL), m_retryTimer(eApp)
+       {
+               CONNECT(m_retryTimer.timeout, eDVBCAService::sendCAPMT);
+               Connect();
+//             eDebug("[eDVBCAHandler] new service %s", service.toString().c_str() );
+       }
+       ~eDVBCAService()
+       {
+               delete [] m_capmt;
+               ::close(m_sock);
+//             eDebug("[eDVBCAHandler] leave service %s", me.toString().c_str() );
+       }
+       void buildCAPMT();
+};
 
 class eDVBServicePMTHandler: public Object
 {
+       friend class eDVBCAService;
        eServiceReferenceDVB m_reference;
        ePtr<eDVBService> m_service;
 
        int m_last_channel_state;
-       
-       eAUTable<eTable<ProgramMapTable> > m_PMT;
-       eAUTable<eTable<ProgramAssociationTable> > m_PAT;
+       uint16_t m_pmt_pid;
+       eDVBCAService *m_ca_servicePtr;
+
+       eAUTable<eTable<ProgramMapSection> > m_PMT;
+       eAUTable<eTable<ProgramAssociationSection> > m_PAT;
 
        eUsePtr<iDVBChannel> m_channel;
        eUsePtr<iDVBPVRChannel> m_pvr_channel;
@@ -28,12 +66,16 @@ class eDVBServicePMTHandler: public Object
 
        void PMTready(int error);
        void PATready(int error);
+       
+       int m_record;
 public:
-       eDVBServicePMTHandler();
+       eDVBServicePMTHandler(int record);
+       ~eDVBServicePMTHandler();
        
        enum
        {
                eventNoResources,  // a requested resource couldn't be allocated
+               eventTuneFailed,   // tune failed
                eventNoPAT,        // no pat could be received (timeout)
                eventNoPATEntry,   // no pat entry for the corresponding SID could be found
                eventNoPMT,        // no pmt could be received (timeout)
@@ -62,6 +104,7 @@ public:
                std::vector<audioStream> audioStreams;
                // ca info
                int pcrPid;
+               int pmtPid;
        };
        
        int getProgramInfo(struct program &program);