some cleanup
[enigma2.git] / lib / dvb / dvb.h
1 #ifndef __dvb_dvb_h
2 #define __dvb_dvb_h
3
4 #include <lib/dvb/idvb.h>
5 #include <lib/dvb/demux.h>
6 #include <lib/dvb/frontend.h>
7 #include <connection.h>
8
9 class eDVBChannel;
10
11 class eDVBResourceManager: public virtual iDVBResourceManager
12 {
13         DECLARE_REF;
14         int avail, busy;
15         struct adapter
16         {
17                 eSmartPtrList<eDVBFrontend> fe;
18                 eSmartPtrList<eDVBDemux> demux;
19         };
20         std::multimap<eDVBChannelID,eDVBChannel*> m_active_channels;
21         ePtr<iDVBChannelList> m_list;
22         ePtr<iDVBSatelliteEquipmentControl> m_sec;
23         static eDVBResourceManager *instance;
24 public:
25         eDVBResourceManager();
26         virtual ~eDVBResourceManager();
27         
28         static RESULT getInstance(ePtr<eDVBResourceManager> &ptr) { if (instance) { ptr = instance; return 0; } return -1; }
29         
30         RESULT setChannelList(iDVBChannelList *list);
31         RESULT getChannelList(ePtr<iDVBChannelList> &list);
32         
33         RESULT allocateChannel(const eDVBChannelID &channelid, ePtr<iDVBChannel> &channel);
34         RESULT allocateRawChannel(ePtr<iDVBChannel> &channel);
35         RESULT allocatePVRChannel(int caps);
36         
37         RESULT addChannel(const eDVBChannelID &chid, eDVBChannel *ch);
38         RESULT removeChannel(const eDVBChannelID &chid, eDVBChannel *ch);
39 };
40
41 class eDVBChannel: public virtual iDVBChannel, public virtual eDVBDemux, public Object
42 {
43         ePtr<eDVBFrontend> m_frontend;
44         ePtr<iDVBFrontendParameters> m_current_frontend_parameters;
45         eDVBChannelID m_channel_id;
46         Signal1<void,iDVBChannel*> m_stateChanged;
47         int m_state;
48         ePtr<eDVBResourceManager> m_mgr;
49         
50         void frontendStateChanged(iDVBFrontend*fe);
51         ePtr<eConnection> m_conn_frontendStateChanged;
52 public:
53         eDVBChannel(eDVBResourceManager *mgr, int adapter, int frontend, int demux);
54         virtual ~eDVBChannel();
55
56                 /* only for managed channels */
57         RESULT setChannel(const eDVBChannelID &id);
58         
59         RESULT connectStateChange(const Slot1<void,iDVBChannel*> &stateChange, ePtr<eConnection> &connection);
60         RESULT getState(int &state);
61
62         RESULT setCIRouting(const eDVBCIRouting &routing);
63         RESULT getDemux(ePtr<iDVBDemux> &demux);
64         RESULT getFrontend(ePtr<iDVBFrontend> &frontend);
65 };
66
67 #endif