2 #include <lib/base/eerror.h>
3 #include <lib/dvb/decoder.h>
4 #if HAVE_DVB_API_VERSION < 3
5 #define audioStatus audio_status
6 #define videoStatus video_status
7 #define pesType pes_type
8 #define playState play_state
9 #define audioStreamSource_t audio_stream_source_t
10 #define videoStreamSource_t video_stream_source_t
11 #define streamSource stream_source
12 #define dmxPesFilterParams dmx_pes_filter_params
13 #define DMX_PES_VIDEO DMX_PES_VIDEO0
14 #define DMX_PES_AUDIO DMX_PES_AUDIO0
16 #include <ost/video.h>
17 #include <ost/audio.h>
19 #include <linux/dvb/audio.h>
20 #include <linux/dvb/video.h>
21 #include <linux/dvb/dmx.h>
26 #include <sys/ioctl.h>
29 DEFINE_REF(eDVBAudio);
31 eDVBAudio::eDVBAudio(eDVBDemux *demux, int dev): m_demux(demux)
34 #if HAVE_DVB_API_VERSION < 3
35 sprintf(filename, "/dev/dvb/card%d/audio%d", demux->adapter, dev);
37 sprintf(filename, "/dev/dvb/adapter%d/audio%d", demux->adapter, dev);
39 m_fd = ::open(filename, O_RDWR);
41 eWarning("%s: %m", filename);
42 #if HAVE_DVB_API_VERSION < 3
43 sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
45 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
47 m_fd_demux = ::open(filename, O_RDWR);
49 eWarning("%s: %m", filename);
52 int eDVBAudio::startPid(int pid)
54 eDebug("setting audio pid to %x", pid);
55 if ((m_fd < 0) || (m_fd_demux < 0))
57 dmx_pes_filter_params pes;
59 pes.input = DMX_IN_FRONTEND;
60 pes.output = DMX_OUT_DECODER;
61 pes.pes_type = DMX_PES_AUDIO; // DMX_PES_AUDIO0
63 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
65 eWarning("audio: DMX_SET_PES_FILTER: %m");
68 if (::ioctl(m_fd_demux, DMX_START) < 0)
70 eWarning("audio: DMX_START: %m");
73 if (::ioctl(m_fd, AUDIO_PLAY) < 0)
74 eWarning("audio: AUDIO_PLAY: %m");
78 void eDVBAudio::stop()
80 if (::ioctl(m_fd, AUDIO_STOP) < 0)
81 eWarning("audio: AUDIO_STOP: %m");
82 #if HAVE_DVB_API_VERSION > 2
83 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
84 eWarning("audio: DMX_STOP: %m");
88 #if HAVE_DVB_API_VERSION < 3
89 void eDVBAudio::stopPid()
91 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
92 eWarning("audio: DMX_STOP: %m");
96 eDVBAudio::~eDVBAudio()
104 DEFINE_REF(eDVBVideo);
106 eDVBVideo::eDVBVideo(eDVBDemux *demux, int dev): m_demux(demux)
109 #if HAVE_DVB_API_VERSION < 3
110 sprintf(filename, "/dev/dvb/card%d/video%d", demux->adapter, dev);
112 sprintf(filename, "/dev/dvb/adapter%d/video%d", demux->adapter, dev);
114 m_fd = ::open(filename, O_RDWR);
116 eWarning("%s: %m", filename);
117 #if HAVE_DVB_API_VERSION < 3
118 sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
120 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
122 m_fd_demux = ::open(filename, O_RDWR);
124 eWarning("%s: %m", filename);
127 int eDVBVideo::startPid(int pid)
129 eDebug("setting video pid to %x", pid);
130 if ((m_fd < 0) || (m_fd_demux < 0))
132 dmx_pes_filter_params pes;
135 pes.input = DMX_IN_FRONTEND;
136 pes.output = DMX_OUT_DECODER;
137 pes.pes_type = DMX_PES_VIDEO;
139 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
141 eWarning("video: DMX_SET_PES_FILTER: %m");
144 if (::ioctl(m_fd_demux, DMX_START) < 0)
146 eWarning("video: DMX_START: %m");
149 if (::ioctl(m_fd, VIDEO_PLAY) < 0)
150 eWarning("video: VIDEO_PLAY: %m");
156 void eDVBVideo::stop()
158 if (::ioctl(m_fd, VIDEO_STOP) < 0)
159 eWarning("video: VIDEO_STOP: %m");
160 #if HAVE_DVB_API_VERSION > 2
161 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
162 eWarning("video: DMX_STOP: %m");
166 #if HAVE_DVB_API_VERSION < 3
167 void eDVBVideo::stopPid()
169 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
170 eWarning("video: DMX_STOP: %m");
174 eDVBVideo::~eDVBVideo()
184 eDVBPCR::eDVBPCR(eDVBDemux *demux): m_demux(demux)
187 #if HAVE_DVB_API_VERSION < 3
188 sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
190 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
192 m_fd_demux = ::open(filename, O_RDWR);
194 eWarning("%s: %m", filename);
197 int eDVBPCR::startPid(int pid)
199 eDebug("setting pcr pid to %x", pid);
202 dmx_pes_filter_params pes;
205 pes.input = DMX_IN_FRONTEND;
206 pes.output = DMX_OUT_DECODER;
207 pes.pes_type = DMX_PES_PCR;
209 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
211 eWarning("video: DMX_SET_PES_FILTER: %m");
214 if (::ioctl(m_fd_demux, DMX_START) < 0)
216 eWarning("video: DMX_START: %m");
224 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
225 eWarning("video: DMX_STOP: %m");
234 DEFINE_REF(eTSMPEGDecoder);
236 int eTSMPEGDecoder::setState()
239 eDebug("changed %x", m_changed);
240 #if HAVE_DVB_API_VERSION < 3
241 if (m_changed & changeAudio && m_audio)
243 if (m_changed & changeVideo && m_video)
245 if (m_changed & changePCR && m_pcr)
250 if (m_changed & changeAudio && m_audio)
255 if (m_changed & changeVideo && m_video)
260 if (m_changed & changePCR)
262 m_pcr = new eDVBPCR(m_demux);
263 if (m_pcr->startPid(m_pcrpid))
265 eWarning("video: startpid failed!");
268 m_changed &= ~changePCR;
270 if (m_changed & changeVideo)
272 m_video = new eDVBVideo(m_demux, 0);
273 if (m_video->startPid(m_vpid))
275 eWarning("video: startpid failed!");
278 m_changed &= ~changeVideo;
280 if (m_changed & changeAudio)
282 m_audio = new eDVBAudio(m_demux, 0);
283 if (m_audio->startPid(m_apid))
285 eWarning("audio: startpid failed!");
288 m_changed &= ~changeAudio;
291 if (m_changed & changePCR)
296 if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF))
298 m_pcr = new eDVBPCR(m_demux);
299 if (m_pcr->startPid(m_pcrpid))
301 eWarning("video: startpid failed!");
305 m_changed &= ~changePCR;
307 if (m_changed & changeVideo)
312 m_video = new eDVBVideo(m_demux, 0);
313 if (m_video->startPid(m_vpid))
315 eWarning("video: startpid failed!");
318 m_changed &= ~changeVideo;
320 if (m_changed & changeAudio)
325 m_audio = new eDVBAudio(m_demux, 0);
326 if (m_audio->startPid(m_apid))
328 eWarning("audio: startpid failed!");
331 m_changed &= ~changeAudio;
337 eTSMPEGDecoder::eTSMPEGDecoder(eDVBDemux *demux, int decoder): m_demux(demux), m_changed(0)
341 eTSMPEGDecoder::~eTSMPEGDecoder()
343 m_vpid = m_apid = m_pcrpid = pidNone;
348 RESULT eTSMPEGDecoder::setVideoPID(int vpid)
352 m_changed |= changeVideo;
358 RESULT eTSMPEGDecoder::setAudioPID(int apid, int type)
360 if ((m_apid != apid) || (m_atype != type))
362 m_changed |= changeAudio;
369 RESULT eTSMPEGDecoder::setSyncPCR(int pcrpid)
371 if (m_pcrpid != pcrpid)
373 m_changed |= changePCR;
379 RESULT eTSMPEGDecoder::setSyncMaster(int who)
384 RESULT eTSMPEGDecoder::start()
389 RESULT eTSMPEGDecoder::freeze(int cont)
394 RESULT eTSMPEGDecoder::unfreeze()
399 RESULT eTSMPEGDecoder::setSinglePictureMode(int when)
404 RESULT eTSMPEGDecoder::setPictureSkipMode(int what)
409 RESULT eTSMPEGDecoder::setSlowMotion(int repeat)
414 RESULT eTSMPEGDecoder::setZoom(int what)