servicemp3.cpp: more simple/flexible streaming detection
[enigma2.git] / lib / dvb / db.h
1 #ifndef __db_h
2 #define __db_h
3
4 #ifndef SWIG
5 #include <lib/dvb/idvb.h>
6 #include <lib/base/eptrlist.h>
7 #include <set>
8 class ServiceDescriptionSection;
9 #endif
10
11 class eDVBDB: public iDVBChannelList
12 {
13         DECLARE_REF(eDVBDB);
14         static eDVBDB *instance;
15         friend class eDVBDBQuery;
16         friend class eDVBDBBouquetQuery;
17         friend class eDVBDBSatellitesQuery;
18         friend class eDVBDBProvidersQuery;
19
20         struct channel
21         {
22                 ePtr<iDVBFrontendParameters> m_frontendParameters;
23         };
24         
25         std::map<eDVBChannelID, channel> m_channels;
26         
27         std::map<eServiceReferenceDVB, ePtr<eDVBService> > m_services;
28         
29         std::map<std::string, eBouquet> m_bouquets;
30 #ifdef SWIG
31         eDVBDB();
32         ~eDVBDB();
33 #endif
34 public:
35 // iDVBChannelList
36         RESULT removeFlags(unsigned int flagmask, int dvb_namespace=-1, int tsid=-1, int onid=-1, unsigned int orb_pos=0xFFFFFFFF);
37         RESULT removeServices(int dvb_namespace=-1, int tsid=-1, int onid=-1, unsigned int orb_pos=0xFFFFFFFF);
38         RESULT removeService(const eServiceReference &service);
39         RESULT addFlag(const eServiceReference &service, unsigned int flagmask);
40         RESULT removeFlag(const eServiceReference &service, unsigned int flagmask);
41         PyObject *readSatellites(SWIG_PYOBJECT(ePyObject) sat_list, SWIG_PYOBJECT(ePyObject) sat_dict, SWIG_PYOBJECT(ePyObject) tp_dict);
42         PyObject *readTerrestrials(SWIG_PYOBJECT(ePyObject) ter_list, SWIG_PYOBJECT(ePyObject) tp_dict);
43         PyObject *readCables(SWIG_PYOBJECT(ePyObject) cab_list, SWIG_PYOBJECT(ePyObject) tp_dict);
44 #ifndef SWIG
45         RESULT removeFlags(unsigned int flagmask, eDVBChannelID chid, unsigned int orb_pos);
46         RESULT removeServices(eDVBChannelID chid, unsigned int orb_pos);
47         RESULT removeServices(iDVBFrontendParameters *feparm);
48
49         RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm);
50         RESULT removeChannel(const eDVBChannelID &id);
51
52         RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm);
53         
54         RESULT addService(const eServiceReferenceDVB &referenc, eDVBService *service);
55         RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service);
56         RESULT flush();
57
58         RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *q, const eServiceReference &source);
59
60         RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet);
61 //////
62         void loadBouquet(const char *path);
63         eServiceReference searchReference(int tsid, int onid, int sid);
64         eDVBDB();
65         virtual ~eDVBDB();
66 #endif
67         void loadServicelist(const char *filename);
68         static eDVBDB *getInstance() { return instance; }
69         void reloadServicelist();
70         void saveServicelist();
71         void saveServicelist(const char *file);
72         void reloadBouquets();
73         void parseServiceData(ePtr<eDVBService> s, std::string str);
74 };
75
76 #ifndef SWIG
77         // we have to add a possibility to invalidate here.
78 class eDVBDBQueryBase: public iDVBChannelListQuery
79 {
80         DECLARE_REF(eDVBDBQueryBase);
81 protected:
82         ePtr<eDVBDB> m_db;
83         ePtr<eDVBChannelQuery> m_query;
84         eServiceReference m_source;
85 public:
86         eDVBDBQueryBase(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
87         virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
88 };
89
90 class eDVBDBQuery: public eDVBDBQueryBase
91 {
92         std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_cursor;
93 public:
94         eDVBDBQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
95         RESULT getNextResult(eServiceReferenceDVB &ref);
96 };
97
98 class eDVBDBBouquetQuery: public eDVBDBQueryBase
99 {
100         std::list<eServiceReference>::iterator m_cursor;
101 public:
102         eDVBDBBouquetQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
103         RESULT getNextResult(eServiceReferenceDVB &ref);
104 };
105
106 class eDVBDBListQuery: public eDVBDBQueryBase
107 {
108 protected:
109         std::list<eServiceReferenceDVB> m_list;
110         std::list<eServiceReferenceDVB>::iterator m_cursor;
111 public:
112         eDVBDBListQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
113         RESULT getNextResult(eServiceReferenceDVB &ref);
114         int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
115 };
116
117 class eDVBDBSatellitesQuery: public eDVBDBListQuery
118 {
119 public:
120         eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
121 };
122
123 class eDVBDBProvidersQuery: public eDVBDBListQuery
124 {
125 public:
126         eDVBDBProvidersQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
127 };
128 #endif // SWIG
129
130 #endif