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 eventSOF, // seek pre start
127 eventEOF, // a file playback did end
129 eventMisconfiguration, // a channel was not found in any list, or no frontend was found which could provide this channel
132 Signal1<void,int> serviceEvent;
138 enum { vtMPEG2, vtMPEG4_H264, vtMPEG1, vtMPEG4_Part2, vtVC1, vtVC1_SM };
145 enum { atMPEG, atAC3, atDTS, atAAC, atAACHE };
146 int type; // mpeg2, ac3, dts, ...
149 std::string language_code; /* iso-639, if available. */
152 struct subtitleStream
155 int subtitling_type; /* see ETSI EN 300 468 table 26 component_type
156 when stream_content is 0x03
157 0x10..0x13, 0x20..0x23 is used for dvb subtitles
158 0x01 is used for teletext subtitles */
161 int composition_page_id; // used for dvb subtitles
162 int teletext_page_number; // used for teletext subtitles
166 int ancillary_page_id; // used for dvb subtitles
167 int teletext_magazine_number; // used for teletext subtitles
169 std::string language_code;
170 bool operator<(const subtitleStream &s) const
174 if (teletext_page_number != s.teletext_page_number)
175 return teletext_page_number < s.teletext_page_number;
176 return teletext_magazine_number < s.teletext_magazine_number;
182 std::vector<videoStream> videoStreams;
183 std::vector<audioStream> audioStreams;
184 int defaultAudioStream;
185 std::vector<subtitleStream> subtitleStreams;
186 std::set<uint16_t> caids;
190 bool isCrypted() { return !caids.empty(); }
192 PyObject *createPythonObject();
195 int getProgramInfo(struct program &program);
196 int getDataDemux(ePtr<iDVBDemux> &demux);
197 int getDecodeDemux(ePtr<iDVBDemux> &demux);
198 PyObject *getCaIds();
200 int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
201 int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; }
202 int getService(ePtr<eDVBService> &service) { service = m_service; return 0; }
203 int getPMT(ePtr<eTable<ProgramMapSection> > &ptr) { return m_PMT.getCurrent(ptr); }
204 int getChannel(eUsePtr<iDVBChannel> &channel);
205 void resetCachedProgram() { m_have_cached_program = false; }
207 int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0);
210 bool m_have_cached_program;
211 program m_cached_program;