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 } audiotype_t;
48 class eServiceMP3: public iPlayableService, public iPauseableService,
49 public iServiceInformation, public iSeekableService, public iAudioTrackSelection, public iAudioChannelSelection, public iSubtitleOutput, public Object
51 DECLARE_REF(eServiceMP3);
53 virtual ~eServiceMP3();
56 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
59 RESULT setTarget(int target);
61 RESULT pause(ePtr<iPauseableService> &ptr);
62 RESULT setSlowMotion(int ratio);
63 RESULT setFastForward(int ratio);
65 RESULT seek(ePtr<iSeekableService> &ptr);
66 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
67 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr);
68 RESULT subtitle(ePtr<iSubtitleOutput> &ptr);
70 // not implemented (yet)
71 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
72 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
73 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
74 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
75 RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
76 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
77 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
78 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
84 RESULT info(ePtr<iServiceInformation>&);
87 RESULT getLength(pts_t &SWIG_OUTPUT);
88 RESULT seekTo(pts_t to);
89 RESULT seekRelative(int direction, pts_t to);
90 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
91 RESULT setTrickmode(int trick);
92 RESULT isCurrentlySeekable();
94 // iServiceInformation
95 RESULT getName(std::string &name);
97 std::string getInfoString(int w);
99 // iAudioTrackSelection
100 int getNumberOfTracks();
101 RESULT selectTrack(unsigned int i);
102 RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
103 int getCurrentTrack();
105 // iAudioChannelSelection
106 int getCurrentChannel();
107 RESULT selectChannel(int i);
110 RESULT enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry);
111 RESULT disableSubtitles(eWidget *parent);
112 PyObject *getSubtitleList();
113 PyObject *getCachedSubtitle();
119 std::string language_code; /* iso-639, if available. */
121 :pad(0), type(atUnknown)
125 struct subtitleStream
128 std::string language_code; /* iso-639, if available. */
135 int m_currentAudioStream;
136 int m_currentSubtitleStream;
137 int selectAudioStream(int i);
138 std::vector<audioStream> m_audioStreams;
139 std::vector<subtitleStream> m_subtitleStreams;
140 eSubtitleWidget *m_subtitle_widget;
141 int m_currentTrickRatio;
142 eTimer m_seekTimeout;
143 void seekTimeoutCB();
144 friend class eServiceFactoryMP3;
145 std::string m_filename;
146 eServiceMP3(const char *filename);
147 Signal2<void,iPlayableService*,int> m_event;
150 stIdle, stRunning, stStopped,
153 GstElement *m_gst_pipeline;
154 GstTagList *m_stream_tags;
155 eFixedMessagePump<int> m_pump;
156 std::string m_error_message;
158 audiotype_t gstCheckAudioPad(GstStructure* structure);
159 void gstBusCall(GstBus *bus, GstMessage *msg);
160 static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
161 static void gstCBpadAdded(GstElement *decodebin, GstPad *pad, gpointer data); /* for mpegdemux */
162 static void gstCBfilterPadAdded(GstElement *filter, GstPad *pad, gpointer user_data); /* for id3demux */
163 static void gstCBnewPad(GstElement *decodebin, GstPad *pad, gboolean last, gpointer data); /* for decodebin */
164 static void gstCBunknownType(GstElement *decodebin, GstPad *pad, GstCaps *l, gpointer data);
165 static void gstCBsubtitleAvail(GstElement *element, GstBuffer *buffer, GstPad *pad, gpointer user_data);
166 static void gstCBsubtitlePadEvent(GstPad *pad, GstEvent *event, gpointer user_data);
167 void gstPoll(const int&);