add getOffset and fix pvrparse for that
[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                 /* get (approximate) offset corresponding to PTS */
42         int getOffset(off_t &offset, pts_t &pts);
43         
44         void calcBegin();
45         void calcEnd();
46         
47         int calcLen(pts_t &len);
48         
49         int calcBitrate(); /* in bits/sec */
50         
51 private:
52         int m_fd, m_pid;
53         int m_maxrange;
54         
55         int m_begin_valid, m_end_valid;
56         pts_t m_pts_begin, m_pts_end;
57         off_t m_offset_begin, m_offset_end;
58         
59         eMPEGStreamInformation m_streaminfo;
60         int m_use_streaminfo;
61 };
62
63 #endif