c730d501c6ce06e647d9a05cb5b3fba690c7fea4
[enigma2.git] / lib / python / Plugins / Extensions / DVDPlayer / src / servicedvd.h
1 #ifndef __servicedvd_h
2 #define __servicedvd_h
3
4 #include <lib/base/message.h>
5 #include <lib/base/ebase.h>
6 #include <lib/base/thread.h>
7 #include <lib/service/iservice.h>
8
9 class eSubtitleWidget;
10 class gPixmap;
11 class eStaticServiceDVDInfo;
12
13 class eServiceFactoryDVD: public iServiceHandler
14 {
15         DECLARE_REF(eServiceFactoryDVD);
16 public:
17         eServiceFactoryDVD();
18         virtual ~eServiceFactoryDVD();
19         enum { id = 0x1111 };
20
21                 // iServiceHandler
22         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
23         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
24         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
25         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
26         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
27 };
28
29 class eServiceDVD: public iPlayableService, public iPauseableService, public iSeekableService,
30         public iServiceInformation, public iSubtitleOutput, public iServiceKeys, public iCueSheet, public eThread, public Object
31 {
32         friend class eServiceFactoryDVD;
33         DECLARE_REF(eServiceDVD);
34 public:
35         virtual ~eServiceDVD();
36                 // not implemented (yet)
37         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return -1; }
38         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
39         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
40         RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
41         RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
42         RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
43         RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
44         RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
45         RESULT streamed(ePtr<iStreamedService> &ptr) { ptr = 0; return -1; }
46         RESULT cueSheet(ePtr<iCueSheet> &ptr);
47
48                 // iPlayableService
49         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
50         RESULT start();
51         RESULT stop();
52         RESULT setTarget(int target);
53         RESULT info(ePtr<iServiceInformation> &ptr);
54         RESULT pause(ePtr<iPauseableService> &ptr);
55         RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
56         RESULT seek(ePtr<iSeekableService> &ptr);
57         RESULT keys(ePtr<iServiceKeys> &ptr);
58
59                 // iPausableService
60         RESULT pause();
61         RESULT unpause();
62         RESULT setSlowMotion(int ratio);
63         RESULT setFastForward(int ratio);
64
65                 // iSubtitleOutput
66         RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
67         RESULT disableSubtitles(eWidget *parent);
68         PyObject *getSubtitleList();
69         PyObject *getCachedSubtitle();
70
71                 // iSeekableService
72         RESULT getLength(pts_t &len);
73         RESULT seekTo(pts_t to);
74         RESULT seekRelative(int direction, pts_t to);
75         RESULT getPlayPosition(pts_t &pos);
76         RESULT setTrickmode(int trick=0);
77         RESULT isCurrentlySeekable();
78         RESULT seekChapter(int chapter);
79         RESULT seekTitle(int title);
80
81                 // iServiceInformation
82         RESULT getName(std::string &name);
83         int getInfo(int w);
84         std::string getInfoString(int w);
85         virtual PyObject *getInfoObject(int w);
86
87                 // iCueSheet
88         PyObject *getCutList();
89         void setCutList(SWIG_PYOBJECT(ePyObject));
90         void setCutListEnable(int enable);
91
92                 // iServiceKeys
93         RESULT keyPressed(int key);
94 private:
95         eServiceDVD(eServiceReference ref);
96
97         void gotMessage(int); // message from dvdlib
98         void gotThreadMessage(const int &); // message from dvd thread
99
100                 // eThread
101         void thread();
102         void thread_finished();
103
104         eServiceReference m_ref;
105
106         Signal2<void,iPlayableService*,int> m_event;
107
108         struct ddvd *m_ddvdconfig;
109         ePtr<gPixmap> m_pixmap;
110         eSubtitleWidget *m_subtitle_widget;
111
112         enum
113         {
114                 stIdle, stRunning, stMenu, stStopped
115         };
116
117         int m_state;
118         int m_current_trick;
119
120         char m_ddvd_titlestring[96];
121
122         ePtr<eSocketNotifier> m_sn;
123         eFixedMessagePump<int> m_pump;
124
125         pts_t m_cue_pts;
126         struct ddvd_resume m_resume_info;
127
128         void loadCuesheet();
129         void saveCuesheet();
130 };
131
132 #endif