add servicets.so sources
[enigma2-plugins.git] / vlcplayer / src / servicets / servicets.h
1 #ifndef __servicets_h
2 #define __servicets_h
3
4 #include <lib/base/ioprio.h>
5 #include <lib/base/message.h>
6 #include <lib/service/iservice.h>
7 #include <lib/dvb/dvb.h>
8
9 class eStaticServiceTSInfo;
10
11 class eServiceFactoryTS: public iServiceHandler
12 {
13 DECLARE_REF(eServiceFactoryTS);
14 public:
15         eServiceFactoryTS();
16         virtual ~eServiceFactoryTS();
17         enum { id = 0x1002 };
18
19         // iServiceHandler
20         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
21         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
22         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
23         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
24         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
25 private:
26         ePtr<eStaticServiceTSInfo> m_service_info;
27 };
28
29 class eStaticServiceTSInfo: public iStaticServiceInformation
30 {
31         DECLARE_REF(eStaticServiceTSInfo);
32         friend class eServiceFactoryTS;
33         eStaticServiceTSInfo();
34 public:
35         RESULT getName(const eServiceReference &ref, std::string &name);
36         int getLength(const eServiceReference &ref);
37 };
38
39 class eStreamThread;
40
41 class eServiceTS: public iPlayableService, public iPauseableService, 
42         public iServiceInformation, public iSeekableService, public Object
43 {
44 DECLARE_REF(eServiceTS);
45 public:
46         virtual ~eServiceTS();
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         
54         RESULT pause(ePtr<iPauseableService> &ptr);
55         RESULT setSlowMotion(int ratio);
56         RESULT setFastForward(int ratio);
57
58         RESULT seek(ePtr<iSeekableService> &ptr);
59
60                 // not implemented (yet)
61         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return -1; }
62         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
63         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
64         RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
65         RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
66         RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
67         RESULT subtitle(ePtr<iSubtitleOutput> &ptr) { ptr = 0; return -1; }
68         RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
69         RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
70         RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
71         RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
72                 // iPausableService
73         RESULT pause();
74         RESULT unpause();
75         
76         RESULT info(ePtr<iServiceInformation>&);
77         
78                 // iSeekableService
79         RESULT getLength(pts_t &SWIG_OUTPUT);
80         RESULT seekTo(pts_t to);
81         RESULT seekRelative(int direction, pts_t to);
82         RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
83         RESULT setTrickmode(int trick);
84         RESULT isCurrentlySeekable();
85
86                 // iServiceInformation
87         RESULT getName(std::string &name);
88         int getInfo(int w);
89         std::string getInfoString(int w);
90 private:
91         friend class eServiceFactoryTS;
92         std::string m_filename;
93         int m_vpid, m_apid;
94         int m_srcfd, m_destfd;
95         ePtr<eDVBAllocatedDemux> m_decodedemux;
96         ePtr<iTSMPEGDecoder> m_decoder;
97         ePtr<eStreamThread> m_streamthread;
98         
99         eServiceTS(const eServiceReference &url);
100         int openHttpConnection(std::string url);
101         
102         Signal2<void,iPlayableService*,int> m_event;
103         enum
104         {
105                 stIdle, stRunning, stStopped
106         };
107         int m_state;
108         eFixedMessagePump<int> m_pump;
109         void recv_event(int evt);
110 };
111
112 class eStreamThread: public eThread, public Object {
113 DECLARE_REF(eStreamThread);
114 public:
115         eStreamThread();
116         virtual ~eStreamThread();
117         void start(int srcfd, int destfd);
118         void stop();
119
120         virtual void thread();
121         virtual void thread_finished();
122
123         enum { evtEOS, evtReadError, evtWriteError, evtUser };
124         Signal1<void,int> m_event;
125 private:
126         bool m_stop;
127         int m_srcfd, m_destfd;
128         eFixedMessagePump<int> m_messagepump;
129         void recvEvent(const int &evt);
130 };
131
132 #endif
133
134