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, public iSubtitleOutput, public iStreamedService, public Object
55 DECLARE_REF(eServiceMP3);
57 virtual ~eServiceMP3();
60 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
63 RESULT setTarget(int target);
65 RESULT pause(ePtr<iPauseableService> &ptr);
66 RESULT setSlowMotion(int ratio);
67 RESULT setFastForward(int ratio);
69 RESULT seek(ePtr<iSeekableService> &ptr);
70 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
71 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
72 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
74 // not implemented (yet)
75 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
76 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
77 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
78 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
79 RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
80 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
81 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
82 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
88 RESULT info(ePtr<iServiceInformation>&);
91 RESULT getLength(pts_t &SWIG_OUTPUT);
92 RESULT seekTo(pts_t to);
93 RESULT seekRelative(int direction, pts_t to);
94 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
95 RESULT setTrickmode(int trick);
96 RESULT isCurrentlySeekable();
98 // iServiceInformation
99 RESULT getName(std::string &name);
101 std::string getInfoString(int w);
102 PyObject *getInfoObject(int w);
104 // iAudioTrackSelection
105 int getNumberOfTracks();
106 RESULT selectTrack(unsigned int i);
107 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
108 int getCurrentTrack();
110 // iAudioChannelSelection
111 int getCurrentChannel();
112 RESULT selectChannel(int i);
115 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
116 RESULT disableSubtitles(eWidget *parent);
117 PyObject *getSubtitleList();
118 PyObject *getCachedSubtitle();
121 RESULT streamed(ePtr<iStreamedService> &ptr);
122 PyObject *getBufferCharge();
123 int setBufferSize(int size);
129 std::string language_code; /* iso-639, if available. */
130 std::string codec; /* clear text codec description */
132 :pad(0), type(atUnknown)
136 struct subtitleStream
140 std::string language_code; /* iso-639, if available. */
148 audiotype_t audiotype;
149 containertype_t containertype;
153 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
162 long long bufferingLeft;
164 :bufferPercent(0), avgInRate(0), avgOutRate(0), bufferingLeft(-1)
169 int m_currentAudioStream;
170 int m_currentSubtitleStream;
171 int selectAudioStream(int i);
172 std::vector<audioStream> m_audioStreams;
173 std::vector<subtitleStream> m_subtitleStreams;
174 eSubtitleWidget *m_subtitle_widget;
175 int m_currentTrickRatio;
176 ePtr<eTimer> m_seekTimeout;
177 void seekTimeoutCB();
178 friend class eServiceFactoryMP3;
179 eServiceReference m_ref;
181 bufferInfo m_bufferInfo;
182 eServiceMP3(eServiceReference ref);
183 Signal2<void,iPlayableService*,int> m_event;
186 stIdle, stRunning, stStopped,
189 GstElement *m_gst_playbin;
190 GstTagList *m_stream_tags;
191 eFixedMessagePump<int> m_pump;
192 std::string m_error_message;
194 audiotype_t gstCheckAudioPad(GstStructure* structure);
195 void gstBusCall(GstBus *bus, GstMessage *msg);
196 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
197 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
198 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
199 void gstPoll(const int&);
201 std::list<ePangoSubtitlePage> m_subtitle_pages;
202 ePtr<eTimer> m_subtitle_sync_timer;
203 void pushSubtitles();
206 eSingleLock m_subs_to_pull_lock;
208 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
209 RESULT trickSeek(gdouble ratio);