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
27 isDirectory=1, // SHOULD enter (implies mustDescent)
28 mustDescent=2, // cannot be played directly - often used with "isDirectory" (implies canDescent)
31 normal services have none of them - they can be fed directly into the "play"-handler.
32 normal directories have both of them set - you cannot play a directory directly and the UI should descent into it.
33 playlists have "mustDescent", but not "isDirectory" - you don't want the user to browse inside the playlist (unless he really wants)
34 services with sub-services have none of them, instead the have the "canDecsent" flag (as all of the above)
36 canDescent=4, // supports enterDirectory/leaveDirectory
37 flagDirectory=isDirectory|mustDescent|canDescent,
38 shouldSort=8, // should be ASCII-sorted according to service_name. great for directories.
39 hasSortKey=16, // has a sort key in data[3]. not having a sort key implies 0.
40 sort1=32 // sort key is 1 instead of 0
42 int flags; // flags will NOT be compared.
44 inline int getSortKey() const { return (flags & hasSortKey) ? data[3] : ((flags & sort1) ? 1 : 0); }
50 std::string getPath() { return path; }
51 void setPath( const std::string &n ) { path=n; }
53 int getData(unsigned int num) const
55 if ( num < sizeof(data)/sizeof(int) )
60 void setData(unsigned int num, int val)
62 if ( num < sizeof(data)/sizeof(int) )
66 // only for override service names in bouquets or to give servicerefs a name which not have a
67 // real existing service ( for dvb eServiceDVB )
71 std::string getName() { return name; }
72 void setName( const std::string &n ) { name=n; }
75 : type(idInvalid), flags(0)
77 memset(data, 0, sizeof(data));
80 eServiceReference(int type, int flags)
81 : type(type), flags(flags)
83 memset(data, 0, sizeof(data));
85 eServiceReference(int type, int flags, int data0)
86 : type(type), flags(flags)
88 memset(data, 0, sizeof(data));
91 eServiceReference(int type, int flags, int data0, int data1)
92 : type(type), flags(flags)
94 memset(data, 0, sizeof(data));
98 eServiceReference(int type, int flags, int data0, int data1, int data2)
99 : type(type), flags(flags)
101 memset(data, 0, sizeof(data));
106 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3)
107 : type(type), flags(flags)
109 memset(data, 0, sizeof(data));
115 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3, int data4)
116 : type(type), flags(flags)
118 memset(data, 0, sizeof(data));
125 eServiceReference(int type, int flags, const std::string &path)
126 : type(type), flags(flags), path(path)
128 memset(data, 0, sizeof(data));
131 eServiceReference(const std::string &string);
132 std::string toString() const;
133 bool operator==(const eServiceReference &c) const
137 return (memcmp(data, c.data, sizeof(int)*8)==0) && (path == c.path);
139 bool operator!=(const eServiceReference &c) const
141 return !(*this == c);
143 bool operator<(const eServiceReference &c) const
151 int r=memcmp(data, c.data, sizeof(int)*8);
154 return path < c.path;
156 operator bool() const
163 return type != idInvalid;
167 SWIG_ALLOW_OUTPUT_SIMPLE(eServiceReference);
169 typedef long long pts_t;
171 /* the reason we have the servicereference as additional argument is
172 that we don't have to create one object for every entry in a possibly
173 large list, provided that no state information is nessesary to deliver
174 the required information. Anyway - ref *must* be the same as the argument
175 to the info() or getIServiceInformation call! */
177 /* About the usage of SWIG_VOID:
178 SWIG_VOID(real_returntype_t) hides a return value from swig. This is used for
179 the "superflouus" RESULT return values.
181 Python code has to check the returned pointer against 0. This works,
182 as all functions returning instances in smartpointers AND having a
183 RESULT have to BOTH return non-zero AND set the pointer to zero.
185 Python code thus can't check for the reason, but the reason isn't
186 user-servicable anyway. If you want to return a real reason which
187 goes beyong "it just doesn't work", use extra variables for this,
190 Hide the result only if there is another way to check for failure! */
192 class iStaticServiceInformation: public iObject
195 iStaticServiceInformation();
196 ~iStaticServiceInformation();
199 virtual SWIG_VOID(RESULT) getName(const eServiceReference &ref, std::string &SWIG_OUTPUT)=0;
201 // doesn't need to be implemented, should return -1 then.
202 virtual int getLength(const eServiceReference &ref);
203 virtual SWIG_VOID(RESULT) getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT, time_t start_time=-1);
204 // returns true when not implemented
205 virtual bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
207 virtual int getInfo(const eServiceReference &ref, int w);
208 virtual std::string getInfoString(const eServiceReference &ref,int w);
211 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
213 TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr);
215 class iServiceInformation: public iObject
218 iServiceInformation();
219 ~iServiceInformation();
222 virtual SWIG_VOID(RESULT) getName(std::string &SWIG_OUTPUT)=0;
223 virtual SWIG_VOID(RESULT) getEvent(ePtr<eServiceEvent> &SWIG_OUTPUT, int nownext);
226 sIsCrypted, /* is encrypted (no indication if decrypt was possible) */
227 sAspect, /* aspect ratio: 0=4:3, 1=16:9, 2=whatever we need */
228 sIsMultichannel, /* multichannel *available* (probably not selected) */
230 /* "user serviceable info" - they are not reliable. Don't use them for anything except the service menu!
231 that's also the reason why they are so globally defined.
234 again - if somebody EVER tries to use this information for anything else than simply displaying it,
235 i will change this to return a user-readable text like "zero x zero three three" (and change the
236 exact spelling in every version) to stop that!
251 sTimeCreate, // unix time or string
253 enum { resNA = -1, resIsString = -2 };
255 virtual int getInfo(int w);
256 virtual std::string getInfoString(int w);
259 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
261 class iFrontendStatusInformation: public iObject
264 iFrontendStatusInformation();
265 ~iFrontendStatusInformation();
273 virtual int getFrontendInfo(int w)=0;
276 TEMPLATE_TYPEDEF(ePtr<iFrontendStatusInformation>, iFrontendStatusInformationPtr);
278 class iPauseableService: public iObject
285 virtual RESULT pause()=0;
286 virtual RESULT unpause()=0;
289 virtual RESULT setSlowMotion(int ratio=0)=0;
290 virtual RESULT setFastForward(int ratio=0)=0;
293 TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
295 class iSeekableService: public iObject
302 virtual RESULT getLength(pts_t &SWIG_OUTPUT)=0;
303 virtual RESULT seekTo(pts_t to)=0;
304 enum { dirForward = +1, dirBackward = -1 };
305 virtual RESULT seekRelative(int direction, pts_t to)=0;
306 virtual RESULT getPlayPosition(pts_t &SWIG_OUTPUT)=0;
307 /* if you want to do several seeks in a row, you can enable the trickmode.
308 audio will be switched off, sync will be disabled etc. */
309 virtual RESULT setTrickmode(int trick=0)=0;
312 TEMPLATE_TYPEDEF(ePtr<iSeekableService>, iSeekableServicePtr);
314 struct iAudioTrackInfo
323 std::string m_description;
324 std::string m_language; /* iso639 */
326 std::string getDescription() { return m_description; }
327 std::string getLanguage() { return m_language; }
330 SWIG_ALLOW_OUTPUT_SIMPLE(iAudioTrackInfo);
332 class iAudioTrackSelection: public iObject
335 iAudioTrackSelection();
336 ~iAudioTrackSelection();
339 virtual int getNumberOfTracks()=0;
340 virtual RESULT selectTrack(unsigned int i)=0;
341 virtual SWIG_VOID(RESULT) getTrackInfo(struct iAudioTrackInfo &SWIG_OUTPUT, unsigned int n)=0;
344 TEMPLATE_TYPEDEF(ePtr<iAudioTrackSelection>, iAudioTrackSelectionPtr);
346 class iSubserviceList: public iObject
353 virtual int getNumberOfSubservices()=0;
354 virtual SWIG_VOID(RESULT) getSubservice(eServiceReference &SWIG_OUTPUT, unsigned int n)=0;
357 TEMPLATE_TYPEDEF(ePtr<iSubserviceList>, iSubserviceListPtr);
359 class iTimeshiftService: public iObject
363 ~iTimeshiftService();
366 virtual RESULT startTimeshift()=0;
367 virtual RESULT stopTimeshift()=0;
370 TEMPLATE_TYPEDEF(ePtr<iTimeshiftService>, iTimeshiftServicePtr);
372 class iPlayableService: public iObject
378 friend class iServiceHandler;
386 // when iServiceInformation is implemented:
390 virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
391 virtual RESULT start()=0;
392 virtual RESULT stop()=0;
393 virtual SWIG_VOID(RESULT) seek(ePtr<iSeekableService> &SWIG_OUTPUT)=0;
394 virtual SWIG_VOID(RESULT) pause(ePtr<iPauseableService> &SWIG_OUTPUT)=0;
395 virtual SWIG_VOID(RESULT) info(ePtr<iServiceInformation> &SWIG_OUTPUT)=0;
396 virtual SWIG_VOID(RESULT) audioTracks(ePtr<iAudioTrackSelection> &SWIG_OUTPUT)=0;
397 virtual SWIG_VOID(RESULT) subServices(ePtr<iSubserviceList> &SWIG_OUTPUT)=0;
398 virtual SWIG_VOID(RESULT) frontendStatusInfo(ePtr<iFrontendStatusInformation> &SWIG_OUTPUT)=0;
399 virtual SWIG_VOID(RESULT) timeshift(ePtr<iTimeshiftService> &SWIG_OUTPUT)=0;
402 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
404 class iRecordableService: public iObject
407 iRecordableService();
408 ~iRecordableService();
411 virtual RESULT prepare(const char *filename)=0;
412 virtual RESULT start()=0;
413 virtual RESULT stop()=0;
416 TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
418 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
420 class iMutableServiceList: public iObject
423 iMutableServiceList();
424 ~iMutableServiceList();
428 virtual RESULT flushChanges()=0;
429 /* adds a service to a list */
430 virtual RESULT addService(eServiceReference &ref)=0;
431 /* removes a service from a list */
432 virtual RESULT removeService(eServiceReference &ref)=0;
433 /* moves a service in a list, only if list suppports a specific sort method. */
434 /* pos is the new, absolute position from 0..size-1 */
435 virtual RESULT moveService(eServiceReference &ref, int pos)=0;
438 TEMPLATE_TYPEDEF(ePtr<iMutableServiceList>, iMutableServiceListPtr);
440 class iListableService: public iObject
447 /* legacy interface: get a list */
448 virtual RESULT getContent(std::list<eServiceReference> &list)=0;
450 /* new, shiny interface: streaming. */
451 virtual SWIG_VOID(RESULT) getNext(eServiceReference &SWIG_OUTPUT)=0;
453 /* use this for sorting. output is not sorted because of either
454 - performance reasons: the whole list must be buffered or
455 - the interface would be restricted to a list. streaming
456 (as well as a future "active" extension) won't be possible.
458 virtual int compareLessEqual(const eServiceReference &, const eServiceReference &)=0;
460 virtual SWIG_VOID(RESULT) startEdit(ePtr<iMutableServiceList> &SWIG_OUTPUT)=0;
463 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
466 /* a helper class which can be used as argument to stl's sort(). */
467 class iListableServiceCompare
469 ePtr<iListableService> m_list;
471 iListableServiceCompare(iListableService *list): m_list(list) { }
472 bool operator()(const eServiceReference &a, const eServiceReference &b)
474 return m_list->compareLessEqual(a, b);
479 class iServiceOfflineOperations: public iObject
482 iServiceOfflineOperations();
483 ~iServiceOfflineOperations();
486 /* to delete a service, forever. */
487 virtual RESULT deleteFromDisk(int simulate=1)=0;
489 /* for transferring a service... */
490 virtual SWIG_VOID(RESULT) getListOfFilenames(std::list<std::string> &SWIG_OUTPUT)=0;
492 // TODO: additional stuff, like a conversion interface?
495 TEMPLATE_TYPEDEF(ePtr<iServiceOfflineOperations>, iServiceOfflineOperationsPtr);
497 class iServiceHandler: public iObject
504 virtual SWIG_VOID(RESULT) play(const eServiceReference &, ePtr<iPlayableService> &SWIG_OUTPUT)=0;
505 virtual SWIG_VOID(RESULT) record(const eServiceReference &, ePtr<iRecordableService> &SWIG_OUTPUT)=0;
506 virtual SWIG_VOID(RESULT) list(const eServiceReference &, ePtr<iListableService> &SWIG_OUTPUT)=0;
507 virtual SWIG_VOID(RESULT) info(const eServiceReference &, ePtr<iStaticServiceInformation> &SWIG_OUTPUT)=0;
508 virtual SWIG_VOID(RESULT) offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &SWIG_OUTPUT)=0;
511 TEMPLATE_TYPEDEF(ePtr<iServiceHandler>, iServiceHandlerPtr);