Browse Source

TT#122401 keep track of decoder's output format

Change-Id: Ib55ba9787b07885cfc9544f93749710ce8cafc91
rfuchs/1283
Richard Fuchs 5 years ago
parent
commit
5d5098efde
3 changed files with 9 additions and 6 deletions
  1. +5
    -3
      lib/codeclib.c
  2. +2
    -1
      lib/codeclib.h
  3. +2
    -2
      recording-daemon/decoder.c

+ 5
- 3
lib/codeclib.c View File

@ -529,9 +529,10 @@ decoder_t *decoder_new_fmtp(const codec_def_t *def, int clockrate, int channels,
ret->in_format.channels = channels; ret->in_format.channels = channels;
ret->in_format.clockrate = clockrate; ret->in_format.clockrate = clockrate;
// output defaults to same as input // output defaults to same as input
ret->out_format = ret->in_format;
ret->dest_format = ret->in_format;
ret->dec_out_format = ret->in_format;
if (resample_fmt) if (resample_fmt)
ret->out_format = *resample_fmt;
ret->dest_format = *resample_fmt;
if (ptime > 0) if (ptime > 0)
ret->ptime = ptime; ret->ptime = ptime;
else else
@ -724,7 +725,8 @@ static int __decoder_input_data(decoder_t *dec, const str *data, unsigned long t
AVFrame *frame; AVFrame *frame;
int ret = 0; int ret = 0;
while ((frame = g_queue_pop_head(&frames))) { while ((frame = g_queue_pop_head(&frames))) {
AVFrame *rsmp_frame = resample_frame(&dec->resampler, frame, &dec->out_format);
dec->dec_out_format.format = frame->format;
AVFrame *rsmp_frame = resample_frame(&dec->resampler, frame, &dec->dest_format);
if (!rsmp_frame) { if (!rsmp_frame) {
ilog(LOG_ERR | LOG_FLAG_LIMIT, "Resampling failed"); ilog(LOG_ERR | LOG_FLAG_LIMIT, "Resampling failed");
ret = -1; ret = -1;


+ 2
- 1
lib/codeclib.h View File

@ -176,7 +176,8 @@ struct decoder_s {
codec_options_t codec_options; codec_options_t codec_options;
format_t in_format, format_t in_format,
out_format;
dec_out_format,
dest_format;
resample_t resampler; resample_t resampler;


+ 2
- 2
recording-daemon/decoder.c View File

@ -116,7 +116,7 @@ static int decoder_got_frame(decoder_t *dec, AVFrame *frame, void *sp, void *dp)
if (G_UNLIKELY(deco->mixer_idx == (unsigned int) -1)) if (G_UNLIKELY(deco->mixer_idx == (unsigned int) -1))
deco->mixer_idx = mix_get_index(metafile->mix, ssrc); deco->mixer_idx = mix_get_index(metafile->mix, ssrc);
format_t actual_format; format_t actual_format;
if (output_config(metafile->mix_out, &dec->out_format, &actual_format))
if (output_config(metafile->mix_out, &dec->dest_format, &actual_format))
goto no_mix_out; goto no_mix_out;
mix_config(metafile->mix, &actual_format); mix_config(metafile->mix, &actual_format);
// XXX might be a second resampling to same format // XXX might be a second resampling to same format
@ -133,7 +133,7 @@ no_mix_out:
if (output) { if (output) {
dbg("SSRC %lx of stream #%lu has single output", ssrc->ssrc, stream->id); dbg("SSRC %lx of stream #%lu has single output", ssrc->ssrc, stream->id);
if (output_config(output, &dec->out_format, NULL))
if (output_config(output, &dec->dest_format, NULL))
goto err; goto err;
if (output_add(output, frame)) if (output_add(output, frame))
ilog(LOG_ERR, "Failed to add decoded packet to individual output"); ilog(LOG_ERR, "Failed to add decoded packet to individual output");


Loading…
Cancel
Save