Merge remote branch 'remotes/origin/bug_620_dvdburn_absolutepaths'
[enigma2.git] / lib / service / servicexine.h
1 #ifndef __servicemp3_h
2 #define __servicemp3_h
3
4 #define HAVE_XINE
5 #ifdef HAVE_XINE
6 #include <lib/base/message.h>
7 #include <lib/service/iservice.h>
8
9 #include <xine.h>
10 #include <xine/xineutils.h>
11
12 class eStaticServiceXineInfo;
13
14 class eServiceFactoryXine: public iServiceHandler
15 {
16         DECLARE_REF(eServiceFactoryXine);
17 public:
18         eServiceFactoryXine();
19         virtual ~eServiceFactoryXine();
20         enum { id = 0x1010 };
21
22                 // iServiceHandler
23         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
24         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
25         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
26         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
27         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
28 private:
29         ePtr<eStaticServiceXineInfo> m_service_info;
30 };
31
32 class eStaticServiceXineInfo: public iStaticServiceInformation
33 {
34         DECLARE_REF(eStaticServiceXineInfo);
35         friend class eServiceFactoryXine;
36         eStaticServiceXineInfo();
37 public:
38         RESULT getName(const eServiceReference &ref, std::string &name);
39         int getLength(const eServiceReference &ref);
40 };
41
42 typedef struct _GstElement GstElement;
43
44 class eServiceXine: public iPlayableService, public iPauseableService, 
45         public iServiceInformation, public iSeekableService, public Object
46 {
47         DECLARE_REF(eServiceXine);
48 public:
49         virtual ~eServiceXine();
50
51                 // iPlayableService
52         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
53         RESULT start();
54         RESULT stop();
55         RESULT setTarget(int target);
56         
57         RESULT pause(ePtr<iPauseableService> &ptr);
58         RESULT setSlowMotion(int ratio);
59         RESULT setFastForward(int ratio);
60
61         RESULT seek(ePtr<iSeekableService> &ptr);
62
63                 // not implemented (yet)
64         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return -1; }
65         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
66         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
67         RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
68         RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
69         RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }
70         RESULT subtitle(ePtr<iSubtitleOutput> &ptr) { ptr = 0; return -1; }
71         RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }
72         RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
73         RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
74
75                 // iPausableService
76         RESULT pause();
77         RESULT unpause();
78         
79         RESULT info(ePtr<iServiceInformation>&);
80         
81                 // iSeekableService
82         RESULT getLength(pts_t &SWIG_OUTPUT);
83         RESULT seekTo(pts_t to);
84         RESULT seekRelative(int direction, pts_t to);
85         RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
86         RESULT setTrickmode(int trick);
87         RESULT isCurrentlySeekable();
88         
89                 // iServiceInformation
90         RESULT getName(std::string &name);
91         int getInfo(int w);
92         std::string getInfoString(int w);
93 private:
94         friend class eServiceFactoryXine;
95         std::string m_filename;
96         eServiceXine(const char *filename);     
97         Signal2<void,iPlayableService*,int> m_event;
98
99         xine_stream_t *stream;
100         xine_video_port_t *vo_port;
101         xine_audio_port_t *ao_port;
102         xine_event_queue_t *event_queue;
103
104         enum
105         {
106                 stError, stIdle, stRunning, stStopped,
107         };
108         int m_state;
109         
110         static void eventListenerWrap(void *user_data, const xine_event_t *event);
111         void eventListener(const xine_event_t *event);
112         
113
114         eFixedMessagePump<int> m_pump;
115 };
116 #endif
117
118 #endif