write iframes two times is enough
[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, i.e. convert to zero-based */
33         int fixupPTS(const off_t &offset, pts_t &ts);
34
35                 /* get PTS before offset */     
36         int getPTS(off_t &offset, pts_t &pts);
37         
38                 /* inter/extrapolate timestamp from offset */
39         pts_t getInterpolated(off_t offset);
40         
41         off_t getAccessPoint(pts_t ts);
42         
43         int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction);
44         
45         bool empty();
46 };
47
48         /* Now we define the parser's state: */
49 class eMPEGStreamParserTS
50 {
51 public:
52         eMPEGStreamParserTS(eMPEGStreamInformation &streaminfo);
53         void parseData(off_t offset, const void *data, unsigned int len);
54         void setPid(int pid);
55 private:
56         eMPEGStreamInformation &m_streaminfo;
57         unsigned char m_pkt[188];
58         int m_pktptr;
59         int processPacket(const unsigned char *pkt, off_t offset);
60         inline int wantPacket(const unsigned char *hdr) const;
61         int m_pid;
62         int m_need_next_packet;
63         int m_skip;
64 };
65
66 #endif