cvs20080628 - trunk
[gitenigma.git] / include / lib / dvb / service.h
blob7f67a5c131d156d0865c1211d5236ff13daedeb1
1 #ifndef __lib_dvb_service_h
2 #define __lib_dvb_service_h
4 #include <map>
5 #include <set>
6 #include <libsig_comp.h>
7 #include <lib/dvb/dvb.h>
9 class eServiceReference;
11 class eServiceEvent
13 public:
14 eServiceEvent(int type, int param): type(type), param(param)
17 eServiceEvent(int type): type(type), param(0)
20 enum
22 evtStop,
23 evtStart,
24 evtPause,
26 evtGotPMT,
27 evtGotSDT,
28 evtGotEIT,
30 evtStatus, // have (new) status
31 evtInfoUpdated, // updated info..
32 evtAddNewAudioStreamId,
34 evtStateChanged,
35 evtFlagsChanged,
37 evtAspectChanged,
39 evtEnd,
41 evtRecordFailed
43 int type;
44 int param;
47 class eServiceCommand
49 public:
50 eServiceCommand(int type): type(type) { }
51 eServiceCommand(int type, int parm): type(type), parm(parm) { }
52 enum
54 cmdRecordOpen,
55 cmdRecordStart,
56 cmdRecordStop,
57 cmdRecordClose,
59 cmdSeekBegin,
60 cmdSeekEnd,
61 cmdSetSpeed, // parm : ratio.. 1 normal, 0 pause, >1 fast forward, <0 reverse (if supported)
62 cmdSkip, // parm : in ms (~)
63 cmdSeekAbsolute, // parm : percentage ~
64 cmdSeekReal, // parm : service specific, as given by queryRealPosition
66 cmdRecordOpenPermanentTimeshift,
67 cmdAddPermanentTimeshiftToRecording
69 int type;
70 int parm;
73 class PMTEntry;
74 class eService;
75 class EIT;
76 class PMT;
77 class SDT;
78 class PMTEntry;
80 class eServiceHandler: public Object
82 protected:
83 int id;
84 static int flags;
85 public:
86 enum
88 flagIsScrambled=1,
89 flagHaveSubservices=2,
90 flagHaveMultipleAudioStreams=4,
91 flagIsSeekable=8, // supports seek commands
92 flagSupportPosition=16, // supports position read
93 flagIsTrack=32, // behaves like an audio track
94 flagStartTimeshift=64
96 enum
98 statePlaying, stateError, stateScrambled, stateStopped, statePause, stateSkipping
100 eServiceHandler(int id);
101 int getID()
103 return id;
105 virtual ~eServiceHandler();
106 virtual eService *createService(const eServiceReference &node);
108 virtual int play(const eServiceReference &service, int workaround=0 );
110 // current service
111 virtual int serviceCommand(const eServiceCommand &cmd);
113 // for DVB audio channels:
114 virtual PMT *getPMT();
115 virtual void setPID(const PMTEntry *);
117 // for DVB nvod channels:
118 virtual SDT *getSDT();
120 // for DVB events, nvod, audio....
121 virtual EIT *getEIT();
123 // for PS MPEG Files
124 virtual void setAudioStream(unsigned int stream_id);
126 static int getFlags();
127 virtual int getState();
129 // get visual flags
130 virtual int getAspectRatio();
132 virtual int getErrorInfo();
134 virtual int stop(int workaround=0);
136 // position query
137 enum {
138 posQueryLength, // query length (in seconds)
139 posQueryCurrent, // query current position
140 posQueryRealLength, // service specific length, e.g. file length in bytes
141 posQueryRealCurrent // service specific current position, e.g. file position in bytes
143 virtual int getPosition(int what); // -1 means: not available
145 // simple "info" functions..
146 virtual eString getInfo(int id); // 0: status, 1+2 upper/lower line :)
148 Signal1<void, const eServiceEvent &> serviceEvent;
150 // service list functions
151 virtual void enterDirectory(const eServiceReference &dir, Signal1<void,const eServiceReference&> &callback);
152 virtual void leaveDirectory(const eServiceReference &dir);
154 virtual eService *addRef(const eServiceReference &service);
155 virtual void removeRef(const eServiceReference &service);
158 class eService;
160 class eServiceInterface: public Object
162 eServiceHandler *currentServiceHandler;
163 std::map<int,eServiceHandler*> handlers;
164 int switchServiceHandler(int id, int workaround=0);
166 SigC::Connection conn;
167 void handleServiceEvent(const eServiceEvent &event);
169 static eServiceInterface *instance;
170 public:
171 eServiceInterface();
172 ~eServiceInterface();
173 static eServiceInterface *getInstance();
175 int registerHandler(int id, eServiceHandler *handler);
176 int unregisterHandler(int id);
177 eServiceHandler *getServiceHandler(int id);
179 int play(const eServiceReference &service);
180 int play(const eServiceReference &service, int workaround );
182 // service related functions
183 Signal1<void,const eServiceEvent &> serviceEvent;
185 eServiceHandler *getService()
187 return currentServiceHandler;
190 int stop(int workaround=0);
192 eServiceReference service;
194 // service list functions
195 void enterDirectory(const eServiceReference &dir, Signal1<void,const eServiceReference&> &callback);
196 void leaveDirectory(const eServiceReference &dir);
198 // stuff for modifiying ...
200 eService *addRef(const eServiceReference &service);
201 void removeRef(const eServiceReference &service);
204 #endif