1 #ifndef __lib_dvb_iservice_h
2 #define __lib_dvb_iservice_h
4 #include <lib/base/object.h>
6 #include <connection.h>
10 #define TEMPLATE_TYPEDEF(x, y) \
14 #define TEMPLATE_TYPEDEF(x, y) typedef x y
17 class eServiceReference
23 idStructure, // service_id == 0 is root
30 int flags; // flags will NOT be compared.
33 isDirectory=1, // SHOULD enter (implies mustDescent)
34 mustDescent=2, // cannot be played directly - often used with "isDirectory" (implies canDescent)
37 normal services have none of them - they can be fed directly into the "play"-handler.
38 normal directories have both of them set - you cannot play a directory directly and the UI should descent into it.
39 playlists have "mustDescent", but not "isDirectory" - you don't want the user to browse inside the playlist (unless he really wants)
40 services with sub-services have none of them, instead the have the "canDecsent" flag (as all of the above)
42 canDescent=4, // supports enterDirectory/leaveDirectory
43 flagDirectory=isDirectory|mustDescent|canDescent,
44 shouldSort=8, // should be ASCII-sorted according to service_name. great for directories.
45 hasSortKey=16, // has a sort key in data[3]. not having a sort key implies 0.
46 sort1=32 // sort key is 1 instead of 0
49 inline int getSortKey() const { return (flags & hasSortKey) ? data[3] : ((flags & sort1) ? 1 : 0); }
55 : type(idInvalid), flags(0)
59 eServiceReference(int type, int flags)
60 : type(type), flags(flags)
62 memset(data, 0, sizeof(data));
64 eServiceReference(int type, int flags, int data0)
65 : type(type), flags(flags)
67 memset(data, 0, sizeof(data));
70 eServiceReference(int type, int flags, int data0, int data1)
71 : type(type), flags(flags)
73 memset(data, 0, sizeof(data));
77 eServiceReference(int type, int flags, int data0, int data1, int data2)
78 : type(type), flags(flags)
80 memset(data, 0, sizeof(data));
85 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3)
86 : type(type), flags(flags)
88 memset(data, 0, sizeof(data));
94 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3, int data4)
95 : type(type), flags(flags)
97 memset(data, 0, sizeof(data));
104 eServiceReference(int type, int flags, const std::string &path)
105 : type(type), flags(flags), path(path)
107 memset(data, 0, sizeof(data));
109 eServiceReference(const std::string &string);
110 std::string toString() const;
111 bool operator==(const eServiceReference &c) const
115 return /* (flags == c.flags) && */ (memcmp(data, c.data, sizeof(int)*8)==0) && (path == c.path);
117 bool operator!=(const eServiceReference &c) const
119 return !(*this == c);
121 bool operator<(const eServiceReference &c) const
129 /* if (flags < c.flags)
134 int r=memcmp(data, c.data, sizeof(int)*8);
137 return path < c.path;
139 operator bool() const
141 return type != idInvalid;
145 /* the reason we have the servicereference as additional argument is
146 that we don't have to create one object for every entry in a possibly
147 large list, provided that no state information is nessesary to deliver
148 the required information. Anyway - ref *must* be the same as the argument
149 to the info() or getIServiceInformation call! */
150 class iStaticServiceInformation: public iObject
153 virtual RESULT getName(const eServiceReference &ref, std::string &name)=0;
156 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
160 class iServiceInformation: public iStaticServiceInformation
163 virtual RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
166 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
168 class iPauseableService: public iObject
171 virtual RESULT pause()=0;
172 virtual RESULT unpause()=0;
175 TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
177 class iPlayableService: public iObject
179 friend class iServiceHandler;
186 // when iServiceInformation is implemented:
189 virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
190 virtual RESULT start()=0;
191 virtual RESULT stop()=0;
192 virtual RESULT pause(ePtr<iPauseableService> &ptr)=0;
193 virtual RESULT info(ePtr<iServiceInformation> &ptr)=0;
196 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
198 class iRecordableService: public iObject
201 virtual RESULT start()=0;
202 virtual RESULT stop()=0;
205 TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
207 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
209 class iListableService: public iObject
212 virtual RESULT getContent(std::list<eServiceReference> &list)=0;
215 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
217 class iServiceHandler: public iObject
220 virtual RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr)=0;
221 virtual RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr)=0;
222 virtual RESULT list(const eServiceReference &, ePtr<iListableService> &ptr)=0;
223 virtual RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
226 TEMPLATE_TYPEDEF(ePtr<iServiceHandler>, iServiceHandlerPtr);