ref: 380b5aeb5322914724994d3e059438ff5bf5c41f
parent: 39f8ced76584531fb68da965f35e3f562ca900a7
author: Ralph Giles <giles@mozilla.com>
date: Wed Oct 3 11:36:11 EDT 2012
Don't truncate the rtp packets. Previously, the length passed to the sendto() function didn't include the length of the rtp header, truncating every packet by 12 bytes. Also use the calculated rtp header size, rather than hard-coding the minimum size.
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -472,8 +472,8 @@
int send_rtp_packet(int fd, struct sockaddr *sin,
rtp_header *rtp, const unsigned char *opus)
{
- long size = rtp->payload_size;
- unsigned char *packet = malloc(RTP_HEADER_MIN + size);
+ update_rtp_header(rtp);
+ unsigned char *packet = malloc(rtp->header_size + rtp->payload_size);
int ret;
if (!packet) {
@@ -480,12 +480,12 @@
fprintf(stderr, "Couldn't allocate packet buffer\n");
return -1;
}
- update_rtp_header(rtp);
- serialize_rtp_header(packet, RTP_HEADER_MIN, rtp);
- memcpy(packet + RTP_HEADER_MIN, opus, size);
- fprintf(stderr, "rtp %d %d %d (%ld bytes)\n",
- rtp->type, rtp->seq, rtp->time, size);
- ret = sendto(fd, packet, size, 0, sin, sizeof(*sin));
+ serialize_rtp_header(packet, rtp->header_size, rtp);
+ memcpy(packet + rtp->header_size, opus, rtp->payload_size);
+ fprintf(stderr, "rtp %d %d %d (%d bytes)\n",
+ rtp->type, rtp->seq, rtp->time, rtp->payload_size);
+ ret = sendto(fd, packet, rtp->header_size + rtp->payload_size, 0,
+ sin, sizeof(*sin));
if (ret < 0) {
fprintf(stderr, "error sending: %s\n", strerror(errno));
}