1 #ifndef __lib_dvb_iservice_h
2 #define __lib_dvb_iservice_h
4 #include <lib/python/swig.h>
5 #include <lib/base/object.h>
7 #include <connection.h>
10 class eServiceReference
16 idStructure, // service_id == 0 is root
23 int flags; // flags will NOT be compared.
26 isDirectory=1, // SHOULD enter (implies mustDescent)
27 mustDescent=2, // cannot be played directly - often used with "isDirectory" (implies canDescent)
30 normal services have none of them - they can be fed directly into the "play"-handler.
31 normal directories have both of them set - you cannot play a directory directly and the UI should descent into it.
32 playlists have "mustDescent", but not "isDirectory" - you don't want the user to browse inside the playlist (unless he really wants)
33 services with sub-services have none of them, instead the have the "canDecsent" flag (as all of the above)
35 canDescent=4, // supports enterDirectory/leaveDirectory
36 flagDirectory=isDirectory|mustDescent|canDescent,
37 shouldSort=8, // should be ASCII-sorted according to service_name. great for directories.
38 hasSortKey=16, // has a sort key in data[3]. not having a sort key implies 0.
39 sort1=32 // sort key is 1 instead of 0
42 inline int getSortKey() const { return (flags & hasSortKey) ? data[3] : ((flags & sort1) ? 1 : 0); }
48 : type(idInvalid), flags(0)
52 eServiceReference(int type, int flags)
53 : type(type), flags(flags)
55 memset(data, 0, sizeof(data));
57 eServiceReference(int type, int flags, int data0)
58 : type(type), flags(flags)
60 memset(data, 0, sizeof(data));
63 eServiceReference(int type, int flags, int data0, int data1)
64 : type(type), flags(flags)
66 memset(data, 0, sizeof(data));
70 eServiceReference(int type, int flags, int data0, int data1, int data2)
71 : type(type), flags(flags)
73 memset(data, 0, sizeof(data));
78 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3)
79 : type(type), flags(flags)
81 memset(data, 0, sizeof(data));
87 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3, int data4)
88 : type(type), flags(flags)
90 memset(data, 0, sizeof(data));
97 eServiceReference(int type, int flags, const std::string &path)
98 : type(type), flags(flags), path(path)
100 memset(data, 0, sizeof(data));
102 eServiceReference(const std::string &string);
103 std::string toString() const;
104 bool operator==(const eServiceReference &c) const
108 return /* (flags == c.flags) && */ (memcmp(data, c.data, sizeof(int)*8)==0) && (path == c.path);
110 bool operator!=(const eServiceReference &c) const
112 return !(*this == c);
114 bool operator<(const eServiceReference &c) const
122 /* if (flags < c.flags)
127 int r=memcmp(data, c.data, sizeof(int)*8);
130 return path < c.path;
132 operator bool() const
139 return type != idInvalid;
143 SWIG_ALLOW_OUTPUT_SIMPLE(eServiceReference);
145 typedef unsigned long long pts_t;
147 /* the reason we have the servicereference as additional argument is
148 that we don't have to create one object for every entry in a possibly
149 large list, provided that no state information is nessesary to deliver
150 the required information. Anyway - ref *must* be the same as the argument
151 to the info() or getIServiceInformation call! */
153 /* About the usage of SWIG_VOID:
154 SWIG_VOID(real_returntype_t) hides a return value from swig. This is used for
155 the "superflouus" RESULT return values.
157 Python code has to check the returned pointer against 0. This works,
158 as all functions returning instances in smartpointers AND having a
159 RESULT have to BOTH return non-zero AND set the pointer to zero.
161 Python code thus can't check for the reason, but the reason isn't
162 user-servicable anyway. If you want to return a real reason which
163 goes beyong "it just doesn't work", use extra variables for this,
166 Hide the result only if there is another way to check for failure! */
168 class iStaticServiceInformation: public iObject
171 virtual SWIG_VOID(RESULT) getName(const eServiceReference &ref, std::string &SWIG_OUTPUT)=0;
173 // doesn't need to be implemented, should return -1 then.
174 virtual int getLength(const eServiceReference &ref)=0;
177 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
181 TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr);
183 class iServiceInformation: public iObject
186 virtual SWIG_VOID(RESULT) getName(std::string &SWIG_OUTPUT)=0;
187 virtual SWIG_VOID(RESULT) getEvent(ePtr<eServiceEvent> &SWIG_OUTPUT, int nownext);
190 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
192 class iPauseableService: public iObject
195 virtual RESULT pause()=0;
196 virtual RESULT unpause()=0;
199 TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
201 class iSeekableService: public iObject
204 virtual RESULT getLength(pts_t &SWIG_OUTPUT)=0;
205 virtual RESULT seekTo(pts_t to)=0;
206 virtual RESULT getPlayPosition(pts_t &SWIG_OUTPUT)=0;
209 TEMPLATE_TYPEDEF(ePtr<iSeekableService>, iSeekableServicePtr);
211 class iPlayableService: public iObject
213 friend class iServiceHandler;
220 // when iServiceInformation is implemented:
223 virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
224 virtual RESULT start()=0;
225 virtual RESULT stop()=0;
226 virtual SWIG_VOID(RESULT) seek(ePtr<iSeekableService> &SWIG_OUTPUT)=0;
227 virtual SWIG_VOID(RESULT) pause(ePtr<iPauseableService> &SWIG_OUTPUT)=0;
228 virtual SWIG_VOID(RESULT) info(ePtr<iServiceInformation> &SWIG_OUTPUT)=0;
231 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
233 class iRecordableService: public iObject
236 virtual RESULT prepare()=0;
237 virtual RESULT start()=0;
238 virtual RESULT stop()=0;
241 TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
243 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
245 class iListableService: public iObject
248 /* legacy interface: get a list */
249 virtual RESULT getContent(std::list<eServiceReference> &list)=0;
251 /* new, shiny interface: streaming. */
252 virtual SWIG_VOID(RESULT) getNext(eServiceReference &SWIG_OUTPUT)=0;
255 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
257 class iServiceOfflineOperations: public iObject
260 /* to delete a service, forever. */
261 virtual RESULT deleteFromDisk(int simulate=1)=0;
263 /* for transferring a service... */
264 virtual SWIG_VOID(RESULT) getListOfFilenames(std::list<std::string> &SWIG_OUTPUT)=0;
266 // TODO: additional stuff, like a conversion interface?
269 class iServiceHandler: public iObject
272 virtual SWIG_VOID(RESULT) play(const eServiceReference &, ePtr<iPlayableService> &SWIG_OUTPUT)=0;
273 virtual SWIG_VOID(RESULT) record(const eServiceReference &, ePtr<iRecordableService> &SWIG_OUTPUT)=0;
274 virtual SWIG_VOID(RESULT) list(const eServiceReference &, ePtr<iListableService> &SWIG_OUTPUT)=0;
275 virtual SWIG_VOID(RESULT) info(const eServiceReference &, ePtr<iStaticServiceInformation> &SWIG_OUTPUT)=0;
276 virtual SWIG_VOID(RESULT) offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &SWIG_OUTPUT)=0;
279 TEMPLATE_TYPEDEF(ePtr<iServiceHandler>, iServiceHandlerPtr);