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 } subtype_t;
51 typedef enum { ctNone, ctMPEGTS, ctMPEGPS, ctMKV, ctAVI, ctMP4, ctVCD, ctCDA } containertype_t;
55 ePangoSubtitlePage *pango_page;
56 eVobSubtitlePage *vob_page;
59 class eServiceMP3: public iPlayableService, public iPauseableService,
60 public iServiceInformation, public iSeekableService, public iAudioTrackSelection, public iAudioChannelSelection,
61 public iSubtitleOutput, public iStreamedService, public iAudioDelay, public Object
63 DECLARE_REF(eServiceMP3);
65 virtual ~eServiceMP3();
68 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
71 RESULT setTarget(int target);
73 RESULT pause(ePtr<iPauseableService> &ptr);
74 RESULT setSlowMotion(int ratio);
75 RESULT setFastForward(int ratio);
77 RESULT seek(ePtr<iSeekableService> &ptr);
78 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
79 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
80 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
81 RESULT audioDelay(ePtr<iAudioDelay> &ptr);
83 // not implemented (yet)
84 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
85 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
86 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
87 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
89 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
90 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
91 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
97 RESULT info(ePtr<iServiceInformation>&);
100 RESULT getLength(pts_t &SWIG_OUTPUT);
101 RESULT seekTo(pts_t to);
102 RESULT seekRelative(int direction, pts_t to);
103 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
104 RESULT setTrickmode(int trick);
105 RESULT isCurrentlySeekable();
107 // iServiceInformation
108 RESULT getName(std::string &name);
110 std::string getInfoString(int w);
111 PyObject *getInfoObject(int w);
113 // iAudioTrackSelection
114 int getNumberOfTracks();
115 RESULT selectTrack(unsigned int i);
116 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
117 int getCurrentTrack();
119 // iAudioChannelSelection
120 int getCurrentChannel();
121 RESULT selectChannel(int i);
124 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
125 RESULT disableSubtitles(eWidget *parent);
126 PyObject *getSubtitleList();
127 PyObject *getCachedSubtitle();
130 RESULT streamed(ePtr<iStreamedService> &ptr);
131 PyObject *getBufferCharge();
132 int setBufferSize(int size);
137 void setAC3Delay(int);
138 void setPCMDelay(int);
144 std::string language_code; /* iso-639, if available. */
145 std::string codec; /* clear text codec description */
147 :pad(0), type(atUnknown)
151 struct subtitleStream
155 std::string language_code; /* iso-639, if available. */
163 audiotype_t audiotype;
164 containertype_t containertype;
168 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
177 long long bufferingLeft;
179 :bufferPercent(0), avgInRate(0), avgOutRate(0), bufferingLeft(-1)
184 static int pcm_delay;
185 static int ac3_delay;
186 int m_currentAudioStream;
187 int m_currentSubtitleStream;
188 int selectAudioStream(int i);
189 std::vector<audioStream> m_audioStreams;
190 std::vector<subtitleStream> m_subtitleStreams;
191 eSubtitleWidget *m_subtitle_widget;
192 int m_currentTrickRatio;
193 ePtr<eTimer> m_seekTimeout;
194 void seekTimeoutCB();
195 friend class eServiceFactoryMP3;
196 eServiceReference m_ref;
198 bufferInfo m_bufferInfo;
199 eServiceMP3(eServiceReference ref);
200 Signal2<void,iPlayableService*,int> m_event;
203 stIdle, stRunning, stStopped,
206 GstElement *m_gst_playbin;
207 GstElement *m_gst_subtitlebin;
208 GstTagList *m_stream_tags;
209 eFixedMessagePump<int> m_pump;
210 std::string m_error_message;
212 audiotype_t gstCheckAudioPad(GstStructure* structure);
213 void gstBusCall(GstBus *bus, GstMessage *msg);
214 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
215 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
216 static void gstCBsubtitleCAPS(GObject *obj, GParamSpec *pspec, gpointer user_data);
217 static void gstCBsubtitleLink(subtype_t type, gpointer user_data);
218 void gstPoll(const int&);
220 std::list<SubtitlePage> m_subtitle_pages;
221 ePtr<eTimer> m_subtitle_sync_timer;
222 ePtr<eTimer> m_subtitle_hide_timer;
223 void pushSubtitles();
225 void hideSubtitles();
227 eSingleLock m_subs_to_pull_lock;
228 gulong m_subs_to_pull_handler_id;
230 RESULT seekToImpl(pts_t to);
232 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
233 RESULT trickSeek(gdouble ratio);