some fixes
[vuplus_dvbapp] / 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
7 /*
8  * Note: we're interested in PTS values, not STC values.
9  * thus we're evaluating PES headers, not adaption fields.
10  */
11
12 typedef long long pts_t;
13
14 class eDVBTSTools
15 {
16 public:
17         eDVBTSTools();
18         ~eDVBTSTools();
19
20         int openFile(const char *filename);
21         void closeFile();
22         
23         void setSyncPID(int pid);
24         void setSearchRange(int maxrange);
25         
26                 /* get first PTS *after* the given offset. */
27                 /* pts values are zero-based. */
28         int getPTS(off_t &offset, pts_t &pts, int fixed=0);
29         
30                 /* this fixes up PTS to end up in a [0..len) range.
31                    discontinuities etc. are handled here.
32                 
33                   input:        
34                     offset - approximate offset in file to resolve ambiguities
35                     pts - video-pts (i.e. current STC of video decoder)
36                   output:
37                     pts - zero-based PTS value
38                 */
39         int fixupPTS(const off_t &offset, pts_t &pts);
40         
41         void calcBegin();
42         void calcEnd();
43         
44         int calcLen(pts_t &len);
45         
46         int calcBitrate(); /* in bits/sec */
47         
48 private:
49         int m_fd, m_pid;
50         int m_maxrange;
51         
52         int m_begin_valid, m_end_valid;
53         pts_t m_pts_begin, m_pts_end;
54         off_t m_offset_begin, m_offset_end;
55         
56         eMPEGStreamInformation m_streaminfo;
57         int m_use_streaminfo;
58 };
59
60 #endif