Skip to content

Commit

Permalink
Fix transport-wide sequence number parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
atoppi committed Mar 15, 2019
1 parent b850306 commit ddbd1b5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,23 @@ int janus_rtp_header_extension_parse_rtp_stream_id(char *buf, int len, int id,
}

int janus_rtp_header_extension_parse_transport_wide_cc(char *buf, int len, int id, uint16_t *transSeqNum) {
uint32_t bytes = 0;
if(janus_rtp_header_extension_find(buf, len, id, NULL, &bytes, NULL) < 0)
char *ext = NULL;
if(janus_rtp_header_extension_find(buf, len, id, NULL, NULL, &ext) < 0)
return -1;
/* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ID | L=1 |transport-wide sequence number | zero padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
*transSeqNum = (bytes & 0x00FFFF00) >> 8;
if(ext == NULL)
return -2;
int val_len = (*ext & 0x0F) + 1;
if (val_len > len-(ext-buf)-1) {
return -3;
}
memcpy(transSeqNum, ext+1, sizeof(uint16_t));
*transSeqNum = ntohs(*transSeqNum);
return 0;
}

Expand Down

0 comments on commit ddbd1b5

Please sign in to comment.