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);
46 typedef struct _GstElement GstElement;
48 typedef enum { atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC } audiotype_t;
49 typedef enum { stPlainText, stSSA, stSRT } 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; }
90 RESULT info(ePtr<iServiceInformation>&);
93 RESULT getLength(pts_t &SWIG_OUTPUT);
94 RESULT seekTo(pts_t to);
95 RESULT seekRelative(int direction, pts_t to);
96 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
97 RESULT setTrickmode(int trick);
98 RESULT isCurrentlySeekable();
100 // iServiceInformation
101 RESULT getName(std::string &name);
103 std::string getInfoString(int w);
104 PyObject *getInfoObject(int w);
106 // iAudioTrackSelection
107 int getNumberOfTracks();
108 RESULT selectTrack(unsigned int i);
109 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
110 int getCurrentTrack();
112 // iAudioChannelSelection
113 int getCurrentChannel();
114 RESULT selectChannel(int i);
117 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
118 RESULT disableSubtitles(eWidget *parent);
119 PyObject *getSubtitleList();
120 PyObject *getCachedSubtitle();
123 RESULT streamed(ePtr<iStreamedService> &ptr);
124 PyObject *getBufferCharge();
125 int setBufferSize(int size);
130 void setAC3Delay(int);
131 void setPCMDelay(int);
137 std::string language_code; /* iso-639, if available. */
138 std::string codec; /* clear text codec description */
140 :pad(0), type(atUnknown)
144 struct subtitleStream
148 std::string language_code; /* iso-639, if available. */
156 audiotype_t audiotype;
157 containertype_t containertype;
161 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
170 long long bufferingLeft;
172 :bufferPercent(0), avgInRate(0), avgOutRate(0), bufferingLeft(-1)
177 static int pcm_delay;
178 static int ac3_delay;
179 int m_currentAudioStream;
180 int m_currentSubtitleStream;
181 int selectAudioStream(int i);
182 std::vector<audioStream> m_audioStreams;
183 std::vector<subtitleStream> m_subtitleStreams;
184 eSubtitleWidget *m_subtitle_widget;
185 int m_currentTrickRatio;
186 ePtr<eTimer> m_seekTimeout;
187 void seekTimeoutCB();
188 friend class eServiceFactoryMP3;
189 eServiceReference m_ref;
191 bufferInfo m_bufferInfo;
192 eServiceMP3(eServiceReference ref);
193 Signal2<void,iPlayableService*,int> m_event;
196 stIdle, stRunning, stStopped,
199 GstElement *m_gst_playbin;
200 GstTagList *m_stream_tags;
201 eFixedMessagePump<int> m_pump;
202 std::string m_error_message;
204 audiotype_t gstCheckAudioPad(GstStructure* structure);
205 void gstBusCall(GstBus *bus, GstMessage *msg);
206 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
207 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
208 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
209 void gstPoll(const int&);
211 std::list<ePangoSubtitlePage> m_subtitle_pages;
212 ePtr<eTimer> m_subtitle_sync_timer;
213 void pushSubtitles();
216 eSingleLock m_subs_to_pull_lock;
217 gulong m_subs_to_pull_handler_id;
219 RESULT seekToImpl(pts_t to);
221 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
222 RESULT trickSeek(gdouble ratio);