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 void setSource(ePtr<iTsSource> &source, const char *streaminfo_filename=NULL);
25 int openFile(const char *filename, int nostreaminfo = 0);
28 void setSyncPID(int pid);
29 void setSearchRange(int maxrange);
31 /* get first PTS *after* the given offset. */
32 /* pts values are zero-based. */
33 int getPTS(off_t &offset, pts_t &pts, int fixed=0);
35 /* this fixes up PTS to end up in a [0..len) range.
36 discontinuities etc. are handled here.
39 offset - approximate offset in file to resolve ambiguities
40 pts - video-pts (i.e. current STC of video decoder)
42 pts - zero-based PTS value
44 int fixupPTS(const off_t &offset, pts_t &pts);
46 /* get (approximate) offset corresponding to PTS */
47 int getOffset(off_t &offset, pts_t &pts, int marg=0);
49 int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction);
54 int calcLen(pts_t &len);
56 int calcBitrate(); /* in bits/sec */
59 int takeSample(off_t off, pts_t &p);
61 int findPMT(int &pmt_pid, int &service_id);
67 frametypeAll = frametypeI | frametypeP | frametypeB
69 /** findFrame: finds a specific frame at a given position
71 findFrame will look for the specified frame type starting at the given position, moving forward
72 (when direction is >0) or backward (when direction is <0). (direction=0 is a special case and also moves
73 forward, but starts with the last frame.)
75 return values are the new offset, the length of the found frame (both unaligned), and the (signed)
76 number of frames skipped. */
77 int findFrame(off_t &offset, size_t &len, int &direction, int frame_types = frametypeI);
78 int findNextPicture(off_t &offset, size_t &len, int &distance, int frame_types = frametypeAll);
83 ePtr<iTsSource> m_source;
85 int m_begin_valid, m_end_valid;
86 pts_t m_pts_begin, m_pts_end;
87 off_t m_offset_begin, m_offset_end;
89 /* for simple linear interpolation */
90 std::map<pts_t, off_t> m_samples;
93 eMPEGStreamInformation m_streaminfo;
95 off_t m_last_filelength;