MT#65420 decoder config via format_t

Change-Id: I3b956ed14ad1e3a1c73237fc3be403b78e221c92
pull/2169/head
Richard Fuchs 3 weeks ago
parent bf60ed4d41
commit a43de7c26c

@ -4381,6 +4381,7 @@ static void async_chain_finish(AVPacket *pkt, void *async_cb_obj) {
}
static bool __ssrc_handler_decode_common(struct codec_ssrc_handler *ch, struct codec_handler *h,
const format_t *dec_format,
const format_t *enc_format)
{
if (h->pcm_dtmf_detect) {
@ -4393,7 +4394,7 @@ static bool __ssrc_handler_decode_common(struct codec_ssrc_handler *ch, struct c
dtmf_rx_set_realtime_callback(ch->dtmf_dsp, __dtmf_dsp_callback, ch);
}
ch->decoder = decoder_new_fmtp(h->source_pt.codec_def, h->source_pt.clock_rate, h->source_pt.channels,
ch->decoder = decoder_new_fmtp(h->source_pt.codec_def, dec_format,
h->source_pt.ptime,
enc_format, &h->source_pt.format,
&h->source_pt.format_parameters, &h->source_pt.codec_opts);
@ -4480,7 +4481,7 @@ static struct ssrc_entry *__ssrc_handler_transcode_new(void *p) {
&h->dest_pt.codec_opts))
goto err;
if (!__ssrc_handler_decode_common(ch, h, &ch->encoder_format))
if (!__ssrc_handler_decode_common(ch, h, &dec_format, &ch->encoder_format))
goto err;
ch->bytes_per_packet = (ch->encoder->samples_per_packet ?: ch->encoder->samples_per_frame)
@ -4515,7 +4516,13 @@ static struct ssrc_entry *__ssrc_handler_decode_new(void *p) {
.format = AV_SAMPLE_FMT_S16,
};
if (!__ssrc_handler_decode_common(ch, h, &dest_format))
format_t dec_format = {
.clockrate = h->source_pt.clock_rate,
.channels = h->source_pt.channels,
.format = -1,
};
if (!__ssrc_handler_decode_common(ch, h, &dec_format, &dest_format))
goto err;
return &ch->h;

@ -75,7 +75,12 @@ codec_def_t *codec_get_pcm16(void) {
decoder_t *decoder_new_fmt(codec_def_t *def, int clockrate, int channels, int ptime,
const format_t *resample_fmt)
{
return decoder_new_fmtp(def, clockrate, channels, ptime, resample_fmt, NULL, NULL, NULL);
return decoder_new_fmtp(def,
&(format_t) {
.clockrate = clockrate,
.channels = channels,
},
ptime, resample_fmt, NULL, NULL, NULL);
}
bool codec_parse_fmtp(codec_def_t *def, struct rtp_codec_format *fmtp, const str *fmtp_string,
@ -110,7 +115,7 @@ bool codec_parse_fmtp(codec_def_t *def, struct rtp_codec_format *fmtp, const str
return ret;
}
decoder_t *decoder_new_fmtp(codec_def_t *def, int clockrate, int channels, int ptime,
decoder_t *decoder_new_fmtp(codec_def_t *def, const format_t *src_fmt, int ptime,
const format_t *resample_fmt,
struct rtp_codec_format *fmtp, const str *fmtp_string,
const str *extra_opts)
@ -126,9 +131,9 @@ decoder_t *decoder_new_fmtp(codec_def_t *def, int clockrate, int channels, int p
ret->def = def;
ret->clockrate_fact = def->default_clockrate_fact;
format_init(&ret->in_format);
ret->in_format.channels = channels;
ret->in_format.clockrate = clockrate;
ret->in_format = *src_fmt;
ret->in_format.format = -1;
// output defaults to same as input
ret->dest_format = ret->in_format;

@ -413,7 +413,7 @@ bool codec_parse_fmtp(codec_def_t *def, struct rtp_codec_format *fmtp, const str
decoder_t *decoder_new_fmt(codec_def_t *def, int clockrate, int channels, int ptime,
const format_t *resample_fmt);
decoder_t *decoder_new_fmtp(codec_def_t *def, int clockrate, int channels, int ptime,
decoder_t *decoder_new_fmtp(codec_def_t *def, const format_t *src_fmt, int ptime,
const format_t *resample_fmt,
struct rtp_codec_format *fmtp, const str *fmtp_string, const str *codec_opts);
void decoder_close(decoder_t *dec);

@ -523,7 +523,7 @@ static void new_stream_params(
NULL, NULL, NULL);
assert(res == 0); // TODO: handle failures gracefully
s->decoder = decoder_new_fmtp(in_def, dec_format.clockrate, dec_format.channels, 20,
s->decoder = decoder_new_fmtp(in_def, &dec_format, 20,
&actual_enc_format, NULL, NULL, NULL); // TODO: support different options (fmtp etc)
assert(s->decoder != NULL); // TODO: handle failures gracefully
}

@ -66,10 +66,15 @@ decode_t *decoder_new(const char *payload_str, const char *format, int ptime) {
.channels = channels,
.format = AV_SAMPLE_FMT_S16,
};
format_t dec_format = (format_t) {
.clockrate = rtp_clockrate,
.channels = channels,
.format = -1,
};
str fmtp = STR(format);
decoder_t *dec = decoder_new_fmtp(def, rtp_clockrate, channels, ptime, &out_format, NULL, &fmtp, NULL);
decoder_t *dec = decoder_new_fmtp(def, &dec_format, ptime, &out_format, NULL, &fmtp, NULL);
if (!dec)
return NULL;
decode_t *deco = g_new0(decode_t, 1);

@ -64,7 +64,7 @@ static void do_test_amr_xx(const char *file, int line,
str fmtp = STR_NULL;
if (fmtp_s)
fmtp = STR(fmtp_s);
decoder_t *d = decoder_new_fmtp(def, clockrate, 1, 0, &fmt, NULL, NULL, &fmtp);
decoder_t *d = decoder_new_fmtp(def, &fmt, 0, &fmt, NULL, NULL, &fmtp);
assert(d);
const str data = STR_LEN(data_s, data_len);
int ret = decoder_input_data(d, &data, 1, false, frame_cb, &args, NULL);

Loading…
Cancel
Save