1 #ifndef __lib_dvb_tstools_h
2 #define __lib_dvb_tstools_h
5 #include <lib/dvb/pvrparse.h>
6 #include <lib/base/rawfile.h>
7 #include <lib/base/elock.h>
10 * Note: we're interested in PTS values, not STC values.
11 * thus we're evaluating PES headers, not adaption fields.
14 typedef long long pts_t;
22 int openFile(const char *filename, int nostreaminfo = 0);
25 void setSyncPID(int pid);
26 void setSearchRange(int maxrange);
28 /* get first PTS *after* the given offset. */
29 /* pts values are zero-based. */
30 int getPTS(off_t &offset, pts_t &pts, int fixed=0);
32 /* this fixes up PTS to end up in a [0..len) range.
33 discontinuities etc. are handled here.
36 offset - approximate offset in file to resolve ambiguities
37 pts - video-pts (i.e. current STC of video decoder)
39 pts - zero-based PTS value
41 int fixupPTS(const off_t &offset, pts_t &pts);
43 /* get (approximate) offset corresponding to PTS */
44 int getOffset(off_t &offset, pts_t &pts, int marg=0);
46 int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction);
51 int calcLen(pts_t &len);
53 int calcBitrate(); /* in bits/sec */
56 int takeSample(off_t off, pts_t &p);
58 int findPMT(int &pmt_pid, int &service_id);
64 frametypeAll = frametypeI | frametypeP | frametypeB
66 /** findFrame: finds a specific frame at a given position
68 findFrame will look for the specified frame type starting at the given position, moving forward
69 (when direction is >0) or backward (when direction is <0). (direction=0 is a special case and also moves
70 forward, but starts with the last frame.)
72 return values are the new offset, the length of the found frame (both unaligned), and the (signed)
73 number of frames skipped. */
74 int findFrame(off_t &offset, size_t &len, int &direction, int frame_types = frametypeI);
75 int findNextPicture(off_t &offset, size_t &len, int &distance, int frame_types = frametypeAll);
80 eSingleLock m_file_lock;
83 int m_begin_valid, m_end_valid;
84 pts_t m_pts_begin, m_pts_end;
85 off_t m_offset_begin, m_offset_end;
87 /* for simple linear interpolation */
88 std::map<pts_t, off_t> m_samples;
91 eMPEGStreamInformation m_streaminfo;
93 off_t m_last_filelength;