From b96f203b700c91e463eff20889d734119530bce0 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 17 Feb 2006 16:44:45 +0000 Subject: [PATCH] use AUDIO_GET_STC, VIDEO_GET_STC --- lib/dvb/decoder.cpp | 42 +++++++++++++++++++++++++++++++++++++- lib/dvb/decoder.h | 6 ++++++ lib/dvb/dvb.cpp | 18 +++++++++------- lib/dvb/idvb.h | 2 ++ lib/service/servicedvb.cpp | 19 ++++++++++++++++- lib/service/servicedvb.h | 1 + 6 files changed, 79 insertions(+), 9 deletions(-) diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp index 8e21dcad..0e6f86d3 100644 --- a/lib/dvb/decoder.cpp +++ b/lib/dvb/decoder.cpp @@ -25,6 +25,12 @@ #include #include + /* 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) @@ -130,7 +136,12 @@ void eDVBAudio::unfreeze() 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) @@ -236,6 +247,11 @@ int eDVBVideo::setFastForward(int skip) 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() { @@ -642,3 +658,27 @@ RESULT eTSMPEGDecoder::setTrickmode(int what) 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; +} diff --git a/lib/dvb/decoder.h b/lib/dvb/decoder.h index b8b58786..47284999 100644 --- a/lib/dvb/decoder.h +++ b/lib/dvb/decoder.h @@ -22,6 +22,7 @@ public: void flush(); void freeze(); void unfreeze(); + int getPTS(pts_t &now); virtual ~eDVBAudio(); }; @@ -46,6 +47,7 @@ public: int setSlowMotion(int repeat); int setFastForward(int skip); void unfreeze(); + int getPTS(pts_t &now); virtual ~eDVBVideo(); }; @@ -117,5 +119,9 @@ public: RESULT setZoom(int what); RESULT flush(); RESULT setTrickmode(int what); + + /* what 0=auto, 1=video, 2=audio. */ + RESULT getPTS(int what, pts_t &pts); }; + #endif diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 11b1285a..4a3adf55 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -997,15 +997,19 @@ RESULT eDVBChannel::getCurrentPosition(iDVBDemux *decoding_demux, pts_t &pos, in return -1; pts_t now; + int r; - /* TODO: this is a gross hack. */ - r = decoding_demux->getSTC(now, mode ? 128 : 0); - - if (r) + + if (mode == 0) /* demux */ { - eDebug("demux getSTC failed"); - return -1; - } + r = decoding_demux->getSTC(now, 0); + if (r) + { + eDebug("demux getSTC failed"); + return -1; + } + } else + now = pos; /* fixup supplied */ off_t off = 0; /* TODO: fixme */ r = m_tstools.fixupPTS(off, now); diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h index eacc4929..2f9d7d9b 100644 --- a/lib/dvb/idvb.h +++ b/lib/dvb/idvb.h @@ -549,6 +549,8 @@ public: virtual RESULT setZoom(int what)=0; virtual RESULT setTrickmode(int what) = 0; + + virtual RESULT getPTS(int what, pts_t &pts) = 0; }; #endif diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 3487c3e6..5f5aae65 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -604,6 +604,11 @@ void eDVBServicePlay::serviceEvent(int event) updateTimeshiftPids(); if (!m_timeshift_active) updateDecoder(); + if (m_first_program_info && m_is_pvr) + { + m_first_program_info = 0; + seekTo(0); + } m_event((iPlayableService*)this, evUpdatedInfo); break; } @@ -637,6 +642,7 @@ RESULT eDVBServicePlay::start() two (one for decoding, one for data source), as we must be prepared to start recording from the data demux. */ m_cue = new eCueSheet(); + m_first_program_info = 1; r = m_service_handler.tune((eServiceReferenceDVB&)m_reference, m_is_pvr, m_cue); m_event(this, evStart); m_event((iPlayableService*)this, evSeekableStatusChanged); @@ -815,7 +821,18 @@ RESULT eDVBServicePlay::getPlayPosition(pts_t &pos) if ((m_timeshift_enabled ? m_service_handler_timeshift : m_service_handler).getPVRChannel(pvr_channel)) return -1; - return pvr_channel->getCurrentPosition(m_decode_demux, pos, 1); + int r = 0; + + /* if there is a decoder, use audio or video PTS */ + if (m_decoder) + { + r = m_decoder->getPTS(0, pos); + if (r) + return r; + } + + /* fixup */ + return pvr_channel->getCurrentPosition(m_decode_demux, pos, m_decoder ? 1 : 0); } RESULT eDVBServicePlay::setTrickmode(int trick) diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 2785ce2a..42e38013 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -142,6 +142,7 @@ private: Signal2 m_event; int m_is_pvr, m_is_paused, m_timeshift_enabled, m_timeshift_active; + int m_first_program_info; std::string m_timeshift_file; int m_timeshift_fd; -- 2.30.2