Merge branch 'enable_experimental_unicable_support' into experimental
[enigma2.git] / lib / service / servicedvbrecord.h
1 #ifndef __servicedvbrecord_h
2 #define __servicedvbrecord_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 <set>
10
11 #include <lib/service/servicedvb.h>
12
13 class eDVBServiceRecord: public eDVBServiceBase,
14         public iRecordableService, 
15         public iStreamableService,
16         public iSubserviceList,
17         public Object
18 {
19         DECLARE_REF(eDVBServiceRecord);
20 public:
21         RESULT connectEvent(const Slot2<void,iRecordableService*,int> &event, ePtr<eConnection> &connection);
22         RESULT prepare(const char *filename, time_t begTime, time_t endTime, int eit_event_id, const char *name, const char *descr, const char *tags);
23         RESULT prepareStreaming();
24         RESULT start(bool simulate=false);
25         RESULT stop();
26         RESULT stream(ePtr<iStreamableService> &ptr);
27         RESULT getError(int &error) { error = m_error; return 0; }
28         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr);
29         RESULT subServices(ePtr<iSubserviceList> &ptr);
30
31                 // iStreamableService
32         PyObject *getStreamingData();
33
34                 // iSubserviceList
35         int getNumberOfSubservices();
36         RESULT getSubservice(eServiceReference &subservice, unsigned int n);
37 private:
38         enum { stateIdle, statePrepared, stateRecording };
39         bool m_simulate;
40         int m_state, m_want_record;
41         friend class eServiceFactoryDVB;
42         eDVBServiceRecord(const eServiceReferenceDVB &ref);
43         
44         eDVBServiceEITHandler m_event_handler;
45         
46         eServiceReferenceDVB m_ref;
47         
48         ePtr<iDVBTSRecorder> m_record;
49         ePtr<eConnection> m_con_record_event;
50         
51         int m_recording, m_tuned, m_error;
52         std::set<int> m_pids_active;
53         std::string m_filename;
54
55         std::map<int,pts_t> m_event_timestamps;
56         int m_target_fd;
57         int m_streaming;
58         int m_last_event_id;
59         
60         int doPrepare();
61         int doRecord();
62
63                         /* events */
64         void serviceEvent(int event);
65         Signal2<void,iRecordableService*,int> m_event;
66         
67                         /* recorder events */
68         void recordEvent(int event);
69
70                         /* eit updates */
71         void gotNewEvent();
72         void saveCutlist();
73 };
74
75 #endif