parsing for /etc/timezone.xml added
[enigma2.git] / lib / dvb / tstools.cpp
index 5d1c7e354ae747d58d1b7ee26d1abcd0a5ec64c9..b83fd50aa6de36b0a006c1e38c10ea8beede13cf 100644 (file)
@@ -1,4 +1,6 @@
+#include <config.h>
 #include <lib/dvb/tstools.h>
 #include <lib/dvb/tstools.h>
+#include <lib/base/eerror.h>
 #include <unistd.h>
 #include <fcntl.h>
 
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -48,8 +50,6 @@ int eDVBTSTools::getPTS(off_t &offset, pts_t &pts)
 {
        if (m_fd < 0)
                return -1;
 {
        if (m_fd < 0)
                return -1;
-       if (m_pid < 0)
-               return -1;
 
        offset -= offset % 188;
        
 
        offset -= offset % 188;
        
@@ -82,8 +82,9 @@ int eDVBTSTools::getPTS(off_t &offset, pts_t &pts)
                
 //             printf("PID %04x, PUSI %d\n", pid, pusi);
                
                
 //             printf("PID %04x, PUSI %d\n", pid, pusi);
                
-               if (pid != m_pid)
-                       continue;
+               if (m_pid >= 0)
+                       if (pid != m_pid)
+                               continue;
                if (!pusi)
                        continue;
                
                if (!pusi)
                        continue;
                
@@ -149,3 +150,21 @@ int eDVBTSTools::calcLen(pts_t &len)
        return 0;
 }
 
        return 0;
 }
 
+int eDVBTSTools::calcBitrate()
+{
+       calcBegin(); calcEnd();
+       if (!(m_begin_valid && m_end_valid))
+               return -1;
+
+       pts_t len_in_pts = m_pts_end - m_pts_begin;
+       off_t len_in_bytes = m_offset_end - m_offset_begin;
+       
+       if (!len_in_pts)
+               return -1;
+       
+       unsigned long long bitrate = len_in_bytes * 90000 * 8 / len_in_pts;
+       if ((bitrate < 10000) || (bitrate > 100000000))
+               return -1;
+       
+       return bitrate;
+}