1 /*******************************************************************************
2 VLC Player Plugin by A. Lätsch 2007
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
8 ********************************************************************************/
10 #ifndef __servicewebts_h
11 #define __servicewebts_h
13 #include <lib/base/ioprio.h>
14 #include <lib/base/message.h>
15 #include <lib/service/iservice.h>
16 #include <lib/dvb/dvb.h>
22 #define PRIVATE_STREAM1 0xBD
23 #define PRIVATE_STREAM2 0xBF
25 #define AUDIO_STREAM_S 0xC0
26 #define AUDIO_STREAM_E 0xDF
28 #define VIDEO_STREAM_S 0xE0
29 #define VIDEO_STREAM_E 0xEF
34 #define PID_MASK_HI 0x1F
43 class eStaticServiceWebTSInfo;
45 class eServiceFactoryWebTS: public iServiceHandler
47 DECLARE_REF(eServiceFactoryWebTS);
49 eServiceFactoryWebTS();
50 virtual ~eServiceFactoryWebTS();
54 RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
55 RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
56 RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
57 RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
58 RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
61 class TSAudioInfoWeb {
62 DECLARE_REF(TSAudioInfoWeb);
67 std::string language; /* iso639 */
68 std::string description;
70 std::vector<StreamInfo> audioStreams;
71 void addAudio(int pid, std::string lang, std::string desc, int type);
75 class eStreamThreadWeb;
76 class eServiceWebTS: public iPlayableService, public iPauseableService,
77 public iServiceInformation, public iSeekableService,
78 public iAudioTrackSelection, public iAudioChannelSelection, public Object
80 DECLARE_REF(eServiceWebTS);
82 virtual ~eServiceWebTS();
85 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
88 RESULT pause(ePtr<iPauseableService> &ptr);
89 RESULT seek(ePtr<iSeekableService> &ptr);
90 RESULT info(ePtr<iServiceInformation>&);
93 RESULT setTarget(int target) { return -1; };
94 RESULT setSlowMotion(int ratio) { return -1; };
95 RESULT setFastForward(int ratio) { return -1; };
96 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = this; return 0; };
97 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = this; return 0; };
98 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; };
99 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; };
100 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; };
101 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; };
102 RESULT subtitle(ePtr<iSubtitleOutput> &ptr) { ptr = 0; return -1; };
103 RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; };
104 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; };
105 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; };
106 RESULT streamed(ePtr<iStreamedService> &ptr) { ptr = 0; return -1; };
107 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; };
115 RESULT getLength(pts_t &SWIG_OUTPUT);
116 RESULT seekTo(pts_t to);
117 RESULT seekRelative(int direction, pts_t to);
118 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
119 RESULT setTrickmode(int trick);
120 RESULT isCurrentlySeekable();
122 // iServiceInformation
123 RESULT getName(std::string &name);
125 std::string getInfoString(int w);
127 // iAudioTrackSelection
128 int getNumberOfTracks();
129 RESULT selectTrack(unsigned int i);
130 SWIG_VOID(RESULT) getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
131 int getCurrentTrack();
133 // iAudioChannelSelection
134 int getCurrentChannel() { return iAudioChannelSelection_ENUMS::STEREO; };
135 RESULT selectChannel(int i) { return 0; };
138 friend class eServiceFactoryWebTS;
139 std::string m_filename;
141 int m_srcfd, m_destfd;
142 ePtr<iDVBDemux> m_decodedemux;
143 ePtr<iTSMPEGDecoder> m_decoder;
144 ePtr<eStreamThreadWeb> m_streamthread;
145 ePtr<TSAudioInfoWeb> m_audioInfo;
147 eServiceWebTS(const eServiceReference &url);
148 int openHttpConnection(std::string url);
150 Signal2<void,iPlayableService*,int> m_event;
153 stIdle, stRunning, stStopped
156 eFixedMessagePump<int> m_pump;
157 void recv_event(int evt);
158 void setAudioPid(int pid, int type);
161 class eStreamThreadWeb: public eThread, public Object {
162 DECLARE_REF(eStreamThreadWeb);
165 virtual ~eStreamThreadWeb();
166 void start(int srcfd, int destfd);
169 virtual void thread();
170 virtual void thread_finished();
172 RESULT getAudioInfo(ePtr<TSAudioInfoWeb> &ptr);
174 enum { evtEOS, evtSOS, evtReadError, evtWriteError, evtUser, evtStreamInfo };
175 Signal1<void,int> m_event;
178 int m_srcfd, m_destfd;
179 ePtr<TSAudioInfoWeb> m_audioInfo;
180 eFixedMessagePump<int> m_messagepump;
181 void recvEvent(const int &evt);
182 bool scanAudioInfo(unsigned char buf[], int len);
183 std::string getDescriptor(unsigned char buf[], int buflen, int type);