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 class eStaticServiceMP3Info;
14 class eSubtitleWidget;
16 class eServiceFactoryMP3: public iServiceHandler
18 DECLARE_REF(eServiceFactoryMP3);
21 virtual ~eServiceFactoryMP3();
25 RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
26 RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
27 RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
28 RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
29 RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
31 ePtr<eStaticServiceMP3Info> m_service_info;
34 class eStaticServiceMP3Info: public iStaticServiceInformation
36 DECLARE_REF(eStaticServiceMP3Info);
37 friend class eServiceFactoryMP3;
38 eStaticServiceMP3Info();
40 RESULT getName(const eServiceReference &ref, std::string &name);
41 int getLength(const eServiceReference &ref);
44 typedef struct _GstElement GstElement;
46 typedef enum { atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC } audiotype_t;
47 typedef enum { stPlainText, stSSA, stSRT } subtype_t;
48 typedef enum { ctNone, ctMPEGTS, ctMPEGPS, ctMKV, ctAVI, ctMP4, ctVCD, ctCDA } containertype_t;
50 class eServiceMP3: public iPlayableService, public iPauseableService,
51 public iServiceInformation, public iSeekableService, public iAudioTrackSelection, public iAudioChannelSelection, public iSubtitleOutput, public Object
53 DECLARE_REF(eServiceMP3);
55 virtual ~eServiceMP3();
58 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
61 RESULT setTarget(int target);
63 RESULT pause(ePtr<iPauseableService> &ptr);
64 RESULT setSlowMotion(int ratio);
65 RESULT setFastForward(int ratio);
67 RESULT seek(ePtr<iSeekableService> &ptr);
68 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
69 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
70 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
72 // not implemented (yet)
73 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
74 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
75 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
76 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
77 RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
78 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
79 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
80 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
86 RESULT info(ePtr<iServiceInformation>&);
89 RESULT getLength(pts_t &SWIG_OUTPUT);
90 RESULT seekTo(pts_t to);
91 RESULT seekRelative(int direction, pts_t to);
92 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
93 RESULT setTrickmode(int trick);
94 RESULT isCurrentlySeekable();
96 // iServiceInformation
97 RESULT getName(std::string &name);
99 std::string getInfoString(int w);
101 // iAudioTrackSelection
102 int getNumberOfTracks();
103 RESULT selectTrack(unsigned int i);
104 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
105 int getCurrentTrack();
107 // iAudioChannelSelection
108 int getCurrentChannel();
109 RESULT selectChannel(int i);
112 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
113 RESULT disableSubtitles(eWidget *parent);
114 PyObject *getSubtitleList();
115 PyObject *getCachedSubtitle();
121 std::string language_code; /* iso-639, if available. */
123 :pad(0), type(atUnknown)
127 struct subtitleStream
131 std::string language_code; /* iso-639, if available. */
139 audiotype_t audiotype;
140 containertype_t containertype;
144 :audiotype(atUnknown), containertype(ctNone), is_video(FALSE), is_streaming(FALSE)
149 int m_currentAudioStream;
150 int m_currentSubtitleStream;
151 int selectAudioStream(int i);
152 std::vector<audioStream> m_audioStreams;
153 std::vector<subtitleStream> m_subtitleStreams;
154 eSubtitleWidget *m_subtitle_widget;
155 int m_currentTrickRatio;
156 ePtr<eTimer> m_seekTimeout;
157 void seekTimeoutCB();
158 friend class eServiceFactoryMP3;
159 std::string m_filename;
160 eServiceMP3(const char *filename);
161 Signal2<void,iPlayableService*,int> m_event;
164 stIdle, stRunning, stStopped,
167 GstElement *m_gst_pipeline;
168 GstTagList *m_stream_tags;
169 eFixedMessagePump<int> m_pump;
170 std::string m_error_message;
172 audiotype_t gstCheckAudioPad(GstStructure* structure);
173 void gstBusCall(GstBus *bus, GstMessage *msg);
174 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
175 static void gstCBpadAdded(GstElement *decodebin, GstPad *pad, gpointer data); /* for mpegdemux */
176 static void gstCBfilterPadAdded(GstElement *filter, GstPad *pad, gpointer user_data); /* for id3demux */
177 static void gstCBnewPad(GstElement *decodebin, GstPad *pad, gboolean last, gpointer data); /* for decodebin */
178 static void gstCBunknownType(GstElement *decodebin, GstPad *pad, GstCaps *l, gpointer data);
179 static void gstCBsubtitleAvail(GstElement *element, GstBuffer *buffer, GstPad *pad, gpointer user_data);
180 static void gstCBsubtitlePadEvent(GstPad *pad, GstEvent *event, gpointer user_data);
181 GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type);
182 void gstPoll(const int&);