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