update es, da language
[enigma2.git] / lib / service / servicemp3.h
1 #ifndef __servicemp3_h
2 #define __servicemp3_h
3
4 #ifdef HAVE_GSTREAMER
5 #include <lib/base/message.h>
6 #include <lib/service/iservice.h>
7 #include <gst/gst.h>
8
9 class eStaticServiceMP3Info;
10
11 class eServiceFactoryMP3: public iServiceHandler
12 {
13 DECLARE_REF(eServiceFactoryMP3);
14 public:
15         eServiceFactoryMP3();
16         virtual ~eServiceFactoryMP3();
17         enum { id = 0x1001 };
18
19                 // iServiceHandler
20         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
21         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
22         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
23         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
24         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
25 private:
26         ePtr<eStaticServiceMP3Info> m_service_info;
27 };
28
29 class eStaticServiceMP3Info: public iStaticServiceInformation
30 {
31         DECLARE_REF(eStaticServiceMP3Info);
32         friend class eServiceFactoryMP3;
33         eStaticServiceMP3Info();
34 public:
35         RESULT getName(const eServiceReference &ref, std::string &name);
36         int getLength(const eServiceReference &ref);
37 };
38
39 typedef struct _GstElement GstElement;
40
41 class eServiceMP3: public iPlayableService, public iPauseableService, 
42         public iServiceInformation, public iSeekableService, public Object
43 {
44 DECLARE_REF(eServiceMP3);
45 public:
46         virtual ~eServiceMP3();
47
48                 // iPlayableService
49         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
50         RESULT start();
51         RESULT stop();
52         RESULT setTarget(int target);
53         
54         RESULT pause(ePtr<iPauseableService> &ptr);
55         RESULT setSlowMotion(int ratio);
56         RESULT setFastForward(int ratio);
57
58         RESULT seek(ePtr<iSeekableService> &ptr);
59
60                 // not implemented (yet)
61         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return -1; }
62         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
63         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
64         RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
65         RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
66         RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
67         RESULT subtitle(ePtr<iSubtitleOutput> &ptr) { ptr = 0; return -1; }
68         RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
69         RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
70         RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
71
72                 // iPausableService
73         RESULT pause();
74         RESULT unpause();
75         
76         RESULT info(ePtr<iServiceInformation>&);
77         
78                 // iSeekableService
79         RESULT getLength(pts_t &SWIG_OUTPUT);
80         RESULT seekTo(pts_t to);
81         RESULT seekRelative(int direction, pts_t to);
82         RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
83         RESULT setTrickmode(int trick);
84         RESULT isCurrentlySeekable();
85         
86                 // iServiceInformation
87         RESULT getName(std::string &name);
88         int getInfo(int w);
89         std::string getInfoString(int w);
90 private:
91         friend class eServiceFactoryMP3;
92         std::string m_filename;
93         eServiceMP3(const char *filename);      
94         Signal2<void,iPlayableService*,int> m_event;
95         enum
96         {
97                 stIdle, stRunning, stStopped,
98         };
99         int m_state;
100         GstElement *m_gst_pipeline, *m_gst_audio, *m_gst_videoqueue, *m_gst_audioqueue, *m_decoder;
101         GstTagList *m_stream_tags;
102         eFixedMessagePump<int> m_pump;
103         
104         void gstBusCall(GstBus *bus, GstMessage *msg);
105         static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
106         static void gstCBpadAdded(GstElement *decodebin, GstPad *pad, gpointer data); /* for mpegdemux */
107         static void gstCBfilterPadAdded(GstElement *filter, GstPad *pad, gpointer user_data); /* for id3demux */
108         static void gstCBnewPad(GstElement *decodebin, GstPad *pad, gboolean last, gpointer data); /* for decodebin */
109         static void gstCBunknownType(GstElement *decodebin, GstPad *pad, GstCaps *l, gpointer data);
110         void gstPoll(const int&);
111 };
112 #endif
113
114 #endif