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 GstTagList *m_stream_tags;
211 Message(int type, GstPad *pad)
219 GstPad *pad; // for msg type 3
223 eFixedMessagePump<Message> m_pump;
224 std::string m_error_message;
226 audiotype_t gstCheckAudioPad(GstStructure* structure);
227 void gstBusCall(GstBus *bus, GstMessage *msg);
228 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
229 static void gstTextpadHasCAPS(GstPad *pad, GParamSpec * unused, gpointer user_data);
230 void gstTextpadHasCAPS_synced(GstPad *pad);
231 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
232 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
233 void gstPoll(const Message&);
234 static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data);
238 enum { Unknown, Pango, Vob } type;
239 ePangoSubtitlePage pango_page;
240 eVobSubtitlePage vob_page;
243 std::list<SubtitlePage> m_subtitle_pages;
244 ePtr<eTimer> m_subtitle_sync_timer;
246 ePtr<eTimer> m_streamingsrc_timeout;
247 pts_t m_prev_decoder_time;
248 int m_decoder_time_valid_state;
250 void pushSubtitles();
252 void sourceTimeout();
254 sourceStream m_sourceinfo;
255 eSingleLock m_subs_to_pull_lock;
256 gulong m_subs_to_pull_handler_id;
258 RESULT seekToImpl(pts_t to);
260 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
261 std::string m_useragent;
262 RESULT trickSeek(gdouble ratio);