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