409a4421fee330c722f2fdc511e0af5b789db418
[enigma2.git] / lib / dvb / decoder.h
1 #ifndef __decoder_h
2 #define __decoder_h
3
4 #include <lib/base/object.h>
5 #include <lib/dvb/demux.h>
6
7 class eSocketNotifier;
8
9 class eDVBAudio: public iObject
10 {
11 DECLARE_REF(eDVBAudio);
12 private:
13         ePtr<eDVBDemux> m_demux;
14         int m_fd, m_fd_demux, m_dev, m_is_freezed;
15 public:
16         enum { aMPEG, aAC3, aDTS, aAAC };
17         eDVBAudio(eDVBDemux *demux, int dev);
18         enum { aMonoLeft, aStereo, aMonoRight };
19         void setChannel(int channel);
20         void stop();
21 #if HAVE_DVB_API_VERSION < 3
22         int setPid(int pid, int type);
23         int startPid();
24         int start();
25         int stopPid();
26         int setAVSync(int val);
27 #else
28         int startPid(int pid, int type);
29 #endif
30         void flush();
31         void freeze();
32         void unfreeze();
33         int getPTS(pts_t &now);
34         virtual ~eDVBAudio();
35 };
36
37 class eDVBVideo: public iObject, public Object
38 {
39 DECLARE_REF(eDVBVideo);
40 private:
41         ePtr<eDVBDemux> m_demux;
42         int m_fd, m_fd_demux, m_dev;
43 #if HAVE_DVB_API_VERSION < 3
44         m_fd_video;
45 #endif
46         int m_is_slow_motion, m_is_fast_forward, m_is_freezed;
47         eSocketNotifier *m_sn;
48         void video_event(int what);
49         Signal1<void, struct iTSMPEGDecoder::videoEvent> m_event;
50 public:
51         enum { MPEG2, MPEG4_H264 };
52         eDVBVideo(eDVBDemux *demux, int dev);
53         void stop();
54 #if HAVE_DVB_API_VERSION < 3
55         int setPid(int pid);
56         int startPid();
57         int start();
58         int stopPid();
59 #else
60         int startPid(int pid, int type=MPEG2);
61 #endif
62         void flush();
63         void freeze();
64         int setSlowMotion(int repeat);
65         int setFastForward(int skip);
66         void unfreeze();
67         int getPTS(pts_t &now);
68         virtual ~eDVBVideo();
69         RESULT connectEvent(const Slot1<void, struct iTSMPEGDecoder::videoEvent> &event, ePtr<eConnection> &conn);
70 };
71
72 class eDVBPCR: public iObject
73 {
74 DECLARE_REF(eDVBPCR);
75 private:
76         ePtr<eDVBDemux> m_demux;
77         int m_fd_demux;
78 public:
79         eDVBPCR(eDVBDemux *demux);
80 #if HAVE_DVB_API_VERSION < 3
81         int setPid(int pid);
82         int startPid();
83 #else
84         int startPid(int pid);
85 #endif
86         void stop();
87         virtual ~eDVBPCR();
88 };
89
90 class eDVBTText: public iObject
91 {
92 DECLARE_REF(eDVBTText);
93 private:
94         ePtr<eDVBDemux> m_demux;
95         int m_fd_demux;
96 public:
97         eDVBTText(eDVBDemux *demux);
98         int startPid(int pid);
99         void stop();
100         virtual ~eDVBTText();
101 };
102
103 class eTSMPEGDecoder: public Object, public iTSMPEGDecoder
104 {
105         static int m_pcm_delay;
106         static int m_ac3_delay;
107         static int m_audio_channel;
108 DECLARE_REF(eTSMPEGDecoder);
109         std::string m_radio_pic;
110         ePtr<eDVBDemux> m_demux;
111         ePtr<eDVBAudio> m_audio;
112         ePtr<eDVBVideo> m_video;
113         ePtr<eDVBPCR> m_pcr;
114         ePtr<eDVBTText> m_text;
115         int m_vpid, m_vtype, m_apid, m_atype, m_pcrpid, m_textpid;
116         enum
117         {
118                 changeVideo = 1, 
119                 changeAudio = 2, 
120                 changePCR   = 4,
121                 changeText  = 8
122         };
123         int m_changed, m_decoder;
124         int m_is_ff, m_is_sm, m_is_trickmode;
125         int setState();
126         ePtr<eConnection> m_demux_event_conn;
127         ePtr<eConnection> m_video_event_conn;
128         
129         void demux_event(int event);
130         void video_event(struct videoEvent);
131         Signal1<void, struct videoEvent> m_video_event;
132         int m_video_clip_fd;
133         eTimer m_showSinglePicTimer;
134         void finishShowSinglePic(); // called by timer
135 public:
136         enum { pidNone = -1 };
137         eTSMPEGDecoder(eDVBDemux *demux, int decoder);
138         virtual ~eTSMPEGDecoder();
139         RESULT setVideoPID(int vpid, int type);
140         RESULT setAudioPID(int apid, int type);
141         RESULT setAudioChannel(int channel);
142         int getAudioChannel();
143         RESULT setPCMDelay(int delay);
144         int getPCMDelay() { return m_pcm_delay; }
145         RESULT setAC3Delay(int delay);
146         int getAC3Delay() { return m_ac3_delay; }
147         RESULT setSyncPCR(int pcrpid);
148         RESULT setTextPID(int textpid);
149         RESULT setSyncMaster(int who);
150         RESULT start();
151         RESULT preroll();
152         RESULT freeze(int cont);
153         RESULT unfreeze();
154         RESULT setSinglePictureMode(int when);
155         RESULT setPictureSkipMode(int what);
156         RESULT setFastForward(int frames_to_skip);
157         RESULT setSlowMotion(int repeat);
158         RESULT setZoom(int what);
159         RESULT flush();
160         RESULT setTrickmode(int what);
161         RESULT showSinglePic(const char *filename);
162         RESULT setRadioPic(const std::string &filename);
163                 /* what 0=auto, 1=video, 2=audio. */
164         RESULT getPTS(int what, pts_t &pts);
165         RESULT connectVideoEvent(const Slot1<void, struct videoEvent> &event, ePtr<eConnection> &connection);
166 };
167
168 #endif