1 #ifndef __lib_dvb_dvbmid_h
2 #define __lib_dvb_dvbmid_h
6 #include <lib/base/buffer.h>
7 #include <lib/dvb/idvb.h>
8 #include <lib/dvb/dvb.h>
9 #include <lib/dvb/idemux.h>
10 #include <lib/dvb/esection.h>
11 #include <lib/python/python.h>
12 #include <dvbsi++/program_map_section.h>
13 #include <dvbsi++/program_association_section.h>
15 #include <sys/socket.h>
16 #include <sys/types.h>
24 struct channel_data: public Object
26 ePtr<eDVBChannel> m_channel;
27 ePtr<eConnection> m_stateChangedConn;
28 int m_prevChannelState;
32 // TODO .. put all static stuff into a 'eDVBCAServiceHandler class'
34 typedef std::map<eServiceReferenceDVB, eDVBCAService*> CAServiceMap;
35 typedef std::map<iDVBChannel*, channel_data*> ChannelMap;
37 class eDVBCAService: public Object
40 ePtr<eSocketNotifier> m_sn;
41 eServiceReferenceDVB m_service;
42 uint8_t m_used_demux[32];
43 unsigned int m_prev_build_hash;
46 struct sockaddr_un m_servaddr;
47 unsigned int m_sendstate;
48 unsigned char m_capmt[2048];
49 ePtr<eTimer> m_retryTimer;
52 void socketCB(int what);
54 static void DVBChannelAdded(eDVBChannel*);
55 static void DVBChannelStateChanged(iDVBChannel*);
56 static CAServiceMap exist;
57 static ChannelMap exist_channels;
58 static ePtr<eConnection> m_chanAddedConn;
59 static channel_data *getChannelData(eDVBChannelID &chid);
64 static void registerChannelCallback(eDVBResourceManager *res_mgr);
65 static RESULT register_service( const eServiceReferenceDVB &ref, int demux_nums[2], eDVBCAService *&caservice );
66 static RESULT unregister_service( const eServiceReferenceDVB &ref, int demux_nums[2], eTable<ProgramMapSection> *ptr );
67 void buildCAPMT(eTable<ProgramMapSection> *ptr);
72 class eDVBServicePMTHandler: public Object
75 friend class eDVBCAService;
76 eServiceReferenceDVB m_reference;
77 ePtr<eDVBService> m_service;
79 int m_last_channel_state;
80 eDVBCAService *m_ca_servicePtr;
81 ePtr<eDVBScan> m_dvb_scan; // for sdt scan
83 eAUTable<eTable<ProgramMapSection> > m_PMT;
84 eAUTable<eTable<ProgramAssociationSection> > m_PAT;
86 eUsePtr<iDVBChannel> m_channel;
87 eUsePtr<iDVBPVRChannel> m_pvr_channel;
88 ePtr<eDVBResourceManager> m_resourceManager;
89 ePtr<iDVBDemux> m_demux;
91 void channelStateChanged(iDVBChannel *);
92 ePtr<eConnection> m_channelStateChanged_connection;
93 void channelEvent(iDVBChannel *, int event);
94 ePtr<eConnection> m_channelEvent_connection;
95 void SDTScanEvent(int);
96 ePtr<eConnection> m_scan_event_connection;
98 void PMTready(int error);
99 void PATready(int error);
103 int m_use_decode_demux;
104 uint8_t m_decode_demux_num;
106 eDVBServicePMTHandler();
107 ~eDVBServicePMTHandler();
112 eDVBServicePMTHandler();
118 eventNoResources, // a requested resource couldn't be allocated
119 eventTuneFailed, // tune failed
120 eventNoPAT, // no pat could be received (timeout)
121 eventNoPATEntry, // no pat entry for the corresponding SID could be found
122 eventNoPMT, // no pmt could be received (timeout)
123 eventNewProgramInfo, // we just received a PMT
124 eventTuned, // a channel was sucessfully (re-)tuned in, you may start additional filters now
126 eventPreStart, // before start filepush thread
127 eventSOF, // seek pre start
128 eventEOF, // a file playback did end
130 eventMisconfiguration, // a channel was not found in any list, or no frontend was found which could provide this channel
133 Signal1<void,int> serviceEvent;
139 enum { vtMPEG2, vtMPEG4_H264, vtMPEG1, vtMPEG4_Part2, vtVC1, vtVC1_SM };
146 rdsPid; // hack for some radio services which transmit radiotext on different pid (i.e. harmony fm, HIT RADIO FFH, ...)
147 enum { atMPEG, atAC3, atDTS, atAAC, atAACHE, atLPCM };
148 int type; // mpeg2, ac3, dts, ...
151 std::string language_code; /* iso-639, if available. */
154 struct subtitleStream
157 int subtitling_type; /* see ETSI EN 300 468 table 26 component_type
158 when stream_content is 0x03
159 0x10..0x13, 0x20..0x23 is used for dvb subtitles
160 0x01 is used for teletext subtitles */
163 int composition_page_id; // used for dvb subtitles
164 int teletext_page_number; // used for teletext subtitles
168 int ancillary_page_id; // used for dvb subtitles
169 int teletext_magazine_number; // used for teletext subtitles
171 std::string language_code;
172 bool operator<(const subtitleStream &s) const
176 if (teletext_page_number != s.teletext_page_number)
177 return teletext_page_number < s.teletext_page_number;
178 return teletext_magazine_number < s.teletext_magazine_number;
184 std::vector<videoStream> videoStreams;
185 std::vector<audioStream> audioStreams;
186 int defaultAudioStream;
187 std::vector<subtitleStream> subtitleStreams;
188 std::set<uint16_t> caids;
192 bool isCrypted() { return !caids.empty(); }
193 PyObject *createPythonObject();
196 int getProgramInfo(struct program &program);
197 int getDataDemux(ePtr<iDVBDemux> &demux);
198 int getDecodeDemux(ePtr<iDVBDemux> &demux);
199 PyObject *getCaIds();
201 int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
202 int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; }
203 int getService(ePtr<eDVBService> &service) { service = m_service; return 0; }
204 int getPMT(ePtr<eTable<ProgramMapSection> > &ptr) { return m_PMT.getCurrent(ptr); }
205 int getChannel(eUsePtr<iDVBChannel> &channel);
206 void resetCachedProgram() { m_have_cached_program = false; }
208 int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0);
211 bool m_have_cached_program;
212 program m_cached_program;