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 { stPlainText, stSSA, stSRT } 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;
202 eFixedMessagePump<int> m_pump;
203 std::string m_error_message;
205 audiotype_t gstCheckAudioPad(GstStructure* structure);
206 void gstBusCall(GstBus *bus, GstMessage *msg);
207 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
208 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
209 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
210 void gstPoll(const int&);
211 static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data);
213 std::list<ePangoSubtitlePage> m_subtitle_pages;
214 ePtr<eTimer> m_subtitle_sync_timer;
216 ePtr<eTimer> m_streamingsrc_timeout;
217 void pushSubtitles();
219 void sourceTimeout();
221 sourceStream m_sourceinfo;
222 eSingleLock m_subs_to_pull_lock;
223 gulong m_subs_to_pull_handler_id;
225 RESULT seekToImpl(pts_t to);
227 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
228 std::string m_useragent;
229 RESULT trickSeek(gdouble ratio);