+#include <config.h>
#include <lib/dvb/tstools.h>
+#include <lib/base/eerror.h>
#include <unistd.h>
#include <fcntl.h>
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;
+}
* thus we're not evaluating PES headers, not adaption fields.
*/
-typedef unsigned long long pts_t;
+typedef long long pts_t;
class eDVBTSTools
{
/* get first PTS *after* the given offset. */
int getPTS(off_t &offset, pts_t &pts);
+ int getPosition(off_t &offset, pts_t &pts);
+
void calcBegin();
void calcEnd();
int calcLen(pts_t &len);
+ int calcBitrate(); /* in bits/sec */
+
private:
int m_fd, m_pid;
int m_maxrange;