change iFrontendInformation api
[enigma2.git] / lib / dvb / tstools.h
1 #ifndef __lib_dvb_tstools_h
2 #define __lib_dvb_tstools_h
3
4 #include <sys/types.h>
5 #include <lib/dvb/pvrparse.h>
6 #include <lib/base/rawfile.h>
7
8 /*
9  * Note: we're interested in PTS values, not STC values.
10  * thus we're evaluating PES headers, not adaption fields.
11  */
12
13 typedef long long pts_t;
14
15 class eDVBTSTools
16 {
17 public:
18         eDVBTSTools();
19         ~eDVBTSTools();
20
21         int openFile(const char *filename);
22         void closeFile();
23         
24         void setSyncPID(int pid);
25         void setSearchRange(int maxrange);
26         
27                 /* get first PTS *after* the given offset. */
28                 /* pts values are zero-based. */
29         int getPTS(off_t &offset, pts_t &pts, int fixed=0);
30         
31                 /* this fixes up PTS to end up in a [0..len) range.
32                    discontinuities etc. are handled here.
33                 
34                   input:        
35                     offset - approximate offset in file to resolve ambiguities
36                     pts - video-pts (i.e. current STC of video decoder)
37                   output:
38                     pts - zero-based PTS value
39                 */
40         int fixupPTS(const off_t &offset, pts_t &pts);
41         
42                 /* get (approximate) offset corresponding to PTS */
43         int getOffset(off_t &offset, pts_t &pts);
44         
45         int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction);
46         
47         void calcBegin();
48         void calcEnd();
49         
50         int calcLen(pts_t &len);
51         
52         int calcBitrate(); /* in bits/sec */
53         
54         void takeSamples();
55         
56         int findPMT(int &pmt_pid, int &service_id);
57 private:
58         int m_pid;
59         int m_maxrange;
60         
61         eRawFile m_file;
62         
63         int m_begin_valid, m_end_valid;
64         pts_t m_pts_begin, m_pts_end;
65         off_t m_offset_begin, m_offset_end;
66         
67                 /* for simple linear interpolation */
68         std::map<pts_t, off_t> m_samples;
69         int m_samples_taken;
70         
71         eMPEGStreamInformation m_streaminfo;
72         int m_use_streaminfo;
73         off_t m_last_filelength;
74         int m_futile;
75 };
76
77 #endif