1 #ifndef __lib_dvb_dvbmid_h
2 #define __lib_dvb_dvbmid_h
6 #include <lib/dvb/idvb.h>
7 #include <lib/dvb/dvb.h>
8 #include <lib/dvb/idemux.h>
9 #include <lib/dvb/esection.h>
10 #include <lib/python/python.h>
11 #include <dvbsi++/program_map_section.h>
12 #include <dvbsi++/program_association_section.h>
14 #include <sys/socket.h>
15 #include <sys/types.h>
23 struct channel_data: public Object
25 ePtr<eDVBChannel> m_channel;
26 ePtr<eConnection> m_stateChangedConn;
27 int m_prevChannelState;
31 // TODO .. put all static stuff into a 'eDVBCAServiceHandler class'
33 typedef std::map<eServiceReferenceDVB, eDVBCAService*> CAServiceMap;
34 typedef std::map<iDVBChannel*, channel_data*> ChannelMap;
36 class eDVBCAService: public Object
38 eSocketNotifier *m_sn;
39 eServiceReferenceDVB m_service;
40 uint8_t m_used_demux[32];
41 unsigned int m_prev_build_hash;
44 struct sockaddr_un m_servaddr;
45 unsigned int m_sendstate;
46 unsigned char m_capmt[2048];
50 void socketCB(int what);
52 static void DVBChannelAdded(eDVBChannel*);
53 static void DVBChannelStateChanged(iDVBChannel*);
54 static CAServiceMap exist;
55 static ChannelMap exist_channels;
56 static ePtr<eConnection> m_chanAddedConn;
57 static channel_data *getChannelData(eDVBChannelID &chid);
62 static void registerChannelCallback(eDVBResourceManager *res_mgr);
63 static RESULT register_service( const eServiceReferenceDVB &ref, int demux_nums[2], eDVBCAService *&caservice );
64 static RESULT unregister_service( const eServiceReferenceDVB &ref, int demux_nums[2], eTable<ProgramMapSection> *ptr );
65 void buildCAPMT(eTable<ProgramMapSection> *ptr);
70 class eDVBServicePMTHandler: public Object
73 friend class eDVBCAService;
74 eServiceReferenceDVB m_reference;
75 ePtr<eDVBService> m_service;
77 int m_last_channel_state;
78 eDVBCAService *m_ca_servicePtr;
79 eDVBScan *m_dvb_scan; // for sdt scan
81 eAUTable<eTable<ProgramMapSection> > m_PMT;
82 eAUTable<eTable<ProgramAssociationSection> > m_PAT;
84 eUsePtr<iDVBChannel> m_channel;
85 eUsePtr<iDVBPVRChannel> m_pvr_channel;
86 ePtr<eDVBResourceManager> m_resourceManager;
87 ePtr<iDVBDemux> m_demux;
89 void channelStateChanged(iDVBChannel *);
90 ePtr<eConnection> m_channelStateChanged_connection;
91 void channelEvent(iDVBChannel *, int event);
92 ePtr<eConnection> m_channelEvent_connection;
93 void SDTScanEvent(int);
94 ePtr<eConnection> m_scan_event_connection;
96 void PMTready(int error);
97 void PATready(int error);
101 int m_use_decode_demux;
102 uint8_t m_decode_demux_num;
104 eDVBServicePMTHandler();
105 ~eDVBServicePMTHandler();
110 eDVBServicePMTHandler();
116 eventNoResources, // a requested resource couldn't be allocated
117 eventTuneFailed, // tune failed
118 eventNoPAT, // no pat could be received (timeout)
119 eventNoPATEntry, // no pat entry for the corresponding SID could be found
120 eventNoPMT, // no pmt could be received (timeout)
121 eventNewProgramInfo, // we just received a PMT
122 eventTuned, // a channel was sucessfully (re-)tuned in, you may start additional filters now
124 eventSOF, // seek pre start
125 eventEOF, // a file playback did end
127 eventMisconfiguration, // a channel was not found in any list, or no frontend was found which could provide this channel
130 Signal1<void,int> serviceEvent;
136 enum { vtMPEG2, vtMPEG4_H264 };
143 enum { atMPEG, atAC3, atDTS, atAAC };
144 int type; // mpeg2, ac3, dts, ...
147 std::string language_code; /* iso-639, if available. */
150 struct subtitleStream
153 int subtitling_type; /* see ETSI EN 300 468 table 26 component_type
154 when stream_content is 0x03
155 0x10..0x13, 0x20..0x23 is used for dvb subtitles
156 0x01 is used for teletext subtitles */
159 int composition_page_id; // used for dvb subtitles
160 int teletext_page_number; // used for teletext subtitles
164 int ancillary_page_id; // used for dvb subtitles
165 int teletext_magazine_number; // used for teletext subtitles
167 std::string language_code;
168 bool operator<(const subtitleStream &s) const
172 if (teletext_page_number != s.teletext_page_number)
173 return teletext_page_number < s.teletext_page_number;
174 return teletext_magazine_number < s.teletext_magazine_number;
180 std::vector<videoStream> videoStreams;
181 std::vector<audioStream> audioStreams;
182 int defaultAudioStream;
183 std::vector<subtitleStream> subtitleStreams;
184 std::set<uint16_t> caids;
188 bool isCrypted() { return !caids.empty(); }
190 PyObject *createPythonObject();
193 int getProgramInfo(struct program &program);
194 int getDataDemux(ePtr<iDVBDemux> &demux);
195 int getDecodeDemux(ePtr<iDVBDemux> &demux);
196 PyObject *getCaIds();
198 int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
199 int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; }
200 int getService(ePtr<eDVBService> &service) { service = m_service; return 0; }
201 int getPMT(ePtr<eTable<ProgramMapSection> > &ptr) { return m_PMT.getCurrent(ptr); }
202 int getChannel(eUsePtr<iDVBChannel> &channel);
203 void resetCachedProgram() { m_have_cached_program = false; }
205 int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0);
208 bool m_have_cached_program;
209 program m_cached_program;