Below is after it has received a packet, calls parse_rtp:
Code: Select all
if (length == VIDEO_RTP_DATA_PACKET_SIZE) {
hdhomerun_video_parse_rtp(vs, &pkt);
length = pkt.end - pkt.pos;
}
if (length != VIDEO_DATA_PACKET_SIZE) {
/* Data received but not valid - ignore. */
continue;
}
Code: Select all
static void hdhomerun_video_parse_rtp(struct hdhomerun_video_sock_t *vs, struct hdhomerun_pkt_t *pkt)
{
pkt->pos += 2;
uint32_t rtp_sequence = hdhomerun_pkt_read_u16(pkt);
pkt->pos += 8;
uint32_t previous_rtp_sequence = vs->rtp_sequence;
vs->rtp_sequence = rtp_sequence;
/* Initial case - first packet received. */
if (previous_rtp_sequence == 0xFFFFFFFF) {
return;
}
/* Normal case - next sequence number. */
if (rtp_sequence == ((previous_rtp_sequence + 1) & 0xFFFF)) {
return;
}
/* Error case - sequence missed. */
vs->network_error_count++;
/* Restart pid sequence check after packet loss. */
int i;
for (i = 0; i < 0x2000; i++) {
vs->sequence[i] = 0xFF;
}
}