add DVDPlayer plugin (not final yet)
[vuplus_dvbapp] / 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 #define cue
10
11 class eSubtitleWidget;
12 class gPixmap;
13 class eStaticServiceDVDInfo;
14
15 class eServiceFactoryDVD: public iServiceHandler
16 {
17 DECLARE_REF(eServiceFactoryDVD);
18 public:
19         eServiceFactoryDVD();
20         virtual ~eServiceFactoryDVD();
21         enum { id = 0x1111 };
22
23                 // iServiceHandler
24         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
25         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
26         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
27         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
28         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
29 };
30
31 class eServiceDVD: public iPlayableService, public iPauseableService, public iSeekableService,
32         public iServiceInformation, public iSubtitleOutput, public iServiceKeys, public eThread, public Object
33 #ifdef cue
34 , public iCueSheet
35 #endif
36 {
37         friend class eServiceFactoryDVD;
38 DECLARE_REF(eServiceDVD);
39 public:
40         virtual ~eServiceDVD();
41                 // not implemented (yet)
42         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return -1; }
43         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
44         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
45         RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
46         RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
47         RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
48         RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
49         RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
50 #ifdef cue
51         RESULT cueSheet(ePtr<iCueSheet> &ptr);
52 #else
53         RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
54 #endif
55
56                 // iPlayableService
57         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
58         RESULT start();
59         RESULT stop();
60         RESULT setTarget(int target);
61         RESULT info(ePtr<iServiceInformation> &ptr);
62         RESULT pause(ePtr<iPauseableService> &ptr);
63         RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
64         RESULT seek(ePtr<iSeekableService> &ptr);
65         RESULT keys(ePtr<iServiceKeys> &ptr);
66
67                 // iPausableService
68         RESULT pause();
69         RESULT unpause();
70         RESULT setSlowMotion(int ratio);
71         RESULT setFastForward(int ratio);
72
73                 // iSubtitleOutput
74         RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
75         RESULT disableSubtitles(eWidget *parent);
76         PyObject *getSubtitleList();
77         PyObject *getCachedSubtitle();
78
79 #if 1
80                 // iSeekableService
81         RESULT getLength(pts_t &len);
82         RESULT seekTo(pts_t to);
83         RESULT seekRelative(int direction, pts_t to);
84         RESULT getPlayPosition(pts_t &pos);
85         RESULT setTrickmode(int trick=0);
86         RESULT isCurrentlySeekable();
87         RESULT seekChapter(int chapter);
88 #endif
89
90                 // iServiceInformation
91         RESULT getName(std::string &name);
92         int getInfo(int w);
93         std::string getInfoString(int w);
94         virtual PyObject *getInfoObject(int w);
95
96 #ifdef cue
97                 // iCueSheet
98         PyObject *getCutList();
99         void setCutList(SWIG_PYOBJECT(ePyObject));
100         void setCutListEnable(int enable);
101 #endif
102                 // iServiceKeys
103         RESULT keyPressed(int key);
104 private:
105         eServiceDVD(const char *filename);
106
107         void gotMessage(int); // message from dvdlib
108         void gotThreadMessage(const int &); // message from dvd thread
109
110                 // eThread
111         void thread();
112         void thread_finished();
113
114         std::string m_filename;
115
116         Signal2<void,iPlayableService*,int> m_event;
117
118         struct ddvd *m_ddvdconfig;
119         ePtr<gPixmap> m_pixmap;
120         eSubtitleWidget *m_subtitle_widget;
121
122         enum
123         {
124                 stIdle, stRunning, stStopped,
125         };
126
127         int m_state;
128         int m_current_trick;
129
130         pts_t m_doSeekTo;
131         int m_seekTitle;
132         char m_ddvd_titlestring[96];
133
134         eSocketNotifier m_sn;
135         eFixedMessagePump<int> m_pump;
136
137 #ifdef cue
138 //      ePtr<eCueSheet> m_cue;
139 // 
140 //      struct cueEntry
141 //      {
142 //              pts_t where;
143 //              unsigned int what;
144 //              
145 //              bool operator < (const struct cueEntry &o) const
146 //              {
147 //                      return where < o.where;
148 //              }
149 //              cueEntry(const pts_t &where, unsigned int what) :
150 //                      where(where), what(what)
151 //              {
152 //              }
153 //      };
154         
155 //      std::multiset<cueEntry> m_cue_entries;
156         int m_cuesheet_changed, m_cutlist_enabled;
157         pts_t m_cue_pts;
158         
159         void loadCuesheet();
160         void saveCuesheet();
161         
162 //      void cutlistToCuesheet();
163 #endif
164 };
165
166 #endif