1 #ifndef __include_lib_dvb_pvrparse_h
2 #define __include_lib_dvb_pvrparse_h
4 #include <lib/dvb/idvb.h>
8 /* This module parses TS data and collects valuable information */
9 /* about it, like PTS<->offset correlations and sequence starts. */
11 /* At first, we define the collector class: */
12 class eMPEGStreamInformation
15 /* we order by off_t here, since the timestamp may */
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;
23 int save(const char *filename);
24 int load(const char *filename);
26 /* recalculates timestampDeltas */
27 void fixupDiscontinuties();
29 /* get delta at specific offset */
30 pts_t getDelta(off_t offset);
32 /* fixup timestamp near offset, i.e. convert to zero-based */
33 int fixupPTS(const off_t &offset, pts_t &ts);
35 /* get PTS before offset */
36 int getPTS(off_t &offset, pts_t &pts);
38 /* inter/extrapolate timestamp from offset */
39 pts_t getInterpolated(off_t offset);
41 off_t getAccessPoint(pts_t ts);
43 int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction);
48 /* Now we define the parser's state: */
49 class eMPEGStreamParserTS
52 eMPEGStreamParserTS(eMPEGStreamInformation &streaminfo);
53 void parseData(off_t offset, const void *data, unsigned int len);
56 eMPEGStreamInformation &m_streaminfo;
57 unsigned char m_pkt[188];
59 int processPacket(const unsigned char *pkt, off_t offset);
60 inline int wantPacket(const unsigned char *hdr) const;
62 int m_need_next_packet;