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);
44 int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate) { return 1; }
45 RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr, time_t start_time);
48 typedef struct _GstElement GstElement;
50 typedef enum { atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC } audiotype_t;
51 typedef enum { stUnknown, stPlainText, stSSA, stASS, stSRT, stVOB, stPGS } subtype_t;
52 typedef enum { ctNone, ctMPEGTS, ctMPEGPS, ctMKV, ctAVI, ctMP4, ctVCD, ctCDA } containertype_t;
54 class eServiceMP3: public iPlayableService, public iPauseableService,
55 public iServiceInformation, public iSeekableService, public iAudioTrackSelection, public iAudioChannelSelection,
56 public iSubtitleOutput, public iStreamedService, public iAudioDelay, public Object
58 DECLARE_REF(eServiceMP3);
60 virtual ~eServiceMP3();
63 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
66 RESULT setTarget(int target);
68 RESULT pause(ePtr<iPauseableService> &ptr);
69 RESULT setSlowMotion(int ratio);
70 RESULT setFastForward(int ratio);
72 RESULT seek(ePtr<iSeekableService> &ptr);
73 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
74 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
75 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
76 RESULT audioDelay(ePtr<iAudioDelay> &ptr);
78 // not implemented (yet)
79 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
80 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
81 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
82 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
84 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
85 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
86 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
88 void setQpipMode(bool value, bool audio) { }
94 RESULT info(ePtr<iServiceInformation>&);
97 RESULT getLength(pts_t &SWIG_OUTPUT);
98 RESULT seekTo(pts_t to);
99 RESULT seekRelative(int direction, pts_t to);
100 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
101 RESULT setTrickmode(int trick);
102 RESULT isCurrentlySeekable();
104 // iServiceInformation
105 RESULT getName(std::string &name);
106 RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
108 std::string getInfoString(int w);
109 PyObject *getInfoObject(int w);
111 // iAudioTrackSelection
112 int getNumberOfTracks();
113 RESULT selectTrack(unsigned int i);
114 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
115 int getCurrentTrack();
117 // iAudioChannelSelection
118 int getCurrentChannel();
119 RESULT selectChannel(int i);
122 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
123 RESULT disableSubtitles(eWidget *parent);
124 PyObject *getSubtitleList();
125 PyObject *getCachedSubtitle();
128 RESULT streamed(ePtr<iStreamedService> &ptr);
129 PyObject *getBufferCharge();
130 int setBufferSize(int size);
135 void setAC3Delay(int);
136 void setPCMDelay(int);
142 std::string language_code; /* iso-639, if available. */
143 std::string codec; /* clear text codec description */
145 :pad(0), type(atUnknown)
149 struct subtitleStream
153 std::string language_code; /* iso-639, if available. */
161 audiotype_t audiotype;
162 containertype_t containertype;
166 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
175 int64_t bufferingLeft;
177 :bufferPercent(0), avgInRate(0), avgOutRate(0), bufferingLeft(-1)
183 std::string error_message;
184 std::string missing_codec;
188 ePtr<eTimer> m_nownext_timer;
189 ePtr<eServiceEvent> m_event_now, m_event_next;
190 void updateEpgCacheNowNext();
192 static int pcm_delay;
193 static int ac3_delay;
194 int m_currentAudioStream;
195 int m_currentSubtitleStream;
196 int selectAudioStream(int i);
197 std::vector<audioStream> m_audioStreams;
198 std::vector<subtitleStream> m_subtitleStreams;
199 eSubtitleWidget *m_subtitle_widget;
200 int m_currentTrickRatio;
201 friend class eServiceFactoryMP3;
202 eServiceReference m_ref;
205 bufferInfo m_bufferInfo;
206 errorInfo m_errorInfo;
207 eServiceMP3(eServiceReference ref);
208 Signal2<void,iPlayableService*,int> m_event;
211 stIdle, stRunning, stStopped,
214 GstElement *m_gst_playbin, *audioSink, *videoSink;
215 GstTagList *m_stream_tags;
225 Message(int type, GstPad *pad)
230 Message(int type, GstBuffer *buffer)
238 GstBuffer *buffer; // for msg type 2
239 GstPad *pad; // for msg type 3
243 eFixedMessagePump<Message> m_pump;
245 audiotype_t gstCheckAudioPad(GstStructure* structure);
246 #if GST_VERSION_MAJOR < 1
247 static gint match_sinktype(GstElement *element, gpointer type);
249 static gint match_sinktype(const GValue *velement, const gchar *type);
251 void gstBusCall(GstBus *bus, GstMessage *msg);
252 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
253 static void gstTextpadHasCAPS(GstPad *pad, GParamSpec * unused, gpointer user_data);
254 void gstTextpadHasCAPS_synced(GstPad *pad);
255 static void gstCBsubtitleAvail(GstElement *element, GstBuffer *buffer, gpointer user_data);
256 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
257 void gstPoll(const Message&);
258 static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data);
262 enum { Unknown, Pango, Vob } type;
263 ePangoSubtitlePage pango_page;
264 eVobSubtitlePage vob_page;
267 std::list<SubtitlePage> m_subtitle_pages;
268 ePtr<eTimer> m_subtitle_sync_timer;
270 ePtr<eTimer> m_streamingsrc_timeout;
271 pts_t m_prev_decoder_time;
272 int m_decoder_time_valid_state;
274 void pushSubtitles();
275 void pullSubtitle(GstBuffer *buffer);
276 void sourceTimeout();
277 sourceStream m_sourceinfo;
278 gulong m_subs_to_pull_handler_id;
280 RESULT seekToImpl(pts_t to);
282 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
283 std::string m_useragent;
284 RESULT trickSeek(gdouble ratio);