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 /* 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;
26 int save(const char *filename);
27 int load(const char *filename);
29 /* recalculates timestampDeltas */
30 void fixupDiscontinuties();
32 /* get delta at specific offset */
33 pts_t getDelta(off_t offset);
35 /* fixup timestamp near offset, i.e. convert to zero-based */
36 int fixupPTS(const off_t &offset, pts_t &ts);
38 /* get PTS before offset */
39 int getPTS(off_t &offset, pts_t &pts);
41 /* inter/extrapolate timestamp from offset */
42 pts_t getInterpolated(off_t offset);
44 off_t getAccessPoint(pts_t ts);
46 int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction);
51 /* Now we define the parser's state: */
52 class eMPEGStreamParserTS
55 eMPEGStreamParserTS(eMPEGStreamInformation &streaminfo);
56 void parseData(off_t offset, const void *data, unsigned int len);
58 int getLastPTS(pts_t &last_pts);
60 eMPEGStreamInformation &m_streaminfo;
61 unsigned char m_pkt[188];
63 int processPacket(const unsigned char *pkt, off_t offset);
64 inline int wantPacket(const unsigned char *hdr) const;
66 int m_need_next_packet;