add getOffset and fix pvrparse for that
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 27 Feb 2006 03:06:55 +0000 (03:06 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 27 Feb 2006 03:06:55 +0000 (03:06 +0000)
lib/dvb/pvrparse.cpp
lib/dvb/tstools.cpp
lib/dvb/tstools.h

index 58b215ba00cabcca9278c5eae018dfe347e01269..bde43765595c0b46459a56471f0f564bca980eae 100644 (file)
@@ -208,9 +208,7 @@ off_t eMPEGStreamInformation::getAccessPoint(pts_t ts)
        off_t last = 0;
        for (std::map<off_t, pts_t>::const_iterator i(m_access_points.begin()); i != m_access_points.end(); ++i)
        {
-               std::map<off_t, pts_t>::const_iterator d = m_timestamp_deltas.find(i->first);
-               if (d != m_timestamp_deltas.end())
-                       delta = d->second;
+               pts_t delta = getDelta(i->first);
                pts_t c = i->second - delta;
                if (c > ts)
                        break;
index 51cc994c560758c9b4480e34423e6e48798b643c..e440aecad5753b601cd75dbaf6871d424667bb5c 100644 (file)
@@ -172,6 +172,25 @@ int eDVBTSTools::fixupPTS(const off_t &offset, pts_t &now)
        }
 }
 
+int eDVBTSTools::getOffset(off_t &offset, pts_t &pts)
+{
+       if (m_use_streaminfo)
+       {
+               offset = m_streaminfo.getAccessPoint(pts);
+               return 0;
+       } else
+       {
+               int bitrate = calcBitrate(); /* in bits/s */
+               if (bitrate <= 0)
+                       return -1;
+               
+               offset = (pts * (pts_t)bitrate) / 8ULL / 90000ULL;
+               offset -= offset % 188;
+
+               return 0;
+       }
+}
+
 void eDVBTSTools::calcBegin()
 {
        if (m_fd < 0)   
index 723207d312f29cf2036a54c826b824fda085ab84..f23d8108cf5247090056476cc6d90091e2acc39b 100644 (file)
@@ -38,6 +38,9 @@ public:
                */
        int fixupPTS(const off_t &offset, pts_t &pts);
        
+               /* get (approximate) offset corresponding to PTS */
+       int getOffset(off_t &offset, pts_t &pts);
+       
        void calcBegin();
        void calcEnd();