work on (premiere) subservice selection
[enigma2.git] / lib / service / servicedvb.h
1 #ifndef __servicedvb_h
2 #define __servicedvb_h
3
4 #include <lib/service/iservice.h>
5 #include <lib/dvb/idvb.h>
6
7 #include <lib/dvb/pmt.h>
8 #include <lib/dvb/eit.h>
9
10 class eServiceFactoryDVB: public iServiceHandler
11 {
12 DECLARE_REF(eServiceFactoryDVB);
13 public:
14         eServiceFactoryDVB();
15         virtual ~eServiceFactoryDVB();
16         enum { id = 0x1 };
17
18                 // iServiceHandler
19         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
20         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
21         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
22         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
23         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
24 private:
25         RESULT lookupService(ePtr<eDVBService> &ptr, const eServiceReference &ref);
26 };
27
28 class eBouquet;
29
30 class eDVBServiceList: public iListableService, public iMutableServiceList
31 {
32 DECLARE_REF(eDVBServiceList);
33 public:
34         virtual ~eDVBServiceList();
35         RESULT getContent(std::list<eServiceReference> &list);
36         RESULT getNext(eServiceReference &ptr);
37         int compareLessEqual(const eServiceReference &a, const eServiceReference &b);
38         
39         RESULT startEdit(ePtr<iMutableServiceList> &);
40         RESULT flushChanges();
41         RESULT addService(eServiceReference &ref);
42         RESULT removeService(eServiceReference &ref);
43         RESULT moveService(eServiceReference &ref, int pos);
44 private:
45         RESULT startQuery();
46         eServiceReference m_parent;
47         friend class eServiceFactoryDVB;
48         eDVBServiceList(const eServiceReference &parent);
49         ePtr<iDVBChannelListQuery> m_query;
50         
51                 /* for editing purposes. WARNING: lifetime issue! */
52         eBouquet *m_bouquet;
53 };
54
55 class eDVBServicePlay: public iPlayableService, public iPauseableService, 
56                 public iSeekableService, public Object, public iServiceInformation, 
57                 public iAudioTrackSelection
58 {
59 DECLARE_REF(eDVBServicePlay);
60 public:
61         virtual ~eDVBServicePlay();
62
63                 // iPlayableService
64         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
65         RESULT start();
66         RESULT stop();
67         RESULT seek(ePtr<iSeekableService> &ptr);
68         RESULT pause(ePtr<iPauseableService> &ptr);
69         RESULT info(ePtr<iServiceInformation> &ptr);
70         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
71         
72                 // iPauseableService
73         RESULT pause();
74         RESULT unpause();
75         
76                 // iSeekableService
77         RESULT getLength(pts_t &len);
78         RESULT seekTo(pts_t to);
79         RESULT seekRelative(int direction, pts_t to);
80         RESULT getPlayPosition(pts_t &pos);
81
82                 // iServiceInformation
83         RESULT getName(std::string &name);
84         RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
85         int getInfo(int w);
86         std::string getInfoString(int w);
87
88                 // iAudioTrackSelection 
89         int getNumberOfTracks();
90         RESULT selectTrack(unsigned int i);
91         RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
92
93 private:
94         friend class eServiceFactoryDVB;
95         eServiceReference m_reference;
96         
97         ePtr<eDVBService> m_dvb_service;
98         
99         ePtr<iTSMPEGDecoder> m_decoder;
100         
101         eDVBServicePMTHandler m_service_handler;
102         eDVBServiceEITHandler m_event_handler;
103         
104         eDVBServicePlay(const eServiceReference &ref, eDVBService *service);
105         
106         void gotNewEvent();
107         
108         void serviceEvent(int event);
109         Signal2<void,iPlayableService*,int> m_event;
110         
111         int m_is_pvr, m_is_paused;
112         
113         int m_current_audio_stream;
114         int selectAudioStream(int n);
115 };
116
117 #endif