X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fdvb%2Fpesparse.cpp;h=b0352fe60faa7f20e72bab1b8c881fe0dc04f320;hp=7e05c96ac562013d7191e8d2d955a8c513802908;hb=0ba26361a853f91ebc36c9c11f6771df74008535;hpb=141be00b0febd77db0bca46e9a788f018d07aeb8 diff --git a/lib/dvb/pesparse.cpp b/lib/dvb/pesparse.cpp index 7e05c96..b0352fe 100644 --- a/lib/dvb/pesparse.cpp +++ b/lib/dvb/pesparse.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -11,12 +12,13 @@ ePESParser::ePESParser() setStreamID(0); /* must be overridden */ } -void ePESParser::setStreamID(unsigned char id) +void ePESParser::setStreamID(unsigned char id, unsigned char id_mask) { m_header[3] = id; + m_stream_id_mask = id_mask; } -void ePESParser::processData(unsigned char *p, int len) +void ePESParser::processData(const __u8 *p, int len) { /* this is a state machine, handling arbitary amounts of pes-formatted data. */ while (len) @@ -40,13 +42,21 @@ void ePESParser::processData(unsigned char *p, int len) } else { if (m_pes_position < 4) - if (*p != "\x00\x00\x01\xbd"[m_pes_position]) + { + unsigned char ch = *p; + if (m_pes_position == 3) + ch &= m_stream_id_mask; + if (ch != m_header[m_pes_position]) { +// eDebug("sync lost at %d (%02x)", m_pes_position, *p); m_pes_position = 0; + while (m_header[m_pes_position] == ch) /* guaranteed to stop at the old m_pes_position */ + m_pes_position++; p++; len--; continue; } + } m_pes_buffer[m_pes_position++] = *p++; len--; if (m_pes_position == 6) {