X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;f=lib%2Fdvb%2Fpvrparse.h;h=5f99700291b03678014c877a3873563b89560bd9;hb=1d557af556c71a9c658deea9cec783a66903c136;hp=5ca6263d3a957ab80eb2f6aba2fbc9280a99115d;hpb=fe478efd1c354b304a3b68aa8fbcc5e5a53e7833;p=vuplus_dvbapp diff --git a/lib/dvb/pvrparse.h b/lib/dvb/pvrparse.h old mode 100644 new mode 100755 index 5ca6263..5f99700 --- a/lib/dvb/pvrparse.h +++ b/lib/dvb/pvrparse.h @@ -12,6 +12,11 @@ class eMPEGStreamInformation { public: + eMPEGStreamInformation(); + ~eMPEGStreamInformation(); + + void writeClose(); + void readClose(); /* we order by off_t here, since the timestamp may */ /* wrap around. */ /* we only record sequence start's pts values here. */ @@ -19,8 +24,12 @@ public: /* timestampDelta is in fact the difference between */ /* the PTS in the stream and a real PTS from 0..max */ std::map m_timestamp_deltas; - - int save(const char *filename); + + /* these are non-fixed up pts value (like m_access_points), just used to accelerate stuff. */ + std::multimap m_pts_to_offset; + + int startSave(const char *filename); + int stopSave(void); int load(const char *filename); /* recalculates timestampDeltas */ @@ -29,15 +38,42 @@ public: /* get delta at specific offset */ pts_t getDelta(off_t offset); - /* fixup timestamp near offset */ - pts_t fixuppts_t(off_t offset, pts_t ts); + /* fixup timestamp near offset, i.e. convert to zero-based */ + int fixupPTS(const off_t &offset, pts_t &ts); + + /* get PTS before offset */ + int getPTS(off_t &offset, pts_t &pts); /* inter/extrapolate timestamp from offset */ pts_t getInterpolated(off_t offset); - off_t getAccessPoint(pts_t ts); + off_t getAccessPoint(pts_t ts, int marg=0); - bool empty(); + int getNextAccessPoint(pts_t &ts, const pts_t &start, int direction); + + bool hasAccessPoint() { return !m_access_points.empty(); } + + bool hasStructure() { return !m_structure_read ? false : true; } + + typedef unsigned long long structure_data; + /* this is usually: + sc | (other_information << 8) + but is really specific to the used video encoder. + */ + void writeStructureEntry(off_t offset, structure_data data); + + /* get a structure entry at given offset (or previous one, if no exact match was found). + optionall, return next element. Offset will be returned. this allows you to easily + get previous and next structure elements. */ + int getStructureEntry(off_t &offset, unsigned long long &data, int get_next); + int getStructureEntry_next(off_t &offset, unsigned long long &data); + int getStructureEntry_prev(off_t &offset, unsigned long long &data); + int update_structure_cache_entries(off_t offset); + + std::string m_filename; + int m_structure_cache_entries; + unsigned long long m_structure_cache[1024]; + FILE *m_structure_read, *m_structure_write; }; /* Now we define the parser's state: */ @@ -46,16 +82,21 @@ class eMPEGStreamParserTS public: eMPEGStreamParserTS(eMPEGStreamInformation &streaminfo); void parseData(off_t offset, const void *data, unsigned int len); - void setPid(int pid); + void setPid(int pid, int streamtype); + int getLastPTS(pts_t &last_pts); + void enableAccessPoints(bool enable) { m_enable_accesspoints = enable; } private: eMPEGStreamInformation &m_streaminfo; unsigned char m_pkt[188]; int m_pktptr; int processPacket(const unsigned char *pkt, off_t offset); inline int wantPacket(const unsigned char *hdr) const; - int m_pid; + int m_pid, m_streamtype; int m_need_next_packet; int m_skip; + int m_last_pts_valid; + pts_t m_last_pts; + bool m_enable_accesspoints; }; #endif