MT#55283 remove unsupported codecs w/ audio player

Remove all codecs that cannot be transcoded to when the audio player is in
use.

Add safety to make_transcoder to return failure in case an unsupported
codec is requested for transcoding.

Convert leftover passthrough handlers to SSRC passthrough if there are
any (shouldn't be).

closes #1858

Change-Id: I1822e48723622d550624c7355a1acfbf8ca38eb8
(cherry picked from commit 4573f32d9b)
(cherry picked from commit 657faf5744)
mr12.5.1
Richard Fuchs 8 months ago
parent 13996badab
commit b685584cd4

@ -437,14 +437,15 @@ static void __reset_sequencer(void *p, void *dummy) {
g_hash_table_destroy(s->sequencers); g_hash_table_destroy(s->sequencers);
s->sequencers = NULL; s->sequencers = NULL;
} }
static void __make_transcoder_full(struct codec_handler *handler, rtp_payload_type *dest, static bool __make_transcoder_full(struct codec_handler *handler, rtp_payload_type *dest,
GHashTable *output_transcoders, int dtmf_payload_type, bool pcm_dtmf_detect, GHashTable *output_transcoders, int dtmf_payload_type, bool pcm_dtmf_detect,
int cn_payload_type, int (*packet_decoded)(decoder_t *, AVFrame *, void *, void *), int cn_payload_type, int (*packet_decoded)(decoder_t *, AVFrame *, void *, void *),
struct ssrc_entry *(*ssrc_handler_new_func)(void *p)) struct ssrc_entry *(*ssrc_handler_new_func)(void *p))
{ {
assert(handler->source_pt.codec_def != NULL); if (!handler->source_pt.codec_def)
return false;
assert(dest->codec_def != NULL); if (!dest->codec_def)
return false;
// don't reset handler if it already matches what we want // don't reset handler if it already matches what we want
if (!handler->transcoder) if (!handler->transcoder)
@ -542,6 +543,8 @@ no_handler_reset:
g_hash_table_insert(output_transcoders, GINT_TO_POINTER(dest->payload_type), handler); g_hash_table_insert(output_transcoders, GINT_TO_POINTER(dest->payload_type), handler);
handler->output_handler = handler; // make sure we don't have a stale pointer handler->output_handler = handler; // make sure we don't have a stale pointer
} }
return true;
} }
static void __make_transcoder(struct codec_handler *handler, rtp_payload_type *dest, static void __make_transcoder(struct codec_handler *handler, rtp_payload_type *dest,
GHashTable *output_transcoders, int dtmf_payload_type, bool pcm_dtmf_detect, GHashTable *output_transcoders, int dtmf_payload_type, bool pcm_dtmf_detect,
@ -550,10 +553,10 @@ static void __make_transcoder(struct codec_handler *handler, rtp_payload_type *d
__make_transcoder_full(handler, dest, output_transcoders, dtmf_payload_type, pcm_dtmf_detect, __make_transcoder_full(handler, dest, output_transcoders, dtmf_payload_type, pcm_dtmf_detect,
cn_payload_type, packet_decoded_fifo, __ssrc_handler_transcode_new); cn_payload_type, packet_decoded_fifo, __ssrc_handler_transcode_new);
} }
static void __make_audio_player_decoder(struct codec_handler *handler, rtp_payload_type *dest, static bool __make_audio_player_decoder(struct codec_handler *handler, rtp_payload_type *dest,
bool pcm_dtmf_detect) bool pcm_dtmf_detect)
{ {
__make_transcoder_full(handler, dest, NULL, -1, pcm_dtmf_detect, -1, packet_decoded_audio_player, return __make_transcoder_full(handler, dest, NULL, -1, pcm_dtmf_detect, -1, packet_decoded_audio_player,
__ssrc_handler_decode_new); __ssrc_handler_decode_new);
} }
@ -1477,10 +1480,6 @@ next:
if (a.reset_transcoding && ms) if (a.reset_transcoding && ms)
ms->attrs.transcoding = 1; ms->attrs.transcoding = 1;
if (!use_audio_player) {
// we have to translate RTCP packets
receiver->rtcp_handler = rtcp_transcode_handler;
for (__auto_type l = receiver->codecs.codec_prefs.head; l; ) { for (__auto_type l = receiver->codecs.codec_prefs.head; l; ) {
rtp_payload_type *pt = l->data; rtp_payload_type *pt = l->data;
@ -1497,6 +1496,9 @@ next:
l = __codec_store_delete_link(l, &receiver->codecs); l = __codec_store_delete_link(l, &receiver->codecs);
} }
if (!use_audio_player) {
// we have to translate RTCP packets
receiver->rtcp_handler = rtcp_transcode_handler;
// at least some payload types will be transcoded, which will result in SSRC // at least some payload types will be transcoded, which will result in SSRC
// change. for payload types which we don't actually transcode, we still // change. for payload types which we don't actually transcode, we still
@ -1506,7 +1508,6 @@ next:
__convert_passthrough_ssrc(handler); __convert_passthrough_ssrc(handler);
passthrough_handlers = g_slist_delete_link(passthrough_handlers, passthrough_handlers = g_slist_delete_link(passthrough_handlers,
passthrough_handlers); passthrough_handlers);
} }
} }
else { else {
@ -1516,7 +1517,8 @@ next:
// change all passthrough handlers also to transcoders // change all passthrough handlers also to transcoders
while (passthrough_handlers) { while (passthrough_handlers) {
struct codec_handler *handler = passthrough_handlers->data; struct codec_handler *handler = passthrough_handlers->data;
__make_audio_player_decoder(handler, pref_dest_codec, false); if (!__make_audio_player_decoder(handler, pref_dest_codec, false))
__convert_passthrough_ssrc(handler);
passthrough_handlers = g_slist_delete_link(passthrough_handlers, passthrough_handlers = g_slist_delete_link(passthrough_handlers,
passthrough_handlers); passthrough_handlers);

Loading…
Cancel
Save