-#include <config.h>
#include <lib/base/eerror.h>
#include <lib/dvb/decoder.h>
#if HAVE_DVB_API_VERSION < 3
#include <sys/ioctl.h>
#include <errno.h>
+ /* these are quite new... */
+#ifndef AUDIO_GET_PTS
+#define AUDIO_GET_PTS _IOR('o', 19, __u64)
+#define VIDEO_GET_PTS _IOR('o', 57, __u64)
+#endif
+
DEFINE_REF(eDVBAudio);
eDVBAudio::eDVBAudio(eDVBDemux *demux, int dev): m_demux(demux)
if (::ioctl(m_fd, AUDIO_CONTINUE) < 0)
eDebug("video: AUDIO_CONTINUE: %m");
}
-
+
+int eDVBAudio::getPTS(pts_t &now)
+{
+ return ::ioctl(m_fd, AUDIO_GET_PTS, &now);
+}
+
eDVBAudio::~eDVBAudio()
{
if (m_fd >= 0)
m_is_fast_forward = skip;
return ::ioctl(m_fd, VIDEO_FAST_FORWARD, skip);
}
+
+int eDVBVideo::getPTS(pts_t &now)
+{
+ return ::ioctl(m_fd, VIDEO_GET_PTS, &now);
+}
eDVBVideo::~eDVBVideo()
{
::close(m_fd_demux);
}
+DEFINE_REF(eDVBTText);
+
+eDVBTText::eDVBTText(eDVBDemux *demux): m_demux(demux)
+{
+ char filename[128];
+#if HAVE_DVB_API_VERSION < 3
+ sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
+#else
+ sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
+#endif
+ m_fd_demux = ::open(filename, O_RDWR);
+ if (m_fd_demux < 0)
+ eWarning("%s: %m", filename);
+}
+
+int eDVBTText::startPid(int pid)
+{
+ if (m_fd_demux < 0)
+ return -1;
+ dmx_pes_filter_params pes;
+
+ pes.pid = pid;
+ pes.input = DMX_IN_FRONTEND;
+ pes.output = DMX_OUT_DECODER;
+ pes.pes_type = DMX_PES_TELETEXT;
+ pes.flags = 0;
+ if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
+ {
+ eWarning("video: DMX_SET_PES_FILTER: %m");
+ return -errno;
+ }
+ if (::ioctl(m_fd_demux, DMX_START) < 0)
+ {
+ eWarning("video: DMX_START: %m");
+ return -errno;
+ }
+ return 0;
+}
+
+void eDVBTText::stop()
+{
+ if (::ioctl(m_fd_demux, DMX_STOP) < 0)
+ eWarning("video: DMX_STOP: %m");
+}
+
+eDVBTText::~eDVBTText()
+{
+ if (m_fd_demux >= 0)
+ ::close(m_fd_demux);
+}
+
DEFINE_REF(eTSMPEGDecoder);
int eTSMPEGDecoder::setState()
int res = 0;
int noaudio = m_is_sm || m_is_ff || m_is_trickmode;
-
+ int nott = noaudio; /* actually same conditions */
+
if ((noaudio && m_audio) || (!m_audio && !noaudio))
m_changed |= changeAudio;
+ if ((nott && m_text) || (!m_text && !nott))
+ m_changed |= changeText;
+
#if HAVE_DVB_API_VERSION < 3
if (m_changed & changeAudio && m_audio)
m_audio->stopPid();
m_changed &= ~changeAudio;
}
#else
+ if (m_changed & changePCR)
+ {
+ if (m_pcr)
+ m_pcr->stop();
+ m_pcr = 0;
+ if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF))
+ {
+ m_pcr = new eDVBPCR(m_demux);
+ if (m_pcr->startPid(m_pcrpid))
+ {
+ eWarning("pcr: startpid failed!");
+ res = -1;
+ }
+ }
+ m_changed &= ~changePCR;
+ }
if (m_changed & changeVideo)
{
eDebug("VIDEO CHANGED (to %04x)", m_vpid);
}
m_changed &= ~changeVideo;
}
- if (m_changed & changePCR)
- {
- if (m_pcr)
- m_pcr->stop();
- m_pcr = 0;
- if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF))
- {
- m_pcr = new eDVBPCR(m_demux);
- if (m_pcr->startPid(m_pcrpid))
- {
- eWarning("pcr: startpid failed!");
- res = -1;
- }
- }
- m_changed &= ~changePCR;
- }
if (m_changed & changeAudio)
{
if (m_audio)
}
m_changed &= ~changeAudio;
}
+ if (m_changed & changeText)
+ {
+ if (m_text)
+ m_text->stop();
+ m_text = 0;
+ if ((m_textpid >= 0) && (m_textpid < 0x1FFF) && !nott)
+ {
+ m_text = new eDVBTText(m_demux);
+ if (m_text->startPid(m_textpid))
+ {
+ eWarning("text: startpid failed!");
+ res = -1;
+ }
+ }
+ m_changed &= ~changeText;
+ }
#endif
return res;
}
return 0;
}
+RESULT eTSMPEGDecoder::setTextPID(int textpid)
+{
+ if (m_textpid != textpid)
+ {
+ m_changed |= changeText;
+ m_textpid = textpid;
+ }
+ return 0;
+}
+
RESULT eTSMPEGDecoder::setSyncMaster(int who)
{
return -1;
setState();
return 0;
}
+
+RESULT eTSMPEGDecoder::getPTS(int what, pts_t &pts)
+{
+ if (what == 0) /* auto */
+ what = m_video ? 1 : 2;
+
+ if (what == 1) /* video */
+ {
+ if (m_video)
+ return m_video->getPTS(pts);
+ else
+ return -1;
+ }
+
+ if (what == 2) /* audio */
+ {
+ if (m_audio)
+ return m_audio->getPTS(pts);
+ else
+ return -1;
+ }
+
+ return -1;
+}