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 class iServiceInformation: public iObject
148 virtual RESULT getName(std::string &name)=0;
151 typedef ePtr<iServiceInformation> iServiceInformationPtr;
153 class iPauseableService: public iObject
156 virtual RESULT pause()=0;
157 virtual RESULT unpause()=0;
160 typedef ePtr<iPauseableService> iPauseableServicePtr;
162 class iPlayableService: public iObject
164 friend class iServiceHandler;
171 virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
172 virtual RESULT start()=0;
173 virtual RESULT stop()=0;
174 virtual RESULT getIPausableService(ePtr<iPauseableService> &ptr)=0;
175 virtual RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr)=0;
178 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
180 class iRecordableService: public iObject
183 virtual RESULT start()=0;
184 virtual RESULT stop()=0;
187 typedef ePtr<iRecordableService> iRecordableServicePtr;
189 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
190 typedef std::list<eServiceReference> eServiceReferenceList;
192 class iListableService: public iObject
195 virtual RESULT getContent(std::list<eServiceReference> &list)=0;
198 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
200 class iServiceHandler: public iObject
203 virtual RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr)=0;
204 virtual RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr)=0;
205 virtual RESULT list(const eServiceReference &, ePtr<iListableService> &ptr)=0;
208 typedef ePtr<iServiceHandler> iServiceHandlerPtr;