1 #ifndef __lib_dvb_dvbmid_h
2 #define __lib_dvb_dvbmid_h
5 #include <lib/dvb/idvb.h>
6 #include <lib/dvb/dvb.h>
7 #include <lib/dvb/idemux.h>
8 #include <lib/dvb/esection.h>
9 #include <lib/python/python.h>
10 #include <dvbsi++/program_map_section.h>
11 #include <dvbsi++/program_association_section.h>
13 #include <sys/socket.h>
14 #include <sys/types.h>
22 typedef std::map<eServiceReferenceDVB, eDVBCAService*> CAServiceMap;
24 class eDVBCAService: public Object
26 eServiceReferenceDVB m_service;
27 uint8_t m_used_demux[32];
28 unsigned int m_prev_build_hash;
31 struct sockaddr_un m_servaddr;
32 unsigned int m_sendstate;
33 unsigned char m_capmt[2048];
38 static CAServiceMap exist;
42 static RESULT register_service( const eServiceReferenceDVB &ref, int demux_nums[2], eDVBCAService *&caservice );
43 static RESULT unregister_service( const eServiceReferenceDVB &ref, int demux_nums[2], eTable<ProgramMapSection> *ptr );
44 void buildCAPMT(eTable<ProgramMapSection> *ptr);
47 class eDVBServicePMTHandler: public Object
49 friend class eDVBCAService;
50 eServiceReferenceDVB m_reference;
51 ePtr<eDVBService> m_service;
53 int m_last_channel_state;
54 eDVBCAService *m_ca_servicePtr;
55 eDVBScan *m_dvb_scan; // for sdt scan
57 eAUTable<eTable<ProgramMapSection> > m_PMT;
58 eAUTable<eTable<ProgramAssociationSection> > m_PAT;
60 eUsePtr<iDVBChannel> m_channel;
61 eUsePtr<iDVBPVRChannel> m_pvr_channel;
62 ePtr<eDVBResourceManager> m_resourceManager;
63 ePtr<iDVBDemux> m_demux;
65 void channelStateChanged(iDVBChannel *);
66 ePtr<eConnection> m_channelStateChanged_connection;
67 void channelEvent(iDVBChannel *, int event);
68 ePtr<eConnection> m_channelEvent_connection;
69 void SDTScanEvent(int);
70 ePtr<eConnection> m_scan_event_connection;
72 void PMTready(int error);
73 void PATready(int error);
77 int m_use_decode_demux;
78 uint8_t m_decode_demux_num;
80 eDVBServicePMTHandler();
81 ~eDVBServicePMTHandler();
85 eventNoResources, // a requested resource couldn't be allocated
86 eventTuneFailed, // tune failed
87 eventNoPAT, // no pat could be received (timeout)
88 eventNoPATEntry, // no pat entry for the corresponding SID could be found
89 eventNoPMT, // no pmt could be received (timeout)
90 eventNewProgramInfo, // we just received a PMT
91 eventTuned, // a channel was sucessfully (re-)tuned in, you may start additional filters now
93 eventSOF, // seek pre start
94 eventEOF, // a file playback did end
97 Signal1<void,int> serviceEvent;
103 enum { vtMPEG2, vtMPEG4_H264 };
110 enum { atMPEG, atAC3, atDTS, atAAC };
111 int type; // mpeg2, ac3, dts, ...
114 std::string language_code; /* iso-639, if available. */
117 struct subtitleStream
120 int subtitling_type; /* see ETSI EN 300 468 table 26 component_type
121 when stream_content is 0x03
122 0x10..0x13, 0x20..0x23 is used for dvb subtitles
123 0x01 is used for teletext subtitles */
126 int composition_page_id; // used for dvb subtitles
127 int teletext_page_number; // used for teletext subtitles
131 int ancillary_page_id; // used for dvb subtitles
132 int teletext_magazine_number; // used for teletext subtitles
134 std::string language_code;
135 bool operator<(const subtitleStream &s) const
139 if (teletext_page_number != s.teletext_page_number)
140 return teletext_page_number < s.teletext_page_number;
141 return teletext_magazine_number < s.teletext_magazine_number;
147 std::vector<videoStream> videoStreams;
148 std::vector<audioStream> audioStreams;
149 std::vector<subtitleStream> subtitleStreams;
150 std::set<uint16_t> caids;
154 bool isCrypted() { return !caids.empty(); }
157 int getProgramInfo(struct program &program);
158 int getDataDemux(ePtr<iDVBDemux> &demux);
159 int getDecodeDemux(ePtr<iDVBDemux> &demux);
160 PyObject *getCaIds();
162 int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
163 int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; }
164 int getService(ePtr<eDVBService> &service) { service = m_service; return 0; }
165 int getPMT(ePtr<eTable<ProgramMapSection> > &ptr) { return m_PMT.getCurrent(ptr); }
166 int getChannel(eUsePtr<iDVBChannel> &channel);
167 void resetCachedProgram() { m_have_cached_program = false; }
169 int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0);
172 bool m_have_cached_program;
173 program m_cached_program;