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>
12 class eServiceReference
18 idStructure, // service_id == 0 is root
25 int flags; // flags will NOT be compared.
28 isDirectory=1, // SHOULD enter (implies mustDescent)
29 mustDescent=2, // cannot be played directly - often used with "isDirectory" (implies canDescent)
32 normal services have none of them - they can be fed directly into the "play"-handler.
33 normal directories have both of them set - you cannot play a directory directly and the UI should descent into it.
34 playlists have "mustDescent", but not "isDirectory" - you don't want the user to browse inside the playlist (unless he really wants)
35 services with sub-services have none of them, instead the have the "canDecsent" flag (as all of the above)
37 canDescent=4, // supports enterDirectory/leaveDirectory
38 flagDirectory=isDirectory|mustDescent|canDescent,
39 shouldSort=8, // should be ASCII-sorted according to service_name. great for directories.
40 hasSortKey=16, // has a sort key in data[3]. not having a sort key implies 0.
41 sort1=32 // sort key is 1 instead of 0
44 inline int getSortKey() const { return (flags & hasSortKey) ? data[3] : ((flags & sort1) ? 1 : 0); }
48 std::string getPath() { return path; }
50 // only for override service names in bouquets or to give servicerefs a name which not have a
51 // real existing service ( for dvb eServiceDVB )
53 std::string getName() { return name; }
55 void setName( const std::string &n ) { name=n; }
58 : type(idInvalid), flags(0)
60 memset(data, 0, sizeof(data));
62 eServiceReference(int type, int flags)
63 : type(type), flags(flags)
65 memset(data, 0, sizeof(data));
67 eServiceReference(int type, int flags, int data0)
68 : type(type), flags(flags)
70 memset(data, 0, sizeof(data));
73 eServiceReference(int type, int flags, int data0, int data1)
74 : type(type), flags(flags)
76 memset(data, 0, sizeof(data));
80 eServiceReference(int type, int flags, int data0, int data1, int data2)
81 : type(type), flags(flags)
83 memset(data, 0, sizeof(data));
88 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3)
89 : type(type), flags(flags)
91 memset(data, 0, sizeof(data));
97 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3, int data4)
98 : type(type), flags(flags)
100 memset(data, 0, sizeof(data));
107 eServiceReference(int type, int flags, const std::string &path)
108 : type(type), flags(flags), path(path)
110 memset(data, 0, sizeof(data));
112 eServiceReference(const std::string &string);
113 std::string toString() const;
114 bool operator==(const eServiceReference &c) const
118 return (memcmp(data, c.data, sizeof(int)*8)==0) && (path == c.path);
120 bool operator!=(const eServiceReference &c) const
122 return !(*this == c);
124 bool operator<(const eServiceReference &c) const
132 int r=memcmp(data, c.data, sizeof(int)*8);
135 return path < c.path;
137 operator bool() const
144 return type != idInvalid;
148 SWIG_ALLOW_OUTPUT_SIMPLE(eServiceReference);
150 typedef long long pts_t;
152 /* the reason we have the servicereference as additional argument is
153 that we don't have to create one object for every entry in a possibly
154 large list, provided that no state information is nessesary to deliver
155 the required information. Anyway - ref *must* be the same as the argument
156 to the info() or getIServiceInformation call! */
158 /* About the usage of SWIG_VOID:
159 SWIG_VOID(real_returntype_t) hides a return value from swig. This is used for
160 the "superflouus" RESULT return values.
162 Python code has to check the returned pointer against 0. This works,
163 as all functions returning instances in smartpointers AND having a
164 RESULT have to BOTH return non-zero AND set the pointer to zero.
166 Python code thus can't check for the reason, but the reason isn't
167 user-servicable anyway. If you want to return a real reason which
168 goes beyong "it just doesn't work", use extra variables for this,
171 Hide the result only if there is another way to check for failure! */
173 class iStaticServiceInformation: public iObject
176 virtual SWIG_VOID(RESULT) getName(const eServiceReference &ref, std::string &SWIG_OUTPUT)=0;
178 // doesn't need to be implemented, should return -1 then.
179 virtual int getLength(const eServiceReference &ref);
180 virtual SWIG_VOID(RESULT) getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT, time_t start_time=0);
181 // returns true when not implemented
182 virtual bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
184 virtual int getInfo(const eServiceReference &ref, int w);
185 virtual std::string getInfoString(const eServiceReference &ref,int w);
188 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
190 TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr);
192 class iServiceInformation: public iObject
195 virtual SWIG_VOID(RESULT) getName(std::string &SWIG_OUTPUT)=0;
196 virtual SWIG_VOID(RESULT) getEvent(ePtr<eServiceEvent> &SWIG_OUTPUT, int nownext);
199 sIsCrypted, /* is encrypted (no indication if decrypt was possible) */
200 sAspect, /* aspect ratio: 0=4:3, 1=16:9, 2=whatever we need */
201 sIsMultichannel, /* multichannel *available* (probably not selected) */
203 /* "user serviceable info" - they are not reliable. Don't use them for anything except the service menu!
204 that's also the reason why they are so globally defined.
207 again - if somebody EVER tries to use this information for anything else than simply displaying it,
208 i will change this to return a user-readable text like "zero x zero three three" (and change the
209 exact spelling in every version) to stop that!
224 sTimeCreate, // unix time or string
226 enum { resNA = -1, resIsString = -2 };
228 virtual int getInfo(int w);
229 virtual std::string getInfoString(int w);
232 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
234 class iFrontendStatusInformation: public iObject
242 virtual int getFrontendInfo(int w)=0;
245 TEMPLATE_TYPEDEF(ePtr<iFrontendStatusInformation>, iFrontendStatusInformationPtr);
247 class iPauseableService: public iObject
250 virtual RESULT pause()=0;
251 virtual RESULT unpause()=0;
254 virtual RESULT setSlowMotion(int ratio=0)=0;
255 virtual RESULT setFastForward(int ratio=0)=0;
258 TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
260 class iSeekableService: public iObject
263 virtual RESULT getLength(pts_t &SWIG_OUTPUT)=0;
264 virtual RESULT seekTo(pts_t to)=0;
265 enum { dirForward = +1, dirBackward = -1 };
266 virtual RESULT seekRelative(int direction, pts_t to)=0;
267 virtual RESULT getPlayPosition(pts_t &SWIG_OUTPUT)=0;
270 TEMPLATE_TYPEDEF(ePtr<iSeekableService>, iSeekableServicePtr);
272 struct iAudioTrackInfo
274 std::string m_description;
275 std::string m_language; /* iso639 */
277 std::string getDescription() { return m_description; }
278 std::string getLanguage() { return m_language; }
281 SWIG_ALLOW_OUTPUT_SIMPLE(iAudioTrackInfo);
283 class iAudioTrackSelection: public iObject
286 virtual int getNumberOfTracks()=0;
287 virtual RESULT selectTrack(unsigned int i)=0;
288 virtual SWIG_VOID(RESULT) getTrackInfo(struct iAudioTrackInfo &SWIG_OUTPUT, unsigned int n)=0;
291 TEMPLATE_TYPEDEF(ePtr<iAudioTrackSelection>, iAudioTrackSelectionPtr);
293 class iSubserviceList: public iObject
296 virtual int getNumberOfSubservices()=0;
297 virtual SWIG_VOID(RESULT) getSubservice(eServiceReference &SWIG_OUTPUT, unsigned int n)=0;
300 TEMPLATE_TYPEDEF(ePtr<iSubserviceList>, iSubserviceListPtr);
302 class iTimeshiftService: public iObject
305 virtual RESULT startTimeshift()=0;
306 virtual RESULT stopTimeshift()=0;
309 TEMPLATE_TYPEDEF(ePtr<iTimeshiftService>, iTimeshiftServicePtr);
311 class iPlayableService: public iObject
313 friend class iServiceHandler;
321 // when iServiceInformation is implemented:
325 virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
326 virtual RESULT start()=0;
327 virtual RESULT stop()=0;
328 virtual SWIG_VOID(RESULT) seek(ePtr<iSeekableService> &SWIG_OUTPUT)=0;
329 virtual SWIG_VOID(RESULT) pause(ePtr<iPauseableService> &SWIG_OUTPUT)=0;
330 virtual SWIG_VOID(RESULT) info(ePtr<iServiceInformation> &SWIG_OUTPUT)=0;
331 virtual SWIG_VOID(RESULT) audioTracks(ePtr<iAudioTrackSelection> &SWIG_OUTPUT)=0;
332 virtual SWIG_VOID(RESULT) subServices(ePtr<iSubserviceList> &SWIG_OUTPUT)=0;
333 virtual SWIG_VOID(RESULT) frontendStatusInfo(ePtr<iFrontendStatusInformation> &SWIG_OUTPUT)=0;
334 virtual SWIG_VOID(RESULT) timeshift(ePtr<iTimeshiftService> &SWIG_OUTPUT)=0;
337 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
339 class iRecordableService: public iObject
342 virtual RESULT prepare(const char *filename)=0;
343 virtual RESULT start()=0;
344 virtual RESULT stop()=0;
347 TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
349 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
351 class iMutableServiceList: public iObject
355 virtual RESULT flushChanges()=0;
356 /* adds a service to a list */
357 virtual RESULT addService(eServiceReference &ref)=0;
358 /* removes a service from a list */
359 virtual RESULT removeService(eServiceReference &ref)=0;
360 /* moves a service in a list, only if list suppports a specific sort method. */
361 /* pos is the new, absolute position from 0..size-1 */
362 virtual RESULT moveService(eServiceReference &ref, int pos)=0;
365 TEMPLATE_TYPEDEF(ePtr<iMutableServiceList>, iMutableServiceListPtr);
367 class iListableService: public iObject
370 /* legacy interface: get a list */
371 virtual RESULT getContent(std::list<eServiceReference> &list)=0;
373 /* new, shiny interface: streaming. */
374 virtual SWIG_VOID(RESULT) getNext(eServiceReference &SWIG_OUTPUT)=0;
376 /* use this for sorting. output is not sorted because of either
377 - performance reasons: the whole list must be buffered or
378 - the interface would be restricted to a list. streaming
379 (as well as a future "active" extension) won't be possible.
381 virtual int compareLessEqual(const eServiceReference &, const eServiceReference &)=0;
383 virtual SWIG_VOID(RESULT) startEdit(ePtr<iMutableServiceList> &SWIG_OUTPUT)=0;
386 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
388 /* a helper class which can be used as argument to stl's sort(). */
389 class iListableServiceCompare
391 ePtr<iListableService> m_list;
393 iListableServiceCompare(iListableService *list): m_list(list) { }
394 bool operator()(const eServiceReference &a, const eServiceReference &b)
396 return m_list->compareLessEqual(a, b);
400 class iServiceOfflineOperations: public iObject
403 /* to delete a service, forever. */
404 virtual RESULT deleteFromDisk(int simulate=1)=0;
406 /* for transferring a service... */
407 virtual SWIG_VOID(RESULT) getListOfFilenames(std::list<std::string> &SWIG_OUTPUT)=0;
409 // TODO: additional stuff, like a conversion interface?
412 TEMPLATE_TYPEDEF(ePtr<iServiceOfflineOperations>, iServiceOfflineOperationsPtr);
414 class iServiceHandler: public iObject
417 virtual SWIG_VOID(RESULT) play(const eServiceReference &, ePtr<iPlayableService> &SWIG_OUTPUT)=0;
418 virtual SWIG_VOID(RESULT) record(const eServiceReference &, ePtr<iRecordableService> &SWIG_OUTPUT)=0;
419 virtual SWIG_VOID(RESULT) list(const eServiceReference &, ePtr<iListableService> &SWIG_OUTPUT)=0;
420 virtual SWIG_VOID(RESULT) info(const eServiceReference &, ePtr<iStaticServiceInformation> &SWIG_OUTPUT)=0;
421 virtual SWIG_VOID(RESULT) offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &SWIG_OUTPUT)=0;
424 TEMPLATE_TYPEDEF(ePtr<iServiceHandler>, iServiceHandlerPtr);