ref: 4e411db85d5d89030440a7faa3106486c6ca26ea
parent: 8eeac05c5de9e0b48660cdb629e484202bd84171
author: Ralph Giles <[email protected]>
date: Tue Jun 9 11:10:59 EDT 2020
opusrtp: Clean up tag header style. Regularize whitespace and be consistent using a fixed 8-byte length for the `OpusTags` packet header, rather can calling strlen on the literal. This length, and the offset of the subsequence fields, is fixed by the specification, so using a fixed length would great a less-corrupt file if the header sequence were somehow changed. Thanks to willson-chen for pointint out the style issue, and Mark Harris for recommending the fixed header length.
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -127,7 +127,7 @@
memcpy(data, "OpusHead", 8); /* identifier */
data[8] = 1; /* version */
data[9] = channels; /* channels */
- le16(data+10, 0); /* pre-skip */
+ le16(data + 10, 0); /* pre-skip */
le32(data + 12, samplerate); /* original sample rate */
le16(data + 16, 0); /* gain */
data[18] = 0; /* channel mapping family */
@@ -146,9 +146,8 @@
/* manufacture a generic OpusTags packet */
ogg_packet *op_opustags(void)
{
- char *identifier = "OpusTags";
char *vendor = "opus rtp packet dump";
- int size = strlen(identifier) + 4 + strlen(vendor) + 4;
+ int size = 8 + 4 + strlen(vendor) + 4;
unsigned char *data = malloc(size);
ogg_packet *op = malloc(sizeof(*op));
@@ -163,7 +162,7 @@
return NULL;
}
- memcpy(data, identifier, 8);
+ memcpy(data, "OpusTags", 8);
le32(data + 8, strlen(vendor));
memcpy(data + 12, vendor, strlen(vendor));
le32(data + 12 + strlen(vendor), 0);