4 #include <lib/base/message.h>
5 #include <lib/service/iservice.h>
6 #include <lib/dvb/pmt.h>
7 #include <lib/dvb/subtitle.h>
8 #include <lib/dvb/teletext.h>
11 #include <lib/gui/esubtitle.h>
13 class eStaticServiceMP3Info;
15 class eSubtitleWidget;
17 class eServiceFactoryMP3: public iServiceHandler
19 DECLARE_REF(eServiceFactoryMP3);
22 virtual ~eServiceFactoryMP3();
26 RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
27 RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
28 RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
29 RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
30 RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
32 ePtr<eStaticServiceMP3Info> m_service_info;
35 class eStaticServiceMP3Info: public iStaticServiceInformation
37 DECLARE_REF(eStaticServiceMP3Info);
38 friend class eServiceFactoryMP3;
39 eStaticServiceMP3Info();
41 RESULT getName(const eServiceReference &ref, std::string &name);
42 int getLength(const eServiceReference &ref);
43 int getInfo(const eServiceReference &ref, int w);
46 typedef struct _GstElement GstElement;
48 typedef enum { atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC } audiotype_t;
49 typedef enum { stUnknown, stPlainText, stSSA, stASS, stSRT, stVOB, stPGS } subtype_t;
50 typedef enum { ctNone, ctMPEGTS, ctMPEGPS, ctMKV, ctAVI, ctMP4, ctVCD, ctCDA } containertype_t;
54 ePangoSubtitlePage *pango_page;
55 eVobSubtitlePage *vob_page;
58 class eServiceMP3: public iPlayableService, public iPauseableService,
59 public iServiceInformation, public iSeekableService, public iAudioTrackSelection, public iAudioChannelSelection,
60 public iSubtitleOutput, public iStreamedService, public iAudioDelay, public Object
62 DECLARE_REF(eServiceMP3);
64 virtual ~eServiceMP3();
67 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
70 RESULT setTarget(int target);
72 RESULT pause(ePtr<iPauseableService> &ptr);
73 RESULT setSlowMotion(int ratio);
74 RESULT setFastForward(int ratio);
76 RESULT seek(ePtr<iSeekableService> &ptr);
77 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
78 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
79 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
80 RESULT audioDelay(ePtr<iAudioDelay> &ptr);
82 // not implemented (yet)
83 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
84 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
85 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
86 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
88 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
89 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
90 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
96 RESULT info(ePtr<iServiceInformation>&);
99 RESULT getLength(pts_t &SWIG_OUTPUT);
100 RESULT seekTo(pts_t to);
101 RESULT seekRelative(int direction, pts_t to);
102 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
103 RESULT setTrickmode(int trick);
104 RESULT isCurrentlySeekable();
106 // iServiceInformation
107 RESULT getName(std::string &name);
109 std::string getInfoString(int w);
110 PyObject *getInfoObject(int w);
112 // iAudioTrackSelection
113 int getNumberOfTracks();
114 RESULT selectTrack(unsigned int i);
115 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
116 int getCurrentTrack();
118 // iAudioChannelSelection
119 int getCurrentChannel();
120 RESULT selectChannel(int i);
123 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
124 RESULT disableSubtitles(eWidget *parent);
125 PyObject *getSubtitleList();
126 PyObject *getCachedSubtitle();
129 RESULT streamed(ePtr<iStreamedService> &ptr);
130 PyObject *getBufferCharge();
131 int setBufferSize(int size);
136 void setAC3Delay(int);
137 void setPCMDelay(int);
143 std::string language_code; /* iso-639, if available. */
144 std::string codec; /* clear text codec description */
146 :pad(0), type(atUnknown)
150 struct subtitleStream
154 std::string language_code; /* iso-639, if available. */
162 audiotype_t audiotype;
163 containertype_t containertype;
167 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
176 long long bufferingLeft;
178 :bufferPercent(0), avgInRate(0), avgOutRate(0), bufferingLeft(-1)
183 static int pcm_delay;
184 static int ac3_delay;
185 int m_currentAudioStream;
186 int m_currentSubtitleStream;
187 int selectAudioStream(int i);
188 std::vector<audioStream> m_audioStreams;
189 std::vector<subtitleStream> m_subtitleStreams;
190 eSubtitleWidget *m_subtitle_widget;
191 int m_currentTrickRatio;
192 ePtr<eTimer> m_seekTimeout;
193 void seekTimeoutCB();
194 friend class eServiceFactoryMP3;
195 eServiceReference m_ref;
197 bufferInfo m_bufferInfo;
198 eServiceMP3(eServiceReference ref);
199 Signal2<void,iPlayableService*,int> m_event;
202 stIdle, stRunning, stStopped,
205 GstElement *m_gst_playbin;
206 GstElement *m_gst_subtitlebin;
207 GstTagList *m_stream_tags;
208 eFixedMessagePump<int> m_pump;
209 std::string m_error_message;
211 audiotype_t gstCheckAudioPad(GstStructure* structure);
212 void gstBusCall(GstBus *bus, GstMessage *msg);
213 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
214 static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data);
215 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
216 static GstCaps* gstGhostpadGetCAPS (GstPad * pad);
217 static gboolean gstGhostpadAcceptCAPS(GstPad * pad, GstCaps * caps);
218 static void gstGhostpadLink(gpointer user_data, GstCaps * caps);
219 static GstFlowReturn gstGhostpadBufferAlloc(GstPad *pad, guint64 offset, guint size, GstCaps *caps, GstBuffer **buf);
220 static void gstGhostpadHasCAPS(GstPad *pad, GParamSpec * unused, gpointer user_data);
221 static gboolean gstGhostpadSinkEvent(GstPad * pad, GstEvent * event);
222 static GstFlowReturn gstGhostpadChainFunction(GstPad * pad, GstBuffer * buffer);
223 /* static void gstCBsubtitleCAPS(GObject *obj, GParamSpec *pspec, gpointer user_data);
224 static void gstCBsubtitleLink(subtype_t type, gpointer user_data);
225 static gboolean gstCBsubtitleDrop(GstPad *pad, GstBuffer *buffer, gpointer user_data);*/
226 void gstPoll(const int&);
227 GstPadBufferAllocFunction m_ghost_pad_buffer_alloc;
228 GstPadChainFunction m_ghost_pad_chain_function;
229 GstPadEventFunction m_ghost_pad_subtitle_sink_event;
230 GstCaps *m_gst_prev_subtitle_caps;
231 GstSegment m_gst_subtitle_segment;
232 GstPadEventFunction m_gst_sink_event;
234 std::list<SubtitlePage> m_subtitle_pages;
235 ePtr<eTimer> m_subtitle_sync_timer;
236 ePtr<eTimer> m_subtitle_hide_timer;
237 ePtr<eTimer> m_streamingsrc_timeout;
238 void pushSubtitles();
240 void hideSubtitles();
241 void sourceTimeout();
243 sourceStream m_sourceinfo;
244 eSingleLock m_subs_to_pull_lock;
245 gulong m_subs_to_pull_handler_id;
247 RESULT seekToImpl(pts_t to);
249 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
250 std::string m_useragent;
251 RESULT trickSeek(gdouble ratio);