use AUDIO_GET_STC, VIDEO_GET_STC
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 17 Feb 2006 16:44:45 +0000 (16:44 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 17 Feb 2006 16:44:45 +0000 (16:44 +0000)
lib/dvb/decoder.cpp
lib/dvb/decoder.h
lib/dvb/dvb.cpp
lib/dvb/idvb.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 8e21dca..0e6f86d 100644 (file)
 #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)
@@ -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;
+}
index b8b5878..4728499 100644 (file)
@@ -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
index 11b1285..4a3adf5 100644 (file)
@@ -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);
index eacc492..2f9d7d9 100644 (file)
@@ -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
index 3487c3e..5f5aae6 100644 (file)
@@ -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)
index 2785ce2..42e3801 100644 (file)
@@ -142,6 +142,7 @@ private:
        Signal2<void,iPlayableService*,int> 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;