Browse Source

TT#122401 correct ptime handling for negative values

Change-Id: I3ca96971ec20aa02deb80d2d9613bbaa33c3ae05
rfuchs/1283
Richard Fuchs 5 years ago
parent
commit
b1409e58e1
2 changed files with 14 additions and 10 deletions
  1. +12
    -8
      daemon/codec.c
  2. +2
    -2
      lib/codeclib.c

+ 12
- 8
daemon/codec.c View File

@ -460,9 +460,9 @@ static struct rtp_payload_type *__check_dest_codecs(struct call_media *receiver,
continue; continue;
// fix up ptime // fix up ptime
if (!pt->ptime)
if (pt->ptime <= 0)
pt->ptime = pt->codec_def->default_ptime; pt->ptime = pt->codec_def->default_ptime;
if (sink->ptime)
if (sink->ptime > 0)
pt->ptime = sink->ptime; pt->ptime = sink->ptime;
if (!pref_dest_codec && !pt->codec_def->supplemental) if (!pref_dest_codec && !pt->codec_def->supplemental)
@ -1044,9 +1044,9 @@ static struct codec_handler *__get_pt_handler(struct call_media *receiver, struc
} }
// figure out our ptime // figure out our ptime
if (!pt->ptime && pt->codec_def)
if (pt->ptime <= 0 && pt->codec_def)
pt->ptime = pt->codec_def->default_ptime; pt->ptime = pt->codec_def->default_ptime;
if (receiver->ptime)
if (receiver->ptime > 0)
pt->ptime = receiver->ptime; pt->ptime = receiver->ptime;
return handler; return handler;
@ -2240,7 +2240,7 @@ void codec_init_payload_type(struct rtp_payload_type *ret, struct call_media *me
ret->clock_rate = def->default_clockrate; ret->clock_rate = def->default_clockrate;
if (!ret->channels) if (!ret->channels)
ret->channels = def->default_channels; ret->channels = def->default_channels;
if (!ret->ptime)
if (ret->ptime <= 0)
ret->ptime = def->default_ptime; ret->ptime = def->default_ptime;
if ((!ret->format_parameters.s || !ret->format_parameters.s[0]) && def->default_fmtp) if ((!ret->format_parameters.s || !ret->format_parameters.s[0]) && def->default_fmtp)
str_init(&ret->format_parameters, (char *) def->default_fmtp); str_init(&ret->format_parameters, (char *) def->default_fmtp);
@ -2655,9 +2655,13 @@ static void __dtx_setup(struct codec_ssrc_handler *ch) {
dtx->call = obj_get(ch->handler->media->call); dtx->call = obj_get(ch->handler->media->call);
mutex_init(&dtx->lock); mutex_init(&dtx->lock);
dtx->ptime = ch->ptime; dtx->ptime = ch->ptime;
if (!dtx->ptime)
dtx->ptime = 20; // XXX should be replaced with length of actual decoded packet
dtx->tspp = dtx->ptime * ch->handler->source_pt.clock_rate / 1000; // XXX ditto
if (dtx->ptime <= 0)
dtx->ptime = ch->handler->source_pt.codec_def->default_ptime;
if (dtx->ptime <= 0)
dtx->ptime = 20;
ilogs(dtx, LOG_DEBUG, "Using DTX ptime %i based on handler=%i codec=%i", dtx->ptime,
ch->ptime, ch->handler->source_pt.codec_def->default_ptime);
dtx->tspp = dtx->ptime * ch->handler->source_pt.clock_rate / 1000;
dtx->clockrate = ch->handler->source_pt.clock_rate; dtx->clockrate = ch->handler->source_pt.clock_rate;
} }
static void __ssrc_handler_stop(void *p) { static void __ssrc_handler_stop(void *p) {


+ 2
- 2
lib/codeclib.c View File

@ -1456,7 +1456,7 @@ static void opus_init(struct rtp_payload_type *pt) {
} }
static void opus_set_enc_options(encoder_t *enc, const str *fmtp, const str *codec_opts) { static void opus_set_enc_options(encoder_t *enc, const str *fmtp, const str *codec_opts) {
if (enc->ptime)
if (enc->ptime > 0)
codeclib_set_av_opt_int(enc, "frame_duration", enc->ptime); codeclib_set_av_opt_int(enc, "frame_duration", enc->ptime);
// XXX additional opus options // XXX additional opus options
} }
@ -2348,7 +2348,7 @@ static int format_cmp_ignore(const struct rtp_payload_type *a, const struct rtp_
static int cn_decoder_input(decoder_t *dec, const str *data, GQueue *out) { static int cn_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
// generate one set of ptime worth of samples // generate one set of ptime worth of samples
int ptime = dec->ptime; int ptime = dec->ptime;
if (!ptime)
if (ptime <= 0)
ptime = 20; // ? ptime = 20; // ?
int samples = dec->in_format.clockrate * ptime / 1000; int samples = dec->in_format.clockrate * ptime / 1000;
dec->u.avc.avcctx->frame_size = samples; dec->u.avc.avcctx->frame_size = samples;


Loading…
Cancel
Save