TT#146201 delegate setting transcoding flag

Pass the subscription object to codec_handlers_update to eliminate the
need for a return type and the subsequent if/else.

Change-Id: I311b3e8ca14ee5090cf329163975354385cee800
pull/1682/head
Richard Fuchs 2 years ago
parent 0bc78550f8
commit 758617d490

@ -2435,14 +2435,13 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
codec_tracker_update(&media->codecs);
// set up handlers
codec_handlers_update(media, other_media, flags, sp);
codec_handlers_update(media, other_media, flags, sp , NULL);
// updating the handlers may have removed some codecs, so run update the supp codecs again
codec_tracker_update(&media->codecs);
// finally set up handlers again based on final results
if (codec_handlers_update(media, other_media, flags, sp))
dialogue[1]->attrs.transcoding = 1;
codec_handlers_update(media, other_media, flags, sp, dialogue[1]);
}
else {
// answer
@ -2470,7 +2469,7 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
// update callee side codec handlers again (second pass after the offer) as we
// might need to update some handlers, e.g. when supplemental codecs have been
// rejected
codec_handlers_update(other_media, media, NULL, NULL);
codec_handlers_update(other_media, media, NULL, NULL, NULL);
// finally set up our caller side codecs
ilogs(codec, LOG_DEBUG, "Codec answer for " STR_FORMAT " #%u",
@ -2479,17 +2478,15 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
codec_store_answer(&media->codecs, &other_media->codecs, flags);
// set up handlers
codec_handlers_update(media, other_media, flags, sp);
codec_handlers_update(media, other_media, flags, sp, NULL);
// updating the handlers may have removed some codecs, so run update the supp codecs again
codec_tracker_update(&media->codecs);
codec_tracker_update(&other_media->codecs);
// finally set up handlers again based on final results
if (codec_handlers_update(media, other_media, flags, sp))
dialogue[1]->attrs.transcoding = 1;
if (codec_handlers_update(other_media, media, NULL, NULL))
dialogue[0]->attrs.transcoding = 1;
codec_handlers_update(media, other_media, flags, sp, dialogue[1]);
codec_handlers_update(other_media, media, NULL, NULL, dialogue[0]);
// activate audio player if needed (not done by codec_handlers_update without `flags`)
audio_player_activate(media);
@ -3124,7 +3121,7 @@ static int monologue_subscribe_request1(struct call_monologue *src_ml, struct ca
codec_store_transcode(&dst_media->codecs, &flags->codec_transcode, &sp->codecs);
codec_store_synthesise(&dst_media->codecs, &src_media->codecs);
codec_handlers_update(dst_media, src_media, flags, sp);
codec_handlers_update(dst_media, src_media, flags, sp, NULL);
if (!flags->inactive)
bf_copy(&dst_media->media_flags, MEDIA_FLAG_SEND, &src_media->media_flags, SP_FLAG_RECV);
@ -3236,9 +3233,8 @@ int monologue_subscribe_answer(struct call_monologue *dst_ml, struct sdp_ng_flag
return -1;
}
codec_handlers_update(src_media, dst_media, NULL, NULL);
if (codec_handlers_update(dst_media, src_media, flags, sp))
rev_cs->attrs.transcoding = 1;
codec_handlers_update(src_media, dst_media, NULL, NULL, NULL);
codec_handlers_update(dst_media, src_media, flags, sp, rev_cs);
__dtls_logic(flags, dst_media, sp);

@ -1001,28 +1001,33 @@ INLINE struct codec_handler *codec_handler_lookup(GHashTable *ht, int pt, struct
}
// call must be locked in W
bool codec_handlers_update(struct call_media *receiver, struct call_media *sink,
const struct sdp_ng_flags *flags, const struct stream_params *sp)
void codec_handlers_update(struct call_media *receiver, struct call_media *sink,
const struct sdp_ng_flags *flags, const struct stream_params *sp, struct call_subscription *sub)
{
ilogs(codec, LOG_DEBUG, "Setting up codec handlers for " STR_FORMAT_M " #%u -> " STR_FORMAT_M " #%u",
STR_FMT_M(&receiver->monologue->tag), receiver->index,
STR_FMT_M(&sink->monologue->tag), sink->index);
if (sub)
sub->attrs.transcoding = 0;
MEDIA_CLEAR(receiver, TRANSCODE);
MEDIA_CLEAR(receiver, GENERATOR);
MEDIA_CLEAR(sink, GENERATOR);
// non-RTP protocol?
if (proto_is(receiver->protocol, PROTO_UDPTL)) {
if (codec_handler_udptl_update(receiver, sink, flags))
return true;
if (codec_handler_udptl_update(receiver, sink, flags)) {
if (sub)
sub->attrs.transcoding = 1;
return;
}
}
// everything else is unsupported: pass through
if (proto_is_not_rtp(receiver->protocol)) {
__generator_stop_all(receiver);
__generator_stop_all(sink);
codec_handlers_stop(&receiver->codec_handlers_store);
return false;
return;
}
if (!receiver->codec_handlers)
@ -1030,8 +1035,11 @@ bool codec_handlers_update(struct call_media *receiver, struct call_media *sink,
// should we transcode to a non-RTP protocol?
if (proto_is_not_rtp(sink->protocol)) {
if (codec_handler_non_rtp_update(receiver, sink, flags, sp))
return true;
if (codec_handler_non_rtp_update(receiver, sink, flags, sp)) {
if (sub)
sub->attrs.transcoding = 1;
return;
}
}
// we're doing some kind of media passthrough - shut down local generators
@ -1378,6 +1386,8 @@ next:
MEDIA_SET(sink, AUDIO_PLAYER);
if (is_transcoding) {
if (sub)
sub->attrs.transcoding = 1;
MEDIA_SET(receiver, TRANSCODE);
if (!use_audio_player) {
@ -1442,8 +1452,6 @@ next:
sink->rtcp_handler = rtcp_sink_handler;
__codec_rtcp_timer(sink);
}
return is_transcoding;
}
@ -4149,7 +4157,7 @@ void codec_update_all_handlers(struct call_monologue *ml) {
struct call_media *sink_media = sink->medias->pdata[i];
if (!sink_media)
continue;
codec_handlers_update(source_media, sink_media, NULL, NULL);
codec_handlers_update(source_media, sink_media, NULL, NULL, NULL);
}
}
@ -4169,7 +4177,7 @@ void codec_update_all_source_handlers(struct call_monologue *ml, const struct sd
struct call_media *sink_media = ml->medias->pdata[i];
if (!sink_media)
continue;
codec_handlers_update(source_media, sink_media, flags, NULL);
codec_handlers_update(source_media, sink_media, flags, NULL, NULL);
}
}

@ -1861,7 +1861,7 @@ static int json_link_medias(struct call *c, struct redis_list *medias,
continue;
other_m->monologue = other_ml;
if (other_m->index == med->index) {
codec_handlers_update(other_m, med, NULL, NULL);
codec_handlers_update(other_m, med, NULL, NULL, cs);
break;
}
}

@ -28,6 +28,7 @@ struct codec_store;
struct call_monologue;
struct delay_buffer;
struct sink_handler;
struct call_subscription;
typedef int codec_handler_func(struct codec_handler *, struct media_packet *);
@ -146,8 +147,8 @@ void payload_type_clear(struct rtp_payload_type *p);
void ensure_codec_def(struct rtp_payload_type *pt, struct call_media *media);
void codec_handler_free(struct codec_handler **handler);
bool codec_handlers_update(struct call_media *receiver, struct call_media *sink, const struct sdp_ng_flags *,
const struct stream_params *);
void codec_handlers_update(struct call_media *receiver, struct call_media *sink, const struct sdp_ng_flags *,
const struct stream_params *, struct call_subscription *);
void codec_add_dtmf_event(struct codec_ssrc_handler *ch, int code, int level, uint64_t ts, bool injected);
uint64_t codec_last_dtmf_event(struct codec_ssrc_handler *ch);
uint64_t codec_encoder_pts(struct codec_ssrc_handler *ch, struct ssrc_ctx *);
@ -170,10 +171,9 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *,
#else
INLINE bool codec_handlers_update(struct call_media *receiver, struct call_media *sink,
const struct sdp_ng_flags *flags, const struct stream_params *sp)
INLINE void codec_handlers_update(struct call_media *receiver, struct call_media *sink,
const struct sdp_ng_flags *flags, const struct stream_params *sp, struct call_subscription *sub)
{
return false;
}
INLINE void codec_handler_free(struct codec_handler **handler) { }
INLINE void codec_tracker_update(struct codec_store *cs) { }

Loading…
Cancel
Save