5 #include <lib/base/message.h>
6 #include <lib/service/iservice.h>
7 #include <lib/dvb/pmt.h>
8 #include <lib/dvb/subtitle.h>
9 #include <lib/dvb/teletext.h>
12 #include <lib/gui/esubtitle.h>
14 class eStaticServiceMP3Info;
16 class eSubtitleWidget;
18 class eServiceFactoryMP3: public iServiceHandler
20 DECLARE_REF(eServiceFactoryMP3);
23 virtual ~eServiceFactoryMP3();
27 RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
28 RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
29 RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
30 RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
31 RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
33 ePtr<eStaticServiceMP3Info> m_service_info;
36 class eStaticServiceMP3Info: public iStaticServiceInformation
38 DECLARE_REF(eStaticServiceMP3Info);
39 friend class eServiceFactoryMP3;
40 eStaticServiceMP3Info();
42 RESULT getName(const eServiceReference &ref, std::string &name);
43 int getLength(const eServiceReference &ref);
44 int getInfo(const eServiceReference &ref, int w);
47 typedef struct _GstElement GstElement;
49 typedef enum { atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC } audiotype_t;
50 typedef enum { stUnknown, stPlainText, stSSA, stASS, stSRT, stVOB, stPGS } subtype_t;
51 typedef enum { ctNone, ctMPEGTS, ctMPEGPS, ctMKV, ctAVI, ctMP4, ctVCD, ctCDA } containertype_t;
53 class eServiceMP3: public iPlayableService, public iPauseableService,
54 public iServiceInformation, public iSeekableService, public iAudioTrackSelection, public iAudioChannelSelection,
55 public iSubtitleOutput, public iStreamedService, public iAudioDelay, public Object
57 DECLARE_REF(eServiceMP3);
59 virtual ~eServiceMP3();
62 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
65 RESULT setTarget(int target);
67 RESULT pause(ePtr<iPauseableService> &ptr);
68 RESULT setSlowMotion(int ratio);
69 RESULT setFastForward(int ratio);
71 RESULT seek(ePtr<iSeekableService> &ptr);
72 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
73 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
74 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
75 RESULT audioDelay(ePtr<iAudioDelay> &ptr);
77 // not implemented (yet)
78 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
79 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
80 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
81 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
83 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
84 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
85 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
91 RESULT info(ePtr<iServiceInformation>&);
94 RESULT getLength(pts_t &SWIG_OUTPUT);
95 RESULT seekTo(pts_t to);
96 RESULT seekRelative(int direction, pts_t to);
97 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
98 RESULT setTrickmode(int trick);
99 RESULT isCurrentlySeekable();
101 // iServiceInformation
102 RESULT getName(std::string &name);
104 std::string getInfoString(int w);
105 PyObject *getInfoObject(int w);
107 // iAudioTrackSelection
108 int getNumberOfTracks();
109 RESULT selectTrack(unsigned int i);
110 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
111 int getCurrentTrack();
113 // iAudioChannelSelection
114 int getCurrentChannel();
115 RESULT selectChannel(int i);
118 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
119 RESULT disableSubtitles(eWidget *parent);
120 PyObject *getSubtitleList();
121 PyObject *getCachedSubtitle();
124 RESULT streamed(ePtr<iStreamedService> &ptr);
125 PyObject *getBufferCharge();
126 int setBufferSize(int size);
131 void setAC3Delay(int);
132 void setPCMDelay(int);
138 std::string language_code; /* iso-639, if available. */
139 std::string codec; /* clear text codec description */
141 :pad(0), type(atUnknown)
145 struct subtitleStream
149 std::string language_code; /* iso-639, if available. */
157 audiotype_t audiotype;
158 containertype_t containertype;
162 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
171 long long bufferingLeft;
173 :bufferPercent(0), avgInRate(0), avgOutRate(0), bufferingLeft(-1)
178 static int pcm_delay;
179 static int ac3_delay;
180 int m_currentAudioStream;
181 int m_currentSubtitleStream;
182 int selectAudioStream(int i);
183 std::vector<audioStream> m_audioStreams;
184 std::vector<subtitleStream> m_subtitleStreams;
185 eSubtitleWidget *m_subtitle_widget;
186 int m_currentTrickRatio;
187 ePtr<eTimer> m_seekTimeout;
188 void seekTimeoutCB();
189 friend class eServiceFactoryMP3;
190 eServiceReference m_ref;
192 bufferInfo m_bufferInfo;
193 eServiceMP3(eServiceReference ref);
194 Signal2<void,iPlayableService*,int> m_event;
197 stIdle, stRunning, stStopped,
200 GstElement *m_gst_playbin;
201 GstElement *m_gst_subtitlebin;
202 GstTagList *m_stream_tags;
212 Message(int type, GstPad *pad)
220 GstPad *pad; // for msg type 3
224 eFixedMessagePump<Message> m_pump;
225 std::string m_error_message;
227 audiotype_t gstCheckAudioPad(GstStructure* structure);
228 void gstBusCall(GstBus *bus, GstMessage *msg);
229 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
230 static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data);
231 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
232 static GstCaps* gstGhostpadGetCAPS (GstPad * pad);
233 static gboolean gstGhostpadAcceptCAPS(GstPad * pad, GstCaps * caps);
234 static void gstGhostpadLink(gpointer user_data, GstCaps * caps);
235 static GstFlowReturn gstGhostpadBufferAlloc(GstPad *pad, guint64 offset, guint size, GstCaps *caps, GstBuffer **buf);
236 static void gstGhostpadHasCAPS(GstPad *pad, GParamSpec * unused, gpointer user_data);
237 static gboolean gstGhostpadSinkEvent(GstPad * pad, GstEvent * event);
238 static GstFlowReturn gstGhostpadChainFunction(GstPad * pad, GstBuffer * buffer);
239 /* static void gstCBsubtitleCAPS(GObject *obj, GParamSpec *pspec, gpointer user_data);
240 static void gstCBsubtitleLink(subtype_t type, gpointer user_data);
241 static gboolean gstCBsubtitleDrop(GstPad *pad, GstBuffer *buffer, gpointer user_data);*/
242 void gstPoll(const Message&);
243 void gstGhostpadHasCAPS_synced(GstPad *pad);
245 GstPadBufferAllocFunction m_ghost_pad_buffer_alloc;
246 GstPadChainFunction m_ghost_pad_chain_function;
247 GstPadEventFunction m_ghost_pad_subtitle_sink_event;
248 GstCaps *m_gst_prev_subtitle_caps;
249 GstSegment m_gst_subtitle_segment;
250 GstPadEventFunction m_gst_sink_event;
254 enum { Unknown, Pango, Vob } type;
255 ePangoSubtitlePage pango_page;
256 eVobSubtitlePage vob_page;
259 std::list<SubtitlePage> m_subtitle_pages;
260 ePtr<eTimer> m_subtitle_sync_timer;
261 ePtr<eTimer> m_subtitle_hide_timer;
262 ePtr<eTimer> m_streamingsrc_timeout;
263 pts_t m_prev_decoder_time;
264 int m_decoder_time_valid_state;
266 void pushSubtitles();
268 void hideSubtitles();
269 void sourceTimeout();
271 sourceStream m_sourceinfo;
272 eSingleLock m_subs_to_pull_lock;
273 gulong m_subs_to_pull_handler_id;
275 RESULT seekToImpl(pts_t to);
277 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
278 std::string m_useragent;
279 RESULT trickSeek(gdouble ratio);