Skip to content

Commit 73103bd

Browse files
InterLinked1gtjoseph
authored andcommitted
chan_iax2: Fix jitterbuffer regression prior to receiving audio.
ASTERISK_29392 (a security fix) introduced a regression by not processing frames when we don't have an audio format. Currently, chan_iax2 only calls jb_get to read frames from the jitterbuffer when the voiceformat has been set on the pvt. However, this only happens when we receive a voice frame, which means that prior to receiving voice frames, other types of frames get stalled completely in the jitterbuffer. To fix this, we now fallback to using the format negotiated during call setup until we've actually received a voice frame with a format. This ensures we're always able to read from the jitterbuffer. ASTERISK-30354 #close ASTERISK-30162 #close Change-Id: Ie4fd1e8e088a145ad89e0427c2100a530e964fe9
1 parent 2e95f47 commit 73103bd

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: channels/chan_iax2.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -4158,9 +4158,19 @@ static void __get_from_jb(const void *p)
41584158
now.tv_usec += 1000;
41594159

41604160
ms = ast_tvdiff_ms(now, pvt->rxcore);
4161-
4162-
voicefmt = ast_format_compatibility_bitfield2format(pvt->voiceformat);
4163-
if (voicefmt && ms >= (next = jb_next(pvt->jb))) {
4161+
if (ms >= (next = jb_next(pvt->jb))) {
4162+
voicefmt = ast_format_compatibility_bitfield2format(pvt->voiceformat);
4163+
if (!voicefmt) {
4164+
/* pvt->voiceformat won't be set if we haven't received any voice frames yet.
4165+
* In this case, fall back to using the format negotiated during call setup,
4166+
* so we don't stall the jitterbuffer completely. */
4167+
voicefmt = ast_format_compatibility_bitfield2format(pvt->peerformat);
4168+
}
4169+
if (!voicefmt) {
4170+
/* Really shouldn't happen, but if it does, should be looked into */
4171+
ast_log(LOG_WARNING, "No voice format and no peer format available on %s, backlogging frame\n", ast_channel_name(pvt->owner));
4172+
goto cleanup; /* Don't crash if there's no voice format */
4173+
}
41644174
ret = jb_get(pvt->jb, &frame, ms, ast_format_get_default_ms(voicefmt));
41654175
switch(ret) {
41664176
case JB_OK:
@@ -4202,6 +4212,7 @@ static void __get_from_jb(const void *p)
42024212
break;
42034213
}
42044214
}
4215+
cleanup:
42054216
if (pvt)
42064217
update_jbsched(pvt);
42074218
ast_mutex_unlock(&iaxsl[callno]);

0 commit comments

Comments
 (0)