update new e2 subtitle/audio track api in service-type plugins
[enigma2-plugins.git] / merlinmusicplayer / src / merlinmp3player / merlinmp3player.h
1 #include <lib/base/message.h>
2 #include <lib/service/iservice.h>
3 #include <gst/gst.h>
4
5 class eStaticServiceMerlinMP3Info;
6
7 class eServiceFactoryMerlinMP3Player: public iServiceHandler
8 {
9 DECLARE_REF(eServiceFactoryMerlinMP3Player);
10 public:
11         eServiceFactoryMerlinMP3Player();
12         virtual ~eServiceFactoryMerlinMP3Player();
13         enum { id = 0x1014 };
14
15                 // iServiceHandler
16         RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
17         RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
18         RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
19         RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
20         RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
21 private:
22         ePtr<eStaticServiceMerlinMP3Info> m_service_info;
23 };
24
25 class eStaticServiceMerlinMP3Info: public iStaticServiceInformation
26 {
27         DECLARE_REF(eStaticServiceMerlinMP3Info);
28         friend class eServiceFactoryMerlinMP3Player;
29         eStaticServiceMerlinMP3Info();
30 public:
31         RESULT getName(const eServiceReference &ref, std::string &name);
32         int getLength(const eServiceReference &ref);
33 };
34
35 typedef struct _GstElement GstElement;
36
37 class eServiceMerlinMP3Player: public iPlayableService, public iPauseableService, 
38         public iServiceInformation, public iSeekableService, public Object
39 {
40 DECLARE_REF(eServiceMerlinMP3Player);
41 public:
42         virtual ~eServiceMerlinMP3Player();
43
44                 // iPlayableService
45         RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
46         RESULT start();
47         RESULT stop();
48         RESULT setTarget(int target);
49         
50         RESULT pause(ePtr<iPauseableService> &ptr);
51         RESULT setSlowMotion(int ratio);
52         RESULT setFastForward(int ratio);
53
54         RESULT seek(ePtr<iSeekableService> &ptr);
55         // not implemented
56         RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return 0; };
57         RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return 0; };
58         RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; };
59         RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; };
60         RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; };
61         RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; };
62         RESULT subtitle(ePtr<iSubtitleTrackSelection> &ptr) { ptr = 0; return -1; };
63         RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; };
64         RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; };
65         RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; };
66         RESULT streamed(ePtr<iStreamedService> &ptr) { ptr = 0; return -1; };
67         RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; };
68
69                 // iPausableService
70         RESULT pause();
71         RESULT unpause();
72         
73         RESULT info(ePtr<iServiceInformation>&);
74         
75                 // iSeekableService
76         RESULT getLength(pts_t &SWIG_OUTPUT);
77         RESULT seekTo(pts_t to);
78         RESULT seekRelative(int direction, pts_t to);
79         RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
80         RESULT setTrickmode(int trick);
81         RESULT isCurrentlySeekable();
82         
83                 // iServiceInformation
84         RESULT getName(std::string &name);
85         int getInfo(int w);
86         std::string getInfoString(int w);
87 private:
88         friend class eServiceFactoryMerlinMP3Player;
89         eServiceReference m_ref;
90         std::string m_filename;
91         eServiceMerlinMP3Player(eServiceReference ref); 
92         Signal2<void,iPlayableService*,int> m_event;
93         enum
94         {
95                 stIdle, stRunning, stStopped,
96         };
97         int m_state;
98         GstElement *m_gst_pipeline;
99         eFixedMessagePump<int> m_pump;
100         
101         void gstBusCall(GstBus *bus, GstMessage *msg);
102         static GstBusSyncReply gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data);
103         void gstPoll(const int&);
104 };
105