[FCC] Fix to perform normal decoding for usb tuner on FCC mode.
[vuplus_dvbapp] / lib / dvb / pmt.h
index aa5d34d..fc5d849 100644 (file)
@@ -9,6 +9,7 @@
 #include <lib/dvb/idemux.h>
 #include <lib/dvb/esection.h>
 #include <lib/python/python.h>
+#include <lib/python/connections.h>
 #include <dvbsi++/program_map_section.h>
 #include <dvbsi++/program_association_section.h>
 
 class eDVBCAService;
 class eDVBScan;
 
+#include <dvbsi++/application_information_section.h>
+class OCSection : public LongCrcSection
+{
+protected:
+       void *data;
+
+public:
+       OCSection(const uint8_t * const buffer)
+       : LongCrcSection(buffer)
+       {
+               data = malloc(getSectionLength());
+               memcpy(data, buffer, getSectionLength());
+       }
+       ~OCSection()
+       {
+               free(data);
+       }
+       void *getData() { return data; }
+};
+
 struct channel_data: public Object
 {
        ePtr<eDVBChannel> m_channel;
@@ -69,6 +90,27 @@ public:
 
 #endif
 
+#include <list>
+#include <string>
+class HbbTVApplicationInfo
+{
+public:
+       int m_OrgId;
+       int m_AppId;
+       int m_ControlCode;
+       short m_ProfileCode;
+       std::string m_HbbTVUrl;
+       std::string m_ApplicationName;
+public:
+       HbbTVApplicationInfo(int controlCode, int orgid, int appid, std::string hbbtvUrl, std::string applicationName, int profileCode)
+               : m_ControlCode(controlCode), m_HbbTVUrl(hbbtvUrl), m_ApplicationName(applicationName), m_OrgId(orgid), 
+                 m_AppId(appid), m_ProfileCode(profileCode)
+       {}
+};
+typedef std::list<HbbTVApplicationInfo *> HbbTVApplicationInfoList;
+typedef HbbTVApplicationInfoList::iterator HbbTVApplicationInfoListIterator;
+typedef HbbTVApplicationInfoList::const_iterator HbbTVApplicationInfoListConstIterator;
+
 class eDVBServicePMTHandler: public Object
 {
 #ifndef SWIG
@@ -86,8 +128,8 @@ class eDVBServicePMTHandler: public Object
        eUsePtr<iDVBChannel> m_channel;
        eUsePtr<iDVBPVRChannel> m_pvr_channel;
        ePtr<eDVBResourceManager> m_resourceManager;
-       ePtr<iDVBDemux> m_demux;
-       
+       ePtr<iDVBDemux> m_demux, m_pvr_demux_tmp;
+
        void channelStateChanged(iDVBChannel *);
        ePtr<eConnection> m_channelStateChanged_connection;
        void channelEvent(iDVBChannel *, int event);
@@ -95,13 +137,31 @@ class eDVBServicePMTHandler: public Object
        void SDTScanEvent(int);
        ePtr<eConnection> m_scan_event_connection;
 
+       eAUTable<eTable<ApplicationInformationSection> > m_AIT;
+       eAUTable<eTable<OCSection> > m_OC;
+
+       void registerCAService();
        void PMTready(int error);
        void PATready(int error);
        
        int m_pmt_pid;
        
+       void AITready(int error);
+       void OCready(int error);
+       int m_dsmcc_pid;
+       int m_ait_pid;
+       HbbTVApplicationInfoList m_HbbTVApplications;
+       std::string m_HBBTVUrl;
+       std::string m_ApplicationName;
+       unsigned char m_AITData[4096];
+       
        int m_use_decode_demux;
        uint8_t m_decode_demux_num;
+       ePtr<eTimer> m_no_pat_entry_delay;
+       uint8_t mDemuxId;
+
+       bool m_pmt_ready;
+       bool m_ca_disabled;
 public:
        eDVBServicePMTHandler();
        ~eDVBServicePMTHandler();
@@ -127,7 +187,12 @@ public:
                eventSOF,          // seek pre start
                eventEOF,          // a file playback did end
                
+               eventHBBTVInfo, /* HBBTV information was detected in the AIT */
+               
                eventMisconfiguration, // a channel was not found in any list, or no frontend was found which could provide this channel
+               eventNoDiskSpace,  // no disk space available
+               eventStartPvrDescramble,   // start PVR Descramble Convert
+               eventChannelAllocated,
        };
 #ifndef SWIG
        Signal1<void,int> serviceEvent;
@@ -136,7 +201,7 @@ public:
        {
                int pid;
                int component_tag;
-               enum { vtMPEG2, vtMPEG4_H264, vtMPEG1, vtMPEG4_Part2, vtVC1, vtVC1_SM };
+               enum { vtMPEG2, vtMPEG4_H264, vtMPEG1, vtMPEG4_Part2, vtVC1, vtVC1_SM, vtH265_HEVC };
                int type;
        };
        
@@ -144,7 +209,7 @@ public:
        {
                int pid,
                    rdsPid; // hack for some radio services which transmit radiotext on different pid (i.e. harmony fm, HIT RADIO FFH, ...)
-               enum { atMPEG, atAC3, atDTS, atAAC, atAACHE, atLPCM, atDTSHD };
+               enum { atMPEG, atAC3, atDTS, atAAC, atAACHE, atLPCM, atDTSHD, atDDP  };
                int type; // mpeg2, ac3, dts, ...
                
                int component_tag;
@@ -185,7 +250,7 @@ public:
                {
                        uint16_t caid;
                        int capid;
-                       bool operator< (const struct capid_pair &t) { return t.caid < caid; }
+                       bool operator< (const struct capid_pair &t) const { return t.caid < caid; }
                };
                std::vector<videoStream> videoStreams;
                std::vector<audioStream> audioStreams;
@@ -195,6 +260,9 @@ public:
                int pcrPid;
                int pmtPid;
                int textPid;
+               int aitPid;
+               int pmtVersion;
+               bool isCached;
                bool isCrypted() { return !caids.empty(); }
                PyObject *createPythonObject();
        };
@@ -203,6 +271,7 @@ public:
        int getDataDemux(ePtr<iDVBDemux> &demux);
        int getDecodeDemux(ePtr<iDVBDemux> &demux);
        PyObject *getCaIds(bool pair=false); // caid / ecmpid pair
+       PyObject *getHbbTVApplications(void); 
        
        int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
        int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; }
@@ -210,17 +279,44 @@ public:
        int getPMT(ePtr<eTable<ProgramMapSection> > &ptr) { return m_PMT.getCurrent(ptr); }
        int getChannel(eUsePtr<iDVBChannel> &channel);
        void resetCachedProgram() { m_have_cached_program = false; }
+       void sendEventNoPatEntry();
+
+       void getHBBTVUrl(std::string &ret) { ret = m_HBBTVUrl; }
+       void getDemuxID(int &id) { id = mDemuxId; }
+       void setCaDisable(bool disable) { m_ca_disabled = disable; }
+
+       enum serviceType
+       {
+               livetv = 0,
+               recording = 1,
+               scrambled_recording = 2,
+               playback = 3,
+               timeshift_recording = 4,
+               scrambled_timeshift_recording = 5,
+               timeshift_playback = 6,
+               streamserver = 7,
+               scrambled_streamserver = 8,
+               streamclient = 9,
+               offline = 10,
+               pvrDescramble = 11,
+       };
 
        /* deprecated interface */
-       int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0);
+       int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0, serviceType type = livetv, bool descramble = true);
 
        /* new interface */
-       int tuneExt(eServiceReferenceDVB &ref, int use_decode_demux, ePtr<iTsSource> &, const char *streaminfo_file, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0);
+       int tuneExt(eServiceReferenceDVB &ref, int use_decode_demux, ePtr<iTsSource> &, const char *streaminfo_file, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0, serviceType type = livetv, bool descramble=true);
 
        void free();
+       void addCaHandler();
+       void removeCaHandler();
+       bool isCiConnected();
+       bool isPmtReady() { return m_pmt_ready; }
 private:
        bool m_have_cached_program;
        program m_cached_program;
+       bool m_descramble;
+       serviceType m_service_type;
 #endif
 };