5ca6263d3a957ab80eb2f6aba2fbc9280a99115d
[enigma2.git] / lib / dvb / pvrparse.h
1 #ifndef __include_lib_dvb_pvrparse_h
2 #define __include_lib_dvb_pvrparse_h
3
4 #include <lib/dvb/idvb.h>
5 #include <map>
6 #include <set>
7
8         /* This module parses TS data and collects valuable information  */
9         /* about it, like PTS<->offset correlations and sequence starts. */
10
11         /* At first, we define the collector class: */
12 class eMPEGStreamInformation
13 {
14 public:
15                 /* we order by off_t here, since the timestamp may */
16                 /* wrap around. */
17                 /* we only record sequence start's pts values here. */
18         std::map<off_t, pts_t> m_access_points;
19                 /* timestampDelta is in fact the difference between */
20                 /* the PTS in the stream and a real PTS from 0..max */
21         std::map<off_t, pts_t> m_timestamp_deltas;
22         
23         int save(const char *filename);
24         int load(const char *filename);
25         
26                 /* recalculates timestampDeltas */
27         void fixupDiscontinuties();
28         
29                 /* get delta at specific offset */
30         pts_t getDelta(off_t offset);
31         
32                 /* fixup timestamp near offset */
33         pts_t fixuppts_t(off_t offset, pts_t ts);
34         
35                 /* inter/extrapolate timestamp from offset */
36         pts_t getInterpolated(off_t offset);
37         
38         off_t getAccessPoint(pts_t ts);
39         
40         bool empty();
41 };
42
43         /* Now we define the parser's state: */
44 class eMPEGStreamParserTS
45 {
46 public:
47         eMPEGStreamParserTS(eMPEGStreamInformation &streaminfo);
48         void parseData(off_t offset, const void *data, unsigned int len);
49         void setPid(int pid);
50 private:
51         eMPEGStreamInformation &m_streaminfo;
52         unsigned char m_pkt[188];
53         int m_pktptr;
54         int processPacket(const unsigned char *pkt, off_t offset);
55         inline int wantPacket(const unsigned char *hdr) const;
56         int m_pid;
57         int m_need_next_packet;
58         int m_skip;
59 };
60
61 #endif