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 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 stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
82 RESULT keys(ePtr<iServiceKeys> &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();
124 std::string language_code; /* iso-639, if available. */
125 std::string codec; /* clear text codec description */
127 :pad(0), type(atUnknown)
131 struct subtitleStream
135 std::string language_code; /* iso-639, if available. */
143 audiotype_t audiotype;
144 containertype_t containertype;
148 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
153 int m_currentAudioStream;
154 int m_currentSubtitleStream;
155 int selectAudioStream(int i);
156 std::vector<audioStream> m_audioStreams;
157 std::vector<subtitleStream> m_subtitleStreams;
158 eSubtitleWidget *m_subtitle_widget;
159 int m_currentTrickRatio;
160 ePtr<eTimer> m_seekTimeout;
161 void seekTimeoutCB();
162 friend class eServiceFactoryMP3;
163 std::string m_filename;
165 eServiceMP3(const char *filename, const char *title);
166 Signal2<void,iPlayableService*,int> m_event;
169 stIdle, stRunning, stStopped,
172 GstElement *m_gst_playbin;
173 GstTagList *m_stream_tags;
174 eFixedMessagePump<int> m_pump;
175 std::string m_error_message;
177 audiotype_t gstCheckAudioPad(GstStructure* structure);
178 void gstBusCall(GstBus *bus, GstMessage *msg);
179 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
180 static void gstCBsubtitleAvail(GstElement *element, gpointer user_data);
181 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
182 void gstPoll(const int&);
184 std::list<ePangoSubtitlePage> m_subtitle_pages;
185 ePtr<eTimer> m_subtitle_sync_timer;
186 void pushSubtitles();
188 gint m_aspect, m_width, m_height, m_framerate, m_progressive;
189 RESULT trickSeek(gdouble ratio);