4.3.0r7
[enigma2.git] / usr / include / enigma2 / lib / hbbtv / hbbtv.h
1 #ifndef __lib_hbbtv_hbbtv_h_
2 #define __lib_hbbtv_hbbtv_h_
3
4 #include "oipfapplication.h"
5
6 #include <lib/base/esignal.h>
7 #include <lib/service/iservice.h>
8 #include <lib/service/event.h>
9
10 #if QT_VERSION >= 0x050000
11 #define HBBTV_USER_AGENT "Mozilla/5.0 (Linux mips; U;HbbTV/1.1.1 (+RTSP;Dream Property GmbH;Dreambox;1.1;1.0;) CE-HTML/1.0; en) AppleWebKit/538.1 no/Volksbox QtWebkit OIPF/1.1";
12 #else
13 #define HBBTV_USER_AGENT "Mozilla/5.0 (Linux mips; U;HbbTV/1.1.1 (+RTSP;Dream Property GmbH;Dreambox;0.1a;1.0;) CE-HTML/1.0; en) AppleWebKit/535.19 no/Volksbox QtWebkit/2.2";
14 #endif
15
16
17 class eDVBServiceAITHandler;
18
19 class eHbbtv : public sigc::trackable
20 {
21         static eHbbtv *instance;
22         bool m_aitSignalsEnabled;
23         int m_streamState;
24         ePtr<eConnection> m_serviceEventConnection;
25         std::list<eServiceReference> m_serviceList;
26         eServiceReference m_currentBouquet;
27         eServiceReference m_currentService;
28         ePtr<iPlayableService> m_playableService;
29         ePtr<eConnection> m_serviceEventConn;
30         eDVBServiceAITHandler *m_aitHandler;
31         std::map< std::string, std::map<std::string, eOipfApplication> >m_applications;
32
33         void aitChanged(int pid);
34         std::vector<std::string> split(const std::string &s, char delim, int limit = 0);
35         void checkApp(const eOipfApplication *app);
36         bool addApplication(const eOipfApplication &app, std::map<std::string, eOipfApplication> *currentServiceApps);
37         bool isStreaming();
38
39 #ifdef SWIG
40         eHbbtv();
41         ~eHbbtv();
42 #endif
43 public:
44 #ifndef SWIG
45         eHbbtv();
46         ~eHbbtv();
47 #endif
48
49         static const int VERSION_MAJOR = 1;
50         static const int VERSION_MINOR = 1;
51         static const int VERSION_MICRO = 1;
52
53         enum EventTypes{
54                 EVENT_NOW = 0,
55                 EVENT_NEXT = 1,
56         };
57
58         enum PlayStates {
59                 BROADCAST_STATE_UNREALIZED = 0,
60                 BROADCAST_STATE_CONNECTING,
61                 BROADCAST_STATE_PRESENTING,
62         };
63
64         enum ChannelErrors{
65                 CHANNEL_ERROR_NOT_SUPPORTED = 0,
66                 CHANNEL_ERROR_TUNE_FAILED,
67                 CHANNEL_ERROR_TUNER_FOREIGN_LOCK,
68                 CHANNEL_ERROR_PARENTAL_LOCK,
69                 CHANNEL_ERROR_CANNOT_DECRYPT,
70                 CHANNEL_ERROR_UNKNOWN,
71                 CHANNEL_ERROR_SWITCH_INTERRUPTED,
72                 CHANNEL_ERROR_LOCKED_BY_RECORD,
73                 CHANNEL_ERROR_RESOLVE_FAILED,
74                 CHANNEL_ERROR_BANDWITH_INSUFFICIENT,
75                 CHANNEL_ERROR_CANNOT_ZAP,
76         };
77
78         enum StreamPlayStates {
79                 STREAM_STATE_STOPPED = 0,
80                 STREAM_STATE_PLAYING,
81                 STREAM_STATE_PAUSED,
82                 STREAM_STATE_CONNECTING,
83                 STREAM_STATE_BUFFERING,
84                 STREAM_STATE_FINISHED,
85                 STREAM_STATE_ERROR,
86         };
87
88         enum StreamErrors {
89                 STREAM_ERROR_NONE = 0,
90                 STREAM_ERROR_UNSUPPORTED,
91                 STREAM_ERROR_CONNECTING,
92                 STREAM_ERROR_UNKNOWN,
93         };
94
95         //python accessible
96         static eHbbtv *getInstance();
97         void setAitSignalsEnabled(bool enabled){ m_aitSignalsEnabled = enabled; };
98         void setServiceList(std::string sref);
99         void setStreamState(int state);
100         const eOipfApplication getApplication(const std::string &id);
101         const std::string resolveApplicationLocator(const std::string &dvbUrl);
102         std::list<std::pair<std::string, std::string> > getApplicationIdsAndName();
103         void pageLoadFinished();
104
105 #ifndef SWIG
106         //C++ only
107         const std::string getCurrentServiceTriplet();
108         const eServiceReference &getCurrentService();
109         void setCurrentService(eServiceReference service, ePtr<iPlayableService> &playableService);
110         void playService(const std::string &sref);
111         void playStream(const std::string &uri);
112         void pauseStream();
113         bool seekStream(pts_t to);
114         void stopStream();
115         void nextService();
116         void prevService();
117         void onCurrentServiceStop();
118         void onCurrentServiceEvent(iPlayableService *playableService, int what);
119         ePtr<iPlayableService> getPlayableService();
120         long getPlayTime();
121         long getPlayPosition();
122         void setVolume(int volume);
123         const std::list<eServiceReference> getServiceList();
124         ePtr<eServiceEvent> getEvent(int nownext);
125         void setVideoWindow(unsigned int x, unsigned int y, unsigned int w, unsigned int h);
126         void unsetVideoWindow();
127         void showCurrent();
128         void hideCurrent();
129         void createApplication(const std::string &uri);
130
131         Signal0<void> currentServiceChanged;
132         Signal1<void, int> serviceChangeError;
133         Signal1<void, int> streamPlayStateChanged;
134         Signal0<void> serviceListChanged;
135         Signal0<void> loadFinished;
136 #endif
137
138         /* void playServiceRequest(std::string); */
139         eSignal1<void, const char *> playServiceRequest;
140         /* void playStreamRequest(std::string); */
141         eSignal1<void, const char *> playStreamRequest;
142         /* void pauseStreamRequest(); */
143         eSignal0<void> pauseStreamRequest;
144         /* void seekStreamRequest(pts_t); */
145         eSignal1<void, pts_t> seekStreamRequest;
146         /* void stopStreamRequest(); */
147         eSignal0<void> stopStreamRequest;
148         /* void nextServiceRequest(); */
149         eSignal0<void> nextServiceRequest;
150         /* void prevServiceRequest(); */
151         eSignal0<void> prevServiceRequest;
152         /* void setVolumeRequest(int); */
153         eSignal1<void, int> setVolumeRequest;
154         /* void setVideoWindowRequest(unsigned int, unsigned int, unsigned int, unsigned int); */
155         eSignal4<void, unsigned int, unsigned int, unsigned int, unsigned int> setVideoWindowRequest;
156         /* void unsetVideoWindowRequest(); */
157         eSignal0<void> unsetVideoWindowRequest;
158         /* void aitInvalidated() */
159         eSignal0<void> aitInvalidated;
160         /* void redButtonAppplicationReady(std::string); */
161         eSignal1<void, const char*> redButtonAppplicationReady;
162         /* void textApplicationReady(std::string); */
163         eSignal1<void, const char*> textApplicationReady;
164         /* void createApplicationRequest(std::string); */
165         eSignal1<void, const char*> createApplicationRequest
166         /* void show() */;
167         eSignal0<void> show;
168         /* void hide() */;
169         eSignal0<void> hide;
170 };
171
172 #endif /* __lib_hbbtv_hbbtv_h_ */