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;
52 class eServiceMP3: public iPlayableService, public iPauseableService,
53 public iServiceInformation, public iSeekableService, public iAudioTrackSelection, public iAudioChannelSelection,
54 public iSubtitleOutput, public iStreamedService, public iAudioDelay, public Object
56 DECLARE_REF(eServiceMP3);
58 virtual ~eServiceMP3();
61 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
64 RESULT setTarget(int target);
66 RESULT pause(ePtr<iPauseableService> &ptr);
67 RESULT setSlowMotion(int ratio);
68 RESULT setFastForward(int ratio);
70 RESULT seek(ePtr<iSeekableService> &ptr);
71 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
72 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
73 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
74 RESULT audioDelay(ePtr<iAudioDelay> &ptr);
76 // not implemented (yet)
77 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
78 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
79 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
80 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
82 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
83 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
84 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
86 void setQpipMode(bool value, bool audio) { }
92 RESULT info(ePtr<iServiceInformation>&);
95 RESULT getLength(pts_t &SWIG_OUTPUT);
96 RESULT seekTo(pts_t to);
97 RESULT seekRelative(int direction, pts_t to);
98 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
99 RESULT setTrickmode(int trick);
100 RESULT isCurrentlySeekable();
102 // iServiceInformation
103 RESULT getName(std::string &name);
105 std::string getInfoString(int w);
106 PyObject *getInfoObject(int w);
108 // iAudioTrackSelection
109 int getNumberOfTracks();
110 RESULT selectTrack(unsigned int i);
111 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
112 int getCurrentTrack();
114 // iAudioChannelSelection
115 int getCurrentChannel();
116 RESULT selectChannel(int i);
119 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
120 RESULT disableSubtitles(eWidget *parent);
121 PyObject *getSubtitleList();
122 PyObject *getCachedSubtitle();
125 RESULT streamed(ePtr<iStreamedService> &ptr);
126 PyObject *getBufferCharge();
127 int setBufferSize(int size);
132 void setAC3Delay(int);
133 void setPCMDelay(int);
139 std::string language_code; /* iso-639, if available. */
140 std::string codec; /* clear text codec description */
142 :pad(0), type(atUnknown)
146 struct subtitleStream
150 std::string language_code; /* iso-639, if available. */
158 audiotype_t audiotype;
159 containertype_t containertype;
163 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
172 int64_t bufferingLeft;
174 :bufferPercent(0), avgInRate(0), avgOutRate(0), bufferingLeft(-1)
180 std::string error_message;
181 std::string missing_codec;
185 static int pcm_delay;
186 static int ac3_delay;
187 int m_currentAudioStream;
188 int m_currentSubtitleStream;
189 int selectAudioStream(int i);
190 std::vector<audioStream> m_audioStreams;
191 std::vector<subtitleStream> m_subtitleStreams;
192 eSubtitleWidget *m_subtitle_widget;
193 int m_currentTrickRatio;
194 friend class eServiceFactoryMP3;
195 eServiceReference m_ref;
198 bufferInfo m_bufferInfo;
199 errorInfo m_errorInfo;
200 eServiceMP3(eServiceReference ref);
201 Signal2<void,iPlayableService*,int> m_event;
204 stIdle, stRunning, stStopped,
207 GstElement *m_gst_playbin, *audioSink, *videoSink;
208 GstTagList *m_stream_tags;
218 Message(int type, GstPad *pad)
223 Message(int type, GstBuffer *buffer)
231 GstBuffer *buffer; // for msg type 2
232 GstPad *pad; // for msg type 3
236 eFixedMessagePump<Message> m_pump;
238 audiotype_t gstCheckAudioPad(GstStructure* structure);
239 #if GST_VERSION_MAJOR < 1
240 static gint match_sinktype(GstElement *element, gpointer type);
242 static gint match_sinktype(const GValue *velement, const gchar *type);
244 void gstBusCall(GstBus *bus, GstMessage *msg);
245 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
246 static void gstTextpadHasCAPS(GstPad *pad, GParamSpec * unused, gpointer user_data);
247 void gstTextpadHasCAPS_synced(GstPad *pad);
248 static void gstCBsubtitleAvail(GstElement *element, GstBuffer *buffer, gpointer user_data);
249 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
250 void gstPoll(const Message&);
251 static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data);
255 enum { Unknown, Pango, Vob } type;
256 ePangoSubtitlePage pango_page;
257 eVobSubtitlePage vob_page;
260 std::list<SubtitlePage> m_subtitle_pages;
261 ePtr<eTimer> m_subtitle_sync_timer;
263 ePtr<eTimer> m_streamingsrc_timeout;
264 pts_t m_prev_decoder_time;
265 int m_decoder_time_valid_state;
267 void pushSubtitles();
268 void pullSubtitle(GstBuffer *buffer);
269 void sourceTimeout();
270 sourceStream m_sourceinfo;
271 gulong m_subs_to_pull_handler_id;
273 RESULT seekToImpl(pts_t to);
275 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
276 std::string m_useragent;
277 RESULT trickSeek(gdouble ratio);