#ifndef __lib_dvb_iservice_h #define __lib_dvb_iservice_h #include #include #include class eServiceReference { public: enum { idInvalid=-1, idStructure, // service_id == 0 is root idDVB, idFile, idUser=0x1000 }; int type; int flags; // flags will NOT be compared. enum { isDirectory=1, // SHOULD enter (implies mustDescent) mustDescent=2, // cannot be played directly - often used with "isDirectory" (implies canDescent) /* for example: normal services have none of them - they can be fed directly into the "play"-handler. normal directories have both of them set - you cannot play a directory directly and the UI should descent into it. playlists have "mustDescent", but not "isDirectory" - you don't want the user to browse inside the playlist (unless he really wants) services with sub-services have none of them, instead the have the "canDecsent" flag (as all of the above) */ canDescent=4, // supports enterDirectory/leaveDirectory flagDirectory=isDirectory|mustDescent|canDescent, shouldSort=8, // should be ASCII-sorted according to service_name. great for directories. hasSortKey=16, // has a sort key in data[3]. not having a sort key implies 0. sort1=32 // sort key is 1 instead of 0 }; inline int getSortKey() const { return (flags & hasSortKey) ? data[3] : ((flags & sort1) ? 1 : 0); } int data[8]; eString path; eServiceReference() : type(idInvalid), flags(0) { } eServiceReference(int type, int flags) : type(type), flags(flags) { memset(data, 0, sizeof(data)); } eServiceReference(int type, int flags, int data0) : type(type), flags(flags) { memset(data, 0, sizeof(data)); data[0]=data0; } eServiceReference(int type, int flags, int data0, int data1) : type(type), flags(flags) { memset(data, 0, sizeof(data)); data[0]=data0; data[1]=data1; } eServiceReference(int type, int flags, int data0, int data1, int data2) : type(type), flags(flags) { memset(data, 0, sizeof(data)); data[0]=data0; data[1]=data1; data[2]=data2; } eServiceReference(int type, int flags, int data0, int data1, int data2, int data3) : type(type), flags(flags) { memset(data, 0, sizeof(data)); data[0]=data0; data[1]=data1; data[2]=data2; data[3]=data3; } eServiceReference(int type, int flags, int data0, int data1, int data2, int data3, int data4) : type(type), flags(flags) { memset(data, 0, sizeof(data)); data[0]=data0; data[1]=data1; data[2]=data2; data[3]=data3; data[4]=data4; } eServiceReference(int type, int flags, const eString &path) : type(type), flags(flags), path(path) { memset(data, 0, sizeof(data)); } eServiceReference(const eString &string); eString toString() const; bool operator==(const eServiceReference &c) const { if (type != c.type) return 0; return /* (flags == c.flags) && */ (memcmp(data, c.data, sizeof(int)*8)==0) && (path == c.path); } bool operator!=(const eServiceReference &c) const { return !(*this == c); } bool operator<(const eServiceReference &c) const { if (type < c.type) return 1; if (type > c.type) return 0; /* if (flags < c.flags) return 1; if (flags > c.flags) return 0; */ int r=memcmp(data, c.data, sizeof(int)*8); if (r) return r < 0; return path < c.path; } operator bool() const { return type != idInvalid; } }; class iPauseableService: public virtual iObject { public: virtual RESULT pause()=0; virtual RESULT unpause()=0; }; class iPlayableService: public virtual iObject { friend class iServiceHandler; public: // it's PRIVATE to the class factory virtual RESULT start()=0; virtual RESULT getIPausableService(ePtr &ptr)=0; }; class iRecordableService: public virtual iObject { public: virtual RESULT start()=0; virtual RESULT stop()=0; }; class iListableService: public virtual iObject { public: virtual RESULT getContent(std::list &list)=0; }; class iServiceHandler: public virtual iObject { public: virtual RESULT play(const eServiceReference &, ePtr &ptr)=0; virtual RESULT record(const eServiceReference &, ePtr &ptr)=0; virtual RESULT list(const eServiceReference &, ePtr &ptr)=0; }; #endif