diff --git a/daemon/codec.c b/daemon/codec.c index 260367e99..7c534646a 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1032,6 +1032,9 @@ static void packet_dtmf_fwd(struct codec_ssrc_handler *ch, struct transcode_pack // this is actually a DTMF -> PCM handler // grab our underlying PCM transcoder struct codec_ssrc_handler *output_ch = __output_ssrc_handler(ch, mp); + if (G_UNLIKELY(!ch->encoder)) + goto skip; + // init some vars if (!ch->first_ts) ch->first_ts = output_ch->first_ts; @@ -1072,6 +1075,7 @@ static void packet_dtmf_fwd(struct codec_ssrc_handler *ch, struct transcode_pack obj_put(&output_ch->h); } +skip:; char *buf = malloc(packet->payload->len + sizeof(struct rtp_header) + RTP_BUFFER_TAIL_ROOM); memcpy(buf + sizeof(struct rtp_header), packet->payload->s, packet->payload->len); if (packet->ignore_seq) // inject original seq @@ -1567,6 +1571,13 @@ static int __packet_decoded(decoder_t *decoder, AVFrame *frame, void *u1, void * goto discard; } + if (G_UNLIKELY(!ch->encoder)) { + ilog(LOG_INFO | LOG_FLAG_LIMIT, + "Discarding decoded %i PCM samples due to lack of output encoder", + frame->nb_samples); + goto discard; + } + __dtmf_detect(ch, frame); encoder_input_fifo(ch->encoder, frame, __packet_encoded, ch, mp);