From 5c3d39748bc8863a6d86507c90d9e8cea148f3bf Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 16 May 2018 11:10:51 -0400 Subject: [PATCH] TT#35456 fix regression from 895fa9605 Adding a fixed length to the size of the buffer requested from the packetizer was wrong, as this is not just the length of the working buffer but also the size of the buffer to be returned for sample stream (PCM) codecs. Instead, use the codec definition's bit per sample spec to make AMR provide a larger buffer than the bare frame. Change-Id: Ibff59b21d491e3327cc9e907e6515379a8ca9188 --- daemon/codec.c | 1 - lib/codeclib.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/codec.c b/daemon/codec.c index fc9a636b8..1469cc6e8 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -651,7 +651,6 @@ static int __packet_encoded(encoder_t *enc, void *u1, void *u2) { while (1) { // figure out how big of a buffer we need unsigned int payload_len = MAX(enc->avpkt.size, ch->bytes_per_packet); - payload_len += 16; // extra room for certain protocols, e.g. AMR framing unsigned int pkt_len = sizeof(struct rtp_header) + payload_len + RTP_BUFFER_TAIL_ROOM; // prepare our buffers char *buf = malloc(pkt_len); diff --git a/lib/codeclib.c b/lib/codeclib.c index 7e48776ec..aade19483 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -312,6 +312,7 @@ static codec_def_t __codec_defs[] = { .default_ptime = 20, .default_fmtp = "octet-align=1", .packetizer = packetizer_amr, + .bits_per_sample = 2, // max is 12200 / 8000 = 1.525 bits per sample, rounded up .media_type = MT_AUDIO, .codec_type = &codec_type_amr, .set_enc_options = amr_set_enc_options, @@ -327,6 +328,7 @@ static codec_def_t __codec_defs[] = { .default_ptime = 20, .default_fmtp = "octet-align=1", .packetizer = packetizer_amr, + .bits_per_sample = 2, // max is 23850 / 16000 = 1.490625 bits per sample, rounded up .media_type = MT_AUDIO, .codec_type = &codec_type_amr, .set_enc_options = amr_set_enc_options,