Patrick Fischer wrote:
void cMyReceiver::Receive(uchar *Data, int Length) { int pid = ((Data[1] & 0x1f) << 8) | (Data[2]); if (pid == m_VideoPid) { uint8_t off = 0; if (Data[3] & ADAPT_FIELD) { off = Data[4] + 1; } printf("vpts : %fs\n",trans_pts_dts( (uint8_t*)(Data + 4 + off)+9)/90000.); } }
From standard, I miss the following checks:
- Is there payload in this TS packet? - Does a new PES packet start with this TS packet? (payload_unit_start_indicator) - Does the payload start with 00 00 01 PES header prefix? - Does the stream_id refer to an A/V stream with full headers? (well, if VideoPid is valid, this should be expected) - Is the PTS field present in the PES header?
With these assumptions, Data+4+off points to the PES header, and PESheader+9 points to the PTS.
Cheers,
Udo