pass service events to old instance of InfoBarBase until a new service is
[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                 /* these are non-fixed up pts value (like m_access_points), just used to accelerate stuff. */
24         std::multimap<pts_t, off_t> m_pts_to_offset; 
25
26         int save(const char *filename);
27         int load(const char *filename);
28         
29                 /* recalculates timestampDeltas */
30         void fixupDiscontinuties();
31         
32                 /* get delta at specific offset */
33         pts_t getDelta(off_t offset);
34         
35                 /* fixup timestamp near offset, i.e. convert to zero-based */
36         int fixupPTS(const off_t &offset, pts_t &ts);
37
38                 /* get PTS before offset */     
39         int getPTS(off_t &offset, pts_t &pts);
40         
41                 /* inter/extrapolate timestamp from offset */
42         pts_t getInterpolated(off_t offset);
43         
44         off_t getAccessPoint(pts_t ts);
45         
46         int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction);
47         
48         bool empty();
49 };
50
51         /* Now we define the parser's state: */
52 class eMPEGStreamParserTS
53 {
54 public:
55         eMPEGStreamParserTS(eMPEGStreamInformation &streaminfo);
56         void parseData(off_t offset, const void *data, unsigned int len);
57         void setPid(int pid);
58 private:
59         eMPEGStreamInformation &m_streaminfo;
60         unsigned char m_pkt[188];
61         int m_pktptr;
62         int processPacket(const unsigned char *pkt, off_t offset);
63         inline int wantPacket(const unsigned char *hdr) const;
64         int m_pid;
65         int m_need_next_packet;
66         int m_skip;
67 };
68
69 #endif