Browse Source

TT#59650 fix DTMF related core dump when repacketising

Change-Id: I77b84c4b47ee41702b076a8a2f3259dc853654f1
changes/05/30405/2
Richard Fuchs 7 years ago
parent
commit
7ad9906178
3 changed files with 62 additions and 29 deletions
  1. +4
    -0
      daemon/codec.c
  2. +20
    -29
      lib/codeclib.c
  3. +38
    -0
      t/auto-daemon-tests.pl

+ 4
- 0
daemon/codec.c View File

@ -178,6 +178,10 @@ static void __make_transcoder(struct codec_handler *handler, struct rtp_payload_
assert(dest->codec_def != NULL);
assert(handler->source_pt.payload_type == handler->source_pt.payload_type);
// if we're just repacketising:
if (dtmf_payload_type == -1 && dest->codec_def && dest->codec_def->dtmf)
dtmf_payload_type = dest->payload_type;
// don't reset handler if it already matches what we want
if (!handler->transcoder)
goto reset;


+ 20
- 29
lib/codeclib.c View File

@ -57,9 +57,6 @@ static int amr_decoder_input(decoder_t *dec, const str *data, GQueue *out);
static const char *dtmf_decoder_init(decoder_t *, const str *);
static int dtmf_decoder_input(decoder_t *dec, const str *data, GQueue *out);
static const char *dtmf_encoder_init(encoder_t *enc, const str *);
static int dtmf_encoder_input(encoder_t *enc, AVFrame **frame);
static void dtmf_encoder_close(encoder_t *enc);
@ -85,9 +82,6 @@ static const codec_type_t codec_type_amr = {
static const codec_type_t codec_type_dtmf = {
.decoder_init = dtmf_decoder_init,
.decoder_input = dtmf_decoder_input,
.encoder_init = dtmf_encoder_init,
.encoder_input = dtmf_encoder_input,
.encoder_close = dtmf_encoder_close,
};
#ifdef HAVE_BCG729
@ -1043,7 +1037,7 @@ int encoder_config_fmtp(encoder_t *enc, const codec_def_t *def, int bitrate, int
enc->ptime = ptime / def->clockrate_mult;
enc->bitrate = bitrate;
err = def->codec_type->encoder_init(enc, fmtp);
err = def->codec_type->encoder_init ? def->codec_type->encoder_init(enc, fmtp) : 0;
if (err)
goto err;
@ -1051,19 +1045,24 @@ int encoder_config_fmtp(encoder_t *enc, const codec_def_t *def, int bitrate, int
// output frame and fifo
enc->frame = av_frame_alloc();
enc->frame->nb_samples = enc->samples_per_frame ? : 256;
enc->frame->format = enc->actual_format.format;
enc->frame->sample_rate = enc->actual_format.clockrate;
enc->frame->channel_layout = av_get_default_channel_layout(enc->actual_format.channels);
//if (!enc->frame->channel_layout)
//enc->frame->channel_layout = av_get_default_channel_layout(enc->u.avc.avcctx->channels);
if (av_frame_get_buffer(enc->frame, 0) < 0)
abort();
enc->fifo = av_audio_fifo_alloc(enc->frame->format, enc->actual_format.channels,
enc->frame->nb_samples);
if (enc->actual_format.format != -1 && enc->actual_format.clockrate > 0) {
enc->frame->nb_samples = enc->samples_per_frame ? : 256;
enc->frame->format = enc->actual_format.format;
enc->frame->sample_rate = enc->actual_format.clockrate;
enc->frame->channel_layout = av_get_default_channel_layout(enc->actual_format.channels);
//if (!enc->frame->channel_layout)
//enc->frame->channel_layout = av_get_default_channel_layout(enc->u.avc.avcctx->channels);
if (av_frame_get_buffer(enc->frame, 0) < 0)
abort();
enc->fifo = av_audio_fifo_alloc(enc->frame->format, enc->actual_format.channels,
enc->frame->nb_samples);
ilog(LOG_DEBUG, "Initialized encoder with frame size %u samples", enc->frame->nb_samples);
ilog(LOG_DEBUG, "Initialized encoder with frame size %u samples", enc->frame->nb_samples);
}
else
ilog(LOG_DEBUG, "Initialized encoder without frame buffer");
done:
@ -1185,6 +1184,9 @@ int encoder_input_data(encoder_t *enc, AVFrame *frame,
enc->avpkt.size = 0;
while (1) {
if (!enc->def->codec_type->encoder_input)
break;
int ret = enc->def->codec_type->encoder_input(enc, &frame);
if (ret < 0)
return -1;
@ -1791,14 +1793,3 @@ static int dtmf_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
return 0;
}
static const char *dtmf_encoder_init(encoder_t *enc, const str *fmtp) {
return NULL;
}
static int dtmf_encoder_input(encoder_t *enc, AVFrame **frame) {
return 0;
}
static void dtmf_encoder_close(encoder_t *enc) {
}

+ 38
- 0
t/auto-daemon-tests.pl View File

@ -3519,6 +3519,44 @@ rcv($sock_b, $port_a, rtpm(8, 1007, 3000+160*5, $ssrc, "\x2a" x 160));
new_call;
offer('DTMF repacketising',
{ ICE => 'remove', replace => ['origin', 'session-connection'],
flags => ['strict-source'],
ptime => 20, 'ptime-reverse' => 60, 'rtcp-mux' => ['demux'],
}, <<SDP);
v=0
o=- 3768297181 3768297181 IN IP4 10.10.12.22
s=Blink Lite 4.6.0 (MacOSX)
t=0 0
m=audio 50036 RTP/AVP 0 8 101
c=IN IP4 10.10.12.22
a=rtcp:50037
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
----------------------------------
v=0
o=- 3768297181 3768297181 IN IP4 203.0.113.1
s=Blink Lite 4.6.0 (MacOSX)
t=0 0
m=audio PORT RTP/AVP 0 8 101
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=rtcp:PORT
a=ptime:20
SDP
END {
if ($rtpe_pid) {
kill('INT', $rtpe_pid) or die;


Loading…
Cancel
Save