Browse Source

MT#62571 add sink to decode_t

Unused at this point except for the resampler

Change-Id: I093d7924c0bcc42a9a5162e1f02a374ea97e1bf3
pull/1967/head
Richard Fuchs 6 months ago
parent
commit
316161f6aa
5 changed files with 17 additions and 9 deletions
  1. +6
    -6
      recording-daemon/decoder.c
  2. +2
    -1
      recording-daemon/output.c
  3. +1
    -0
      recording-daemon/output.h
  4. +2
    -0
      recording-daemon/packet.c
  5. +6
    -2
      recording-daemon/types.h

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

@ -26,6 +26,7 @@ int resample_audio;
// does not initialise the contained `sink`
decode_t *decoder_new(const char *payload_str, const char *format, int ptime, const format_t *dec_format) {
char *slash = strchr(payload_str, '/');
if (!slash) {
@ -87,7 +88,6 @@ decode_t *decoder_new(const char *payload_str, const char *format, int ptime, co
return NULL;
decode_t *deco = g_new0(decode_t, 1);
deco->dec = dec;
deco->mixer_idx = (unsigned int) -1;
return deco;
}
@ -112,20 +112,20 @@ static int decoder_got_frame(decoder_t *dec, AVFrame *frame, void *sp, void *dp)
pthread_mutex_lock(&metafile->mix_lock);
if (metafile->mix_out) {
dbg("adding packet from stream #%lu to mix output", stream->id);
if (G_UNLIKELY(deco->mixer_idx == (unsigned int) -1))
deco->mixer_idx = mix_get_index(metafile->mix, ssrc, stream->media_sdp_id, stream->channel_slot);
if (G_UNLIKELY(deco->mix_sink.mixer_idx == (unsigned int) -1))
deco->mix_sink.mixer_idx = mix_get_index(metafile->mix, ssrc, stream->media_sdp_id, stream->channel_slot);
format_t actual_format;
if (output_config(metafile->mix_out, &dec->dest_format, &actual_format))
goto no_mix_out;
mix_config(metafile->mix, &actual_format);
// XXX might be a second resampling to same format
AVFrame *copy_frame = av_frame_clone(frame);
AVFrame *dec_frame = resample_frame(&deco->mix_resampler, copy_frame, &actual_format);
AVFrame *dec_frame = resample_frame(&deco->mix_sink.resampler, copy_frame, &actual_format);
if (!dec_frame) {
pthread_mutex_unlock(&metafile->mix_lock);
goto err;
}
if (mix_add(metafile->mix, dec_frame, deco->mixer_idx, ssrc, metafile->mix_out))
if (mix_add(metafile->mix, dec_frame, deco->mix_sink.mixer_idx, ssrc, metafile->mix_out))
ilog(LOG_ERR, "Failed to add decoded packet to mixed output");
if (dec_frame != copy_frame)
av_frame_free(&copy_frame);
@ -204,6 +204,6 @@ void decoder_free(decode_t *deco) {
if (!deco)
return;
decoder_close(deco->dec);
resample_shutdown(&deco->mix_resampler);
sink_close(&deco->mix_sink);
g_free(deco);
}

+ 2
- 1
recording-daemon/output.c View File

@ -123,6 +123,7 @@ static void create_parent_dirs(char *dir) {
void sink_init(sink_t *sink) {
*sink = (__typeof(*sink)) {
.mixer_idx = -1u,
};
}
@ -559,7 +560,7 @@ static bool output_shutdown(output_t *output, FILE **fp, GString **gs) {
}
static void sink_close(sink_t *sink) {
void sink_close(sink_t *sink) {
resample_shutdown(&sink->resampler);
}


+ 1
- 0
recording-daemon/output.h View File

@ -17,6 +17,7 @@ int output_config(output_t *output, const format_t *requested_format, format_t *
void sink_init(sink_t *);
void sink_close(sink_t *sink);
bool sink_add(sink_t *, AVFrame *frame, const format_t *requested_format);


+ 2
- 0
recording-daemon/packet.c View File

@ -120,6 +120,8 @@ static void packet_decode(ssrc_t *ssrc, packet_t *packet) {
else if (ssrc->output)
dec_format = ssrc->output->requested_format;
ssrc->decoders[payload_type] = decoder_new(payload_str, format, ptime, &dec_format);
sink_init(&ssrc->decoders[payload_type]->mix_sink);
ssrc->decoders[payload_type]->mix_sink.ssrc = ssrc;
pthread_mutex_unlock(&mf->mix_lock);
if (!ssrc->decoders[payload_type]) {
ilog(LOG_WARN, "Cannot decode RTP payload type %u (%s)",


+ 6
- 2
recording-daemon/types.h View File

@ -51,9 +51,14 @@ struct sink_s {
union {
output_t *output;
ssrc_t *ssrc;
};
resample_t resampler;
union {
unsigned int mixer_idx;
};
};
@ -197,8 +202,7 @@ struct output_s {
struct decode_s {
decoder_t *dec;
resample_t mix_resampler;
unsigned int mixer_idx;
sink_t mix_sink;
};


Loading…
Cancel
Save