track changing filesizes
[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/base/filepush.h>
10
11 class eServiceFactoryDVB: public iServiceHandler
12 {
13 DECLARE_REF(eServiceFactoryDVB);
14 public:
15         eServiceFactoryDVB();
16         virtual ~eServiceFactoryDVB();
17         enum { id = 0x1 };
18
19                 // iServiceHandler
20         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
21         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
22         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
23         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
24         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
25 private:
26         RESULT lookupService(ePtr<eDVBService> &ptr, const eServiceReference &ref);
27 };
28
29 class eBouquet;
30
31 class eDVBServiceList: public iListableService, public iMutableServiceList
32 {
33 DECLARE_REF(eDVBServiceList);
34 public:
35         virtual ~eDVBServiceList();
36         RESULT getContent(std::list<eServiceReference> &list, bool sorted=false);
37         RESULT getContent(PyObject *list, bool sorted=false);
38         RESULT getNext(eServiceReference &ptr);
39         int compareLessEqual(const eServiceReference &a, const eServiceReference &b);
40         
41         RESULT startEdit(ePtr<iMutableServiceList> &);
42         RESULT flushChanges();
43         RESULT addService(eServiceReference &ref);
44         RESULT removeService(eServiceReference &ref);
45         RESULT moveService(eServiceReference &ref, int pos);
46         RESULT setListName(const std::string &name);
47 private:
48         RESULT startQuery();
49         eServiceReference m_parent;
50         friend class eServiceFactoryDVB;
51         eDVBServiceList(const eServiceReference &parent);
52         ePtr<iDVBChannelListQuery> m_query;
53         
54                 /* for editing purposes. WARNING: lifetime issue! */
55         eBouquet *m_bouquet;
56 };
57
58 class eDVBServicePlay: public iPlayableService, public iPauseableService, 
59                 public iSeekableService, public Object, public iServiceInformation, 
60                 public iAudioTrackSelection, public iFrontendStatusInformation,
61                 public iSubserviceList, public iTimeshiftService
62 {
63 DECLARE_REF(eDVBServicePlay);
64 public:
65         virtual ~eDVBServicePlay();
66
67                 // iPlayableService
68         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
69         RESULT start();
70         RESULT stop();
71         RESULT seek(ePtr<iSeekableService> &ptr);
72         RESULT pause(ePtr<iPauseableService> &ptr);
73         RESULT info(ePtr<iServiceInformation> &ptr);
74         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
75         RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr);
76         RESULT subServices(ePtr<iSubserviceList> &ptr);
77         RESULT timeshift(ePtr<iTimeshiftService> &ptr);
78
79                 // iPauseableService
80         RESULT pause();
81         RESULT unpause();
82         RESULT setSlowMotion(int ratio);
83         RESULT setFastForward(int ratio);
84         
85                 // iSeekableService
86         RESULT getLength(pts_t &len);
87         RESULT seekTo(pts_t to);
88         RESULT seekRelative(int direction, pts_t to);
89         RESULT getPlayPosition(pts_t &pos);
90         RESULT setTrickmode(int trick=0);
91
92                 // iServiceInformation
93         RESULT getName(std::string &name);
94         RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
95         int getInfo(int w);
96         std::string getInfoString(int w);
97
98                 // iAudioTrackSelection 
99         int getNumberOfTracks();
100         RESULT selectTrack(unsigned int i);
101         RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
102
103                 // iFrontendStatusInformation
104         int getFrontendInfo(int w);
105
106                 // iSubserviceList
107         int getNumberOfSubservices();
108         RESULT getSubservice(eServiceReference &subservice, unsigned int n);
109
110                 // iTimeshiftService
111         RESULT startTimeshift();
112         RESULT stopTimeshift();
113         int isTimeshiftActive();
114         RESULT activateTimeshift();
115
116 private:
117         friend class eServiceFactoryDVB;
118         eServiceReference m_reference;
119         
120         ePtr<eDVBService> m_dvb_service;
121         
122         ePtr<iTSMPEGDecoder> m_decoder;
123         
124                 /* in timeshift mode, we essentially have two channels, and thus pmt handlers. */
125         eDVBServicePMTHandler m_service_handler, m_service_handler_timeshift;
126         eDVBServiceEITHandler m_event_handler;
127         
128         eDVBServicePlay(const eServiceReference &ref, eDVBService *service);
129         
130         void gotNewEvent();
131         
132         void serviceEvent(int event);
133         void serviceEventTimeshift(int event);
134         Signal2<void,iPlayableService*,int> m_event;
135         
136         int m_is_pvr, m_is_paused, m_timeshift_enabled, m_timeshift_active;
137         
138         std::string m_timeshift_file;
139         int m_timeshift_fd;
140         
141         ePtr<iDVBDemux> m_decode_demux;
142         
143         int m_current_audio_stream;
144         int selectAudioStream(int n);
145         
146         ePtr<iDVBTSRecorder> m_record;
147         std::set<int> m_pids_active;
148
149         void updateTimeshiftPids();
150         void switchToLive();
151         void switchToTimeshift();
152         
153         void updateDecoder();
154         
155         int m_skipmode;
156         
157         ePtr<eCueSheet> m_cue;
158 };
159
160 #endif