needed changes for dm800/dm8000 drivers >= 20090720
[enigma2-plugins.git] / vlcplayer / src / servicets / servicets.h
1 /*******************************************************************************
2  VLC Player Plugin by A. Lätsch 2007
3
4  This is free software; you can redistribute it and/or modify it under
5  the terms of the GNU General Public License as published by the Free
6  Software Foundation; either version 2, or (at your option) any later
7  version.
8 ********************************************************************************/
9
10 #ifndef __servicets_h
11 #define __servicets_h
12
13 #include <lib/base/ioprio.h>
14 #include <lib/base/message.h>
15 #include <lib/service/iservice.h>
16 #include <lib/dvb/dvb.h>
17
18 class eStaticServiceTSInfo;
19
20 class eServiceFactoryTS: public iServiceHandler
21 {
22 DECLARE_REF(eServiceFactoryTS);
23 public:
24         eServiceFactoryTS();
25         virtual ~eServiceFactoryTS();
26         enum { id = 0x1002 };
27
28         // iServiceHandler
29         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
30         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
31         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
32         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
33         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
34 };
35
36 class TSAudioInfo {
37 DECLARE_REF(TSAudioInfo);
38 public:
39         struct StreamInfo {
40                 int pid;
41                 int type;
42                 std::string language; /* iso639 */
43                 std::string description;
44         };
45         std::vector<StreamInfo> audioStreams;
46         void addAudio(int pid, std::string lang, std::string desc, int type);
47 };
48
49
50 class eStreamThread;
51 class eServiceTS: public iPlayableService, public iPauseableService,
52         public iServiceInformation, public iSeekableService,
53         public iAudioTrackSelection, public iAudioChannelSelection, public Object
54 {
55 DECLARE_REF(eServiceTS);
56 public:
57         virtual ~eServiceTS();
58
59         // iPlayableService
60         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
61         RESULT start();
62         RESULT stop();
63         RESULT pause(ePtr<iPauseableService> &ptr);
64         RESULT seek(ePtr<iSeekableService> &ptr);
65         RESULT info(ePtr<iServiceInformation>&);
66
67         // not implemented
68         RESULT setTarget(int target) { return -1; };
69         RESULT setSlowMotion(int ratio) { return -1; };
70         RESULT setFastForward(int ratio) { return -1; };
71         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = this; return 0; };
72         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = this; return 0; };
73         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; };
74         RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; };
75         RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; };
76         RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; };
77         RESULT subtitle(ePtr<iSubtitleOutput> &ptr) { ptr = 0; return -1; };
78         RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; };
79         RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; };
80         RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; };
81         RESULT streamed(ePtr<iStreamedService> &ptr) { ptr = 0; return -1; };
82         RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; };
83
84         // iPausableService
85         RESULT pause();
86         RESULT unpause();
87
88         // iSeekableService
89         RESULT getLength(pts_t &SWIG_OUTPUT);
90         RESULT seekTo(pts_t to);
91         RESULT seekRelative(int direction, pts_t to);
92         RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
93         RESULT setTrickmode(int trick);
94         RESULT isCurrentlySeekable();
95
96         // iServiceInformation
97         RESULT getName(std::string &name);
98         int getInfo(int w);
99         std::string getInfoString(int w);
100
101         // iAudioTrackSelection
102         int getNumberOfTracks();
103         RESULT selectTrack(unsigned int i);
104         SWIG_VOID(RESULT) getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
105         int getCurrentTrack();
106
107         // iAudioChannelSelection
108         int getCurrentChannel() { return iAudioChannelSelection_ENUMS::STEREO; };
109         RESULT selectChannel(int i) { return 0; };
110
111 private:
112         friend class eServiceFactoryTS;
113         std::string m_filename;
114         int m_vpid, m_apid;
115         int m_destfd;
116         ePtr<iDVBDemux> m_decodedemux;
117         ePtr<iTSMPEGDecoder> m_decoder;
118         ePtr<eStreamThread> m_streamthread;
119         ePtr<TSAudioInfo> m_audioInfo;
120
121         eServiceTS(const eServiceReference &url);
122         int openHttpConnection(std::string url);
123
124         Signal2<void,iPlayableService*,int> m_event;
125         enum
126         {
127                 stIdle, stRunning, stStopped
128         };
129         int m_state;
130         eFixedMessagePump<int> m_pump;
131         void recv_event(int evt);
132         void setAudioPid(int pid, int type);
133 };
134
135 class eStreamThread: public eThread, public Object {
136 DECLARE_REF(eStreamThread);
137 public:
138         eStreamThread();
139         virtual ~eStreamThread();
140         void start(int srcfd, int destfd);
141         void stop();
142
143         virtual void thread();
144         virtual void thread_finished();
145
146         RESULT getAudioInfo(ePtr<TSAudioInfo> &ptr);
147
148         enum { evtEOS, evtSOS, evtReadError, evtWriteError, evtUser, evtStreamInfo };
149         Signal1<void,int> m_event;
150 private:
151         bool m_stop;
152         int m_srcfd, m_destfd;
153         ePtr<TSAudioInfo> m_audioInfo;
154         eFixedMessagePump<int> m_messagepump;
155         void recvEvent(const int &evt);
156         bool scanAudioInfo(unsigned char buf[], int len);
157         std::string getDescriptor(unsigned char buf[], int buflen, int type);
158 };
159
160 #endif
161
162