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 virtual SWIG_VOID(RESULT) getName(const eServiceReference &ref, std::string &SWIG_OUTPUT)=0;
197 // doesn't need to be implemented, should return -1 then.
198 virtual int getLength(const eServiceReference &ref);
199 virtual SWIG_VOID(RESULT) getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT, time_t start_time=0);
200 // returns true when not implemented
201 virtual bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
203 virtual int getInfo(const eServiceReference &ref, int w);
204 virtual std::string getInfoString(const eServiceReference &ref,int w);
207 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
209 TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr);
211 class iServiceInformation: public iObject
214 virtual SWIG_VOID(RESULT) getName(std::string &SWIG_OUTPUT)=0;
215 virtual SWIG_VOID(RESULT) getEvent(ePtr<eServiceEvent> &SWIG_OUTPUT, int nownext);
218 sIsCrypted, /* is encrypted (no indication if decrypt was possible) */
219 sAspect, /* aspect ratio: 0=4:3, 1=16:9, 2=whatever we need */
220 sIsMultichannel, /* multichannel *available* (probably not selected) */
222 /* "user serviceable info" - they are not reliable. Don't use them for anything except the service menu!
223 that's also the reason why they are so globally defined.
226 again - if somebody EVER tries to use this information for anything else than simply displaying it,
227 i will change this to return a user-readable text like "zero x zero three three" (and change the
228 exact spelling in every version) to stop that!
243 sTimeCreate, // unix time or string
245 enum { resNA = -1, resIsString = -2 };
247 virtual int getInfo(int w);
248 virtual std::string getInfoString(int w);
251 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
253 class iFrontendStatusInformation: public iObject
261 virtual int getFrontendInfo(int w)=0;
264 TEMPLATE_TYPEDEF(ePtr<iFrontendStatusInformation>, iFrontendStatusInformationPtr);
266 class iPauseableService: public iObject
269 virtual RESULT pause()=0;
270 virtual RESULT unpause()=0;
273 virtual RESULT setSlowMotion(int ratio=0)=0;
274 virtual RESULT setFastForward(int ratio=0)=0;
277 TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
279 class iSeekableService: public iObject
282 virtual RESULT getLength(pts_t &SWIG_OUTPUT)=0;
283 virtual RESULT seekTo(pts_t to)=0;
284 enum { dirForward = +1, dirBackward = -1 };
285 virtual RESULT seekRelative(int direction, pts_t to)=0;
286 virtual RESULT getPlayPosition(pts_t &SWIG_OUTPUT)=0;
287 /* if you want to do several seeks in a row, you can enable the trickmode.
288 audio will be switched off, sync will be disabled etc. */
289 virtual RESULT setTrickmode(int trick=0)=0;
292 TEMPLATE_TYPEDEF(ePtr<iSeekableService>, iSeekableServicePtr);
294 struct iAudioTrackInfo
297 std::string m_description;
298 std::string m_language; /* iso639 */
300 std::string getDescription() { return m_description; }
301 std::string getLanguage() { return m_language; }
304 SWIG_ALLOW_OUTPUT_SIMPLE(iAudioTrackInfo);
306 class iAudioTrackSelection: public iObject
309 virtual int getNumberOfTracks()=0;
310 virtual RESULT selectTrack(unsigned int i)=0;
311 virtual SWIG_VOID(RESULT) getTrackInfo(struct iAudioTrackInfo &SWIG_OUTPUT, unsigned int n)=0;
314 TEMPLATE_TYPEDEF(ePtr<iAudioTrackSelection>, iAudioTrackSelectionPtr);
316 class iSubserviceList: public iObject
319 virtual int getNumberOfSubservices()=0;
320 virtual SWIG_VOID(RESULT) getSubservice(eServiceReference &SWIG_OUTPUT, unsigned int n)=0;
323 TEMPLATE_TYPEDEF(ePtr<iSubserviceList>, iSubserviceListPtr);
325 class iTimeshiftService: public iObject
328 virtual RESULT startTimeshift()=0;
329 virtual RESULT stopTimeshift()=0;
332 TEMPLATE_TYPEDEF(ePtr<iTimeshiftService>, iTimeshiftServicePtr);
334 class iPlayableService: public iObject
336 friend class iServiceHandler;
344 // when iServiceInformation is implemented:
348 virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
349 virtual RESULT start()=0;
350 virtual RESULT stop()=0;
351 virtual SWIG_VOID(RESULT) seek(ePtr<iSeekableService> &SWIG_OUTPUT)=0;
352 virtual SWIG_VOID(RESULT) pause(ePtr<iPauseableService> &SWIG_OUTPUT)=0;
353 virtual SWIG_VOID(RESULT) info(ePtr<iServiceInformation> &SWIG_OUTPUT)=0;
354 virtual SWIG_VOID(RESULT) audioTracks(ePtr<iAudioTrackSelection> &SWIG_OUTPUT)=0;
355 virtual SWIG_VOID(RESULT) subServices(ePtr<iSubserviceList> &SWIG_OUTPUT)=0;
356 virtual SWIG_VOID(RESULT) frontendStatusInfo(ePtr<iFrontendStatusInformation> &SWIG_OUTPUT)=0;
357 virtual SWIG_VOID(RESULT) timeshift(ePtr<iTimeshiftService> &SWIG_OUTPUT)=0;
360 TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
362 class iRecordableService: public iObject
365 virtual RESULT prepare(const char *filename)=0;
366 virtual RESULT start()=0;
367 virtual RESULT stop()=0;
370 TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
372 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
374 class iMutableServiceList: public iObject
378 virtual RESULT flushChanges()=0;
379 /* adds a service to a list */
380 virtual RESULT addService(eServiceReference &ref)=0;
381 /* removes a service from a list */
382 virtual RESULT removeService(eServiceReference &ref)=0;
383 /* moves a service in a list, only if list suppports a specific sort method. */
384 /* pos is the new, absolute position from 0..size-1 */
385 virtual RESULT moveService(eServiceReference &ref, int pos)=0;
388 TEMPLATE_TYPEDEF(ePtr<iMutableServiceList>, iMutableServiceListPtr);
390 class iListableService: public iObject
393 /* legacy interface: get a list */
394 virtual RESULT getContent(std::list<eServiceReference> &list)=0;
396 /* new, shiny interface: streaming. */
397 virtual SWIG_VOID(RESULT) getNext(eServiceReference &SWIG_OUTPUT)=0;
399 /* use this for sorting. output is not sorted because of either
400 - performance reasons: the whole list must be buffered or
401 - the interface would be restricted to a list. streaming
402 (as well as a future "active" extension) won't be possible.
404 virtual int compareLessEqual(const eServiceReference &, const eServiceReference &)=0;
406 virtual SWIG_VOID(RESULT) startEdit(ePtr<iMutableServiceList> &SWIG_OUTPUT)=0;
409 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
411 /* a helper class which can be used as argument to stl's sort(). */
412 class iListableServiceCompare
414 ePtr<iListableService> m_list;
416 iListableServiceCompare(iListableService *list): m_list(list) { }
417 bool operator()(const eServiceReference &a, const eServiceReference &b)
419 return m_list->compareLessEqual(a, b);
423 class iServiceOfflineOperations: public iObject
426 /* to delete a service, forever. */
427 virtual RESULT deleteFromDisk(int simulate=1)=0;
429 /* for transferring a service... */
430 virtual SWIG_VOID(RESULT) getListOfFilenames(std::list<std::string> &SWIG_OUTPUT)=0;
432 // TODO: additional stuff, like a conversion interface?
435 TEMPLATE_TYPEDEF(ePtr<iServiceOfflineOperations>, iServiceOfflineOperationsPtr);
437 class iServiceHandler: public iObject
440 virtual SWIG_VOID(RESULT) play(const eServiceReference &, ePtr<iPlayableService> &SWIG_OUTPUT)=0;
441 virtual SWIG_VOID(RESULT) record(const eServiceReference &, ePtr<iRecordableService> &SWIG_OUTPUT)=0;
442 virtual SWIG_VOID(RESULT) list(const eServiceReference &, ePtr<iListableService> &SWIG_OUTPUT)=0;
443 virtual SWIG_VOID(RESULT) info(const eServiceReference &, ePtr<iStaticServiceInformation> &SWIG_OUTPUT)=0;
444 virtual SWIG_VOID(RESULT) offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &SWIG_OUTPUT)=0;
447 TEMPLATE_TYPEDEF(ePtr<iServiceHandler>, iServiceHandlerPtr);