trunk 20080912
[gitenigma.git] / include / lib / dvb / pvrparse.h
blobb26dd8105e74b26df246c3be69ba71b1633b9682
1 #ifndef __include_lib_dvb_pvrparse_h
2 #define __include_lib_dvb_pvrparse_h
4 #include <map>
5 #include <set>
7 /* This module parses TS data and collects valuable information */
8 /* about it, like PTS<->offset correlations and sequence starts. */
10 /* At first, we define the collector class: */
11 class eMPEGStreamInformation
13 public:
14 typedef unsigned long long Timestamp;
15 typedef unsigned long long off_t;
16 /* we order by off_t here, since the timestamp may */
17 /* wrap around. */
18 /* we only record sequence start's pts values here. */
19 std::map<off_t, Timestamp> accessPoints;
20 /* timestampDelta is in fact the difference between */
21 /* the PTS in the stream and a real PTS from 0..max */
22 std::map<off_t, Timestamp> timestampDeltas;
24 int save(const char *filename);
25 int load(const char *filename);
27 /* recalculates timestampDeltas */
28 void fixupDiscontinuties();
30 /* get delta at specific offset */
31 Timestamp getDelta(off_t offset);
33 /* inter/extrapolate timestamp from offset */
34 Timestamp getInterpolated(off_t offset);
36 off_t getAccessPoint(Timestamp ts);
38 operator bool();
41 /* Now we define the parser's state: */
42 class eMPEGStreamParserTS
44 eMPEGStreamInformation &streaminfo;
45 unsigned char pkt[188];
46 int pktptr;
47 int processPacket(const unsigned char *pkt, eMPEGStreamInformation::off_t offset);
48 inline int wantPacket(const unsigned char *hdr) const;
49 int pid;
50 int needNextPacket;
51 int skip;
52 public:
53 eMPEGStreamParserTS(eMPEGStreamInformation &streaminfo);
54 void parseData(eMPEGStreamInformation::off_t offset, const void *data, unsigned int len);
55 void setPid(int pid);
58 #endif