do not store default values in cache
[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 #include <lib/dvb/teletext.h>
10 #include <lib/base/filepush.h>
11
12 class eServiceFactoryDVB: public iServiceHandler
13 {
14 DECLARE_REF(eServiceFactoryDVB);
15 public:
16         eServiceFactoryDVB();
17         virtual ~eServiceFactoryDVB();
18         enum { id = 0x1 };
19
20                 // iServiceHandler
21         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
22         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
23         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
24         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
25         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
26 private:
27         RESULT lookupService(ePtr<eDVBService> &ptr, const eServiceReference &ref);
28 };
29
30 class eBouquet;
31
32 class eDVBServiceList: public iListableService, public iMutableServiceList
33 {
34 DECLARE_REF(eDVBServiceList);
35 public:
36         virtual ~eDVBServiceList();
37         PyObject *getContent(const char* formatstr, bool sorted=false);
38         RESULT getContent(std::list<eServiceReference> &list, bool sorted=false);
39         RESULT getNext(eServiceReference &ptr);
40         int compareLessEqual(const eServiceReference &a, const eServiceReference &b);
41         
42         RESULT startEdit(ePtr<iMutableServiceList> &);
43         RESULT flushChanges();
44         RESULT addService(eServiceReference &ref);
45         RESULT removeService(eServiceReference &ref);
46         RESULT moveService(eServiceReference &ref, int pos);
47         RESULT setListName(const std::string &name);
48 private:
49         RESULT startQuery();
50         eServiceReference m_parent;
51         friend class eServiceFactoryDVB;
52         eDVBServiceList(const eServiceReference &parent);
53         ePtr<iDVBChannelListQuery> m_query;
54         
55                 /* for editing purposes. WARNING: lifetime issue! */
56         eBouquet *m_bouquet;
57 };
58
59 class eDVBServicePlay: public iPlayableService, public iPauseableService, 
60                 public iSeekableService, public Object, public iServiceInformation, 
61                 public iAudioTrackSelection, public iAudioChannelSelection,
62                 public iFrontendStatusInformation,
63                 public iSubserviceList, public iTimeshiftService,
64                 public iCueSheet
65 {
66 DECLARE_REF(eDVBServicePlay);
67 public:
68         virtual ~eDVBServicePlay();
69
70                 // iPlayableService
71         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
72         RESULT start();
73         RESULT stop();
74         RESULT setTarget(int target);
75         
76         RESULT seek(ePtr<iSeekableService> &ptr);
77         RESULT pause(ePtr<iPauseableService> &ptr);
78         RESULT info(ePtr<iServiceInformation> &ptr);
79         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
80         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
81         RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr);
82         RESULT subServices(ePtr<iSubserviceList> &ptr);
83         RESULT timeshift(ePtr<iTimeshiftService> &ptr);
84         RESULT cueSheet(ePtr<iCueSheet> &ptr);
85
86                 // iPauseableService
87         RESULT pause();
88         RESULT unpause();
89         RESULT setSlowMotion(int ratio);
90         RESULT setFastForward(int ratio);
91         
92                 // iSeekableService
93         RESULT getLength(pts_t &len);
94         RESULT seekTo(pts_t to);
95         RESULT seekRelative(int direction, pts_t to);
96         RESULT getPlayPosition(pts_t &pos);
97         RESULT setTrickmode(int trick=0);
98         RESULT isCurrentlySeekable();
99
100                 // iServiceInformation
101         RESULT getName(std::string &name);
102         RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
103         int getInfo(int w);
104         std::string getInfoString(int w);
105         PyObject *getInfoObject(int w);
106
107                 // iAudioTrackSelection 
108         int getNumberOfTracks();
109         RESULT selectTrack(unsigned int i);
110         RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
111
112                 // iAudioChannelSelection       
113         int getCurrentChannel();
114         RESULT selectChannel(int i);
115
116                 // iFrontendStatusInformation
117         int getFrontendInfo(int w);
118         PyObject *getFrontendData(bool);
119
120                 // iSubserviceList
121         int getNumberOfSubservices();
122         RESULT getSubservice(eServiceReference &subservice, unsigned int n);
123
124                 // iTimeshiftService
125         RESULT startTimeshift();
126         RESULT stopTimeshift();
127         int isTimeshiftActive();
128         RESULT activateTimeshift();
129
130                 // iCueSheet
131         PyObject *getCutList();
132         void setCutList(PyObject *);
133         void setCutListEnable(int enable);
134         
135 private:
136         friend class eServiceFactoryDVB;
137         eServiceReference m_reference;
138         
139         ePtr<eDVBService> m_dvb_service;
140         
141         ePtr<iTSMPEGDecoder> m_decoder;
142         int m_is_primary;
143         
144                 /* in timeshift mode, we essentially have two channels, and thus pmt handlers. */
145         eDVBServicePMTHandler m_service_handler, m_service_handler_timeshift;
146         eDVBServiceEITHandler m_event_handler;
147         
148         eDVBServicePlay(const eServiceReference &ref, eDVBService *service);
149         
150                 /* events */
151         void gotNewEvent();
152         
153         void serviceEvent(int event);
154         void serviceEventTimeshift(int event);
155         Signal2<void,iPlayableService*,int> m_event;
156         
157                 /* pvr */
158         int m_is_pvr, m_is_paused, m_timeshift_enabled, m_timeshift_active;
159         int m_first_program_info;
160         
161         std::string m_timeshift_file;
162         int m_timeshift_fd;
163         
164         ePtr<iDVBDemux> m_decode_demux;
165         
166         int m_current_audio_stream;
167         int selectAudioStream(int n);
168         
169                 /* timeshift */
170         ePtr<iDVBTSRecorder> m_record;
171         std::set<int> m_pids_active;
172
173         void updateTimeshiftPids();
174         void switchToLive();
175         void switchToTimeshift();
176         
177         void updateDecoder();
178         
179         int m_skipmode;
180         
181                 /* cuesheet */
182         
183         ePtr<eCueSheet> m_cue;
184         
185         struct cueEntry
186         {
187                 pts_t where;
188                 unsigned int what;
189                 
190                 bool operator < (const struct cueEntry &o) const
191                 {
192                         return where < o.where;
193                 }
194                 cueEntry(const pts_t &where, unsigned int what) :
195                         where(where), what(what)
196                 {
197                 }
198         };
199         
200         std::multiset<cueEntry> m_cue_entries;
201         int m_cuesheet_changed, m_cutlist_enabled;
202         
203         void loadCuesheet();
204         void saveCuesheet();
205         
206         void cutlistToCuesheet();
207         
208                 /* teletext subtitles */
209         ePtr<eDVBTeletextParser> m_teletext_parser;
210 };
211
212 #endif