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); }
47 // only for override service names in bouquets or to give servicerefs a name which not have a
48 // real existing service ( for dvb eServiceDVB )
52 : type(idInvalid), flags(0)
56 eServiceReference(int type, int flags)
57 : type(type), flags(flags)
59 memset(data, 0, sizeof(data));
61 eServiceReference(int type, int flags, int data0)
62 : type(type), flags(flags)
64 memset(data, 0, sizeof(data));
67 eServiceReference(int type, int flags, int data0, int data1)
68 : type(type), flags(flags)
70 memset(data, 0, sizeof(data));
74 eServiceReference(int type, int flags, int data0, int data1, int data2)
75 : type(type), flags(flags)
77 memset(data, 0, sizeof(data));
82 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3)
83 : type(type), flags(flags)
85 memset(data, 0, sizeof(data));
91 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3, int data4)
92 : type(type), flags(flags)
94 memset(data, 0, sizeof(data));
101 eServiceReference(int type, int flags, const std::string &path)
102 : type(type), flags(flags), path(path)
104 memset(data, 0, sizeof(data));
106 eServiceReference(const std::string &string);
107 std::string toString() const;
108 bool operator==(const eServiceReference &c) const
112 return (memcmp(data, c.data, sizeof(int)*8)==0) && (path == c.path);
114 bool operator!=(const eServiceReference &c) const
116 return !(*this == c);
118 bool operator<(const eServiceReference &c) const
126 int r=memcmp(data, c.data, sizeof(int)*8);
129 return path < c.path;
131 operator bool() const
138 return type != idInvalid;
142 SWIG_ALLOW_OUTPUT_SIMPLE(eServiceReference);
144 typedef long long pts_t;
146 /* the reason we have the servicereference as additional argument is
147 that we don't have to create one object for every entry in a possibly
148 large list, provided that no state information is nessesary to deliver
149 the required information. Anyway - ref *must* be the same as the argument
150 to the info() or getIServiceInformation call! */
152 /* About the usage of SWIG_VOID:
153 SWIG_VOID(real_returntype_t) hides a return value from swig. This is used for
154 the "superflouus" RESULT return values.
156 Python code has to check the returned pointer against 0. This works,
157 as all functions returning instances in smartpointers AND having a
158 RESULT have to BOTH return non-zero AND set the pointer to zero.
160 Python code thus can't check for the reason, but the reason isn't
161 user-servicable anyway. If you want to return a real reason which
162 goes beyong "it just doesn't work", use extra variables for this,
165 Hide the result only if there is another way to check for failure! */
167 class iStaticServiceInformation: public iObject
170 virtual SWIG_VOID(RESULT) getName(const eServiceReference &ref, std::string &SWIG_OUTPUT)=0;
172 // doesn't need to be implemented, should return -1 then.
173 virtual int getLength(const eServiceReference &ref)=0;
176 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
180 TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr);
182 class iServiceInformation: public iObject
185 virtual SWIG_VOID(RESULT) getName(std::string &SWIG_OUTPUT)=0;
186 virtual SWIG_VOID(RESULT) getEvent(ePtr<eServiceEvent> &SWIG_OUTPUT, int nownext);
189 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
191 class iPauseableService: public iObject
194 virtual RESULT pause()=0;
195 virtual RESULT unpause()=0;
198 TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
200 class iSeekableService: public iObject
203 virtual RESULT getLength(pts_t &SWIG_OUTPUT)=0;
204 virtual RESULT seekTo(pts_t to)=0;
205 enum { dirForward = +1, dirBackward = -1 };
206 virtual RESULT seekRelative(int direction, pts_t to)=0;
207 virtual RESULT getPlayPosition(pts_t &SWIG_OUTPUT)=0;
210 TEMPLATE_TYPEDEF(ePtr<iSeekableService>, iSeekableServicePtr);
212 struct iAudioTrackInfo
214 std::string m_description;
215 std::string getDescription() { return m_description; }
218 SWIG_ALLOW_OUTPUT_SIMPLE(iAudioTrackInfo);
220 class iAudioTrackSelection: public iObject
223 virtual int getNumberOfTracks()=0;
224 virtual RESULT selectTrack(unsigned int i)=0;
225 virtual SWIG_VOID(RESULT) getTrackInfo(struct iAudioTrackInfo &SWIG_OUTPUT, unsigned int n)=0;
228 TEMPLATE_TYPEDEF(ePtr<iAudioTrackSelection>, iAudioTrackSelectionPtr);
230 class iPlayableService: public iObject
232 friend class iServiceHandler;
240 // when iServiceInformation is implemented:
243 virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
244 virtual RESULT start()=0;
245 virtual RESULT stop()=0;
246 virtual SWIG_VOID(RESULT) seek(ePtr<iSeekableService> &SWIG_OUTPUT)=0;
247 virtual SWIG_VOID(RESULT) pause(ePtr<iPauseableService> &SWIG_OUTPUT)=0;
248 virtual SWIG_VOID(RESULT) info(ePtr<iServiceInformation> &SWIG_OUTPUT)=0;
249 virtual SWIG_VOID(RESULT) audioTracks(ePtr<iAudioTrackSelection> &SWIG_OUTPUT)=0;
252 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
254 class iRecordableService: public iObject
257 virtual RESULT prepare(const char *filename)=0;
258 virtual RESULT start()=0;
259 virtual RESULT stop()=0;
262 TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
264 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
266 class iMutableServiceList: public iObject
270 virtual RESULT flushChanges()=0;
271 /* adds a service to a list */
272 virtual RESULT addService(eServiceReference &ref)=0;
273 /* removes a service from a list */
274 virtual RESULT removeService(eServiceReference &ref)=0;
275 /* moves a service in a list, only if list suppports a specific sort method. */
276 /* pos is the new, absolute position from 0..size-1 */
277 virtual RESULT moveService(eServiceReference &ref, int pos)=0;
280 TEMPLATE_TYPEDEF(ePtr<iMutableServiceList>, iMutableServiceListPtr);
282 class iListableService: public iObject
285 /* legacy interface: get a list */
286 virtual RESULT getContent(std::list<eServiceReference> &list)=0;
288 /* new, shiny interface: streaming. */
289 virtual SWIG_VOID(RESULT) getNext(eServiceReference &SWIG_OUTPUT)=0;
291 /* use this for sorting. output is not sorted because of either
292 - performance reasons: the whole list must be buffered or
293 - the interface would be restricted to a list. streaming
294 (as well as a future "active" extension) won't be possible.
296 virtual int compareLessEqual(const eServiceReference &, const eServiceReference &)=0;
298 virtual SWIG_VOID(RESULT) startEdit(ePtr<iMutableServiceList> &SWIG_OUTPUT)=0;
301 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
303 /* a helper class which can be used as argument to stl's sort(). */
304 class iListableServiceCompare
306 ePtr<iListableService> m_list;
308 iListableServiceCompare(iListableService *list): m_list(list) { }
309 bool operator()(const eServiceReference &a, const eServiceReference &b)
311 return m_list->compareLessEqual(a, b);
315 class iServiceOfflineOperations: public iObject
318 /* to delete a service, forever. */
319 virtual RESULT deleteFromDisk(int simulate=1)=0;
321 /* for transferring a service... */
322 virtual SWIG_VOID(RESULT) getListOfFilenames(std::list<std::string> &SWIG_OUTPUT)=0;
324 // TODO: additional stuff, like a conversion interface?
327 TEMPLATE_TYPEDEF(ePtr<iServiceOfflineOperations>, iServiceOfflineOperationsPtr);
329 class iServiceHandler: public iObject
332 virtual SWIG_VOID(RESULT) play(const eServiceReference &, ePtr<iPlayableService> &SWIG_OUTPUT)=0;
333 virtual SWIG_VOID(RESULT) record(const eServiceReference &, ePtr<iRecordableService> &SWIG_OUTPUT)=0;
334 virtual SWIG_VOID(RESULT) list(const eServiceReference &, ePtr<iListableService> &SWIG_OUTPUT)=0;
335 virtual SWIG_VOID(RESULT) info(const eServiceReference &, ePtr<iStaticServiceInformation> &SWIG_OUTPUT)=0;
336 virtual SWIG_VOID(RESULT) offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &SWIG_OUTPUT)=0;
339 TEMPLATE_TYPEDEF(ePtr<iServiceHandler>, iServiceHandlerPtr);