add ability to get ttxpid from python
[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, public iFrontendStatusInformation,
58                 public iSubserviceList, public iTimeshiftService
59 {
60 DECLARE_REF(eDVBServicePlay);
61 public:
62         virtual ~eDVBServicePlay();
63
64                 // iPlayableService
65         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
66         RESULT start();
67         RESULT stop();
68         RESULT seek(ePtr<iSeekableService> &ptr);
69         RESULT pause(ePtr<iPauseableService> &ptr);
70         RESULT info(ePtr<iServiceInformation> &ptr);
71         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
72         RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr);
73         RESULT subServices(ePtr<iSubserviceList> &ptr);
74         RESULT timeshift(ePtr<iTimeshiftService> &ptr);
75
76                 // iPauseableService
77         RESULT pause();
78         RESULT unpause();
79         RESULT setSlowMotion(int ratio);
80         RESULT setFastForward(int ratio);
81         
82                 // iSeekableService
83         RESULT getLength(pts_t &len);
84         RESULT seekTo(pts_t to);
85         RESULT seekRelative(int direction, pts_t to);
86         RESULT getPlayPosition(pts_t &pos);
87         RESULT setTrickmode(int trick=0);
88
89                 // iServiceInformation
90         RESULT getName(std::string &name);
91         RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
92         int getInfo(int w);
93         std::string getInfoString(int w);
94
95                 // iAudioTrackSelection 
96         int getNumberOfTracks();
97         RESULT selectTrack(unsigned int i);
98         RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
99
100                 // iFrontendStatusInformation
101         int getFrontendInfo(int w);
102
103                 // iSubserviceList
104         int getNumberOfSubservices();
105         RESULT getSubservice(eServiceReference &subservice, unsigned int n);
106
107                 // iTimeshiftService
108         RESULT startTimeshift();
109         RESULT stopTimeshift();
110         int isTimeshiftActive();
111         RESULT activateTimeshift();
112
113 private:
114         friend class eServiceFactoryDVB;
115         eServiceReference m_reference;
116         
117         ePtr<eDVBService> m_dvb_service;
118         
119         ePtr<iTSMPEGDecoder> m_decoder;
120         
121                 /* in timeshift mode, we essentially have two channels, and thus pmt handlers. */
122         eDVBServicePMTHandler m_service_handler, m_service_handler_timeshift;
123         eDVBServiceEITHandler m_event_handler;
124         
125         eDVBServicePlay(const eServiceReference &ref, eDVBService *service);
126         
127         void gotNewEvent();
128         
129         void serviceEvent(int event);
130         void serviceEventTimeshift(int event);
131         Signal2<void,iPlayableService*,int> m_event;
132         
133         int m_is_pvr, m_is_paused, m_timeshift_enabled, m_timeshift_active;
134         
135         std::string m_timeshift_file;
136         int m_timeshift_fd;
137         
138         ePtr<iDVBDemux> m_decode_demux;
139         
140         int m_current_audio_stream;
141         int selectAudioStream(int n);
142         
143         ePtr<iDVBTSRecorder> m_record;
144         std::set<int> m_pids_active;
145
146         void updateTimeshiftPids();
147         void switchToLive();
148         void switchToTimeshift();
149         
150         void updateDecoder();
151 };
152
153 #endif