From a68a59fbf5a52b29d192994625d60232ad0a0678 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 6 Mar 2020 11:14:51 -0500 Subject: [PATCH] TT#76711 keep track of the raw SDP format string Change-Id: I7f20dbff3237e39cea700c984a4f41016a2264fc --- daemon/call.c | 21 ++++++++++++++++----- daemon/redis.c | 4 ++++ daemon/sdp.c | 16 ++++++++++++++++ include/call.h | 2 ++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index e2e3ce062..e4227b1df 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1960,6 +1960,10 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, MEDIA_SET(media, PTIME_OVERRIDE); MEDIA_SET(other_media, PTIME_OVERRIDE); } + if (str_cmp_str(&other_media->format_str, &sp->format_str)) + call_str_cpy(call, &other_media->format_str, &sp->format_str); + if (str_cmp_str(&media->format_str, &sp->format_str)) + call_str_cpy(call, &media->format_str, &sp->format_str); codec_rtp_payload_types(media, other_media, &sp->rtp_payload_types, flags); codec_handlers_update(media, other_media, flags); @@ -2222,17 +2226,24 @@ void call_destroy(struct call *c) { // stats output only - no cleanups - rtp_pt = __rtp_stats_codec(md); #define MLL_PREFIX "------ Media #%u ("STR_FORMAT" over %s) using " /* media log line prefix */ #define MLL_COMMON /* common args */ \ md->index, \ STR_FMT(&md->type), \ md->protocol ? md->protocol->name : "(unknown)" - if (!rtp_pt) - ilog(LOG_INFO, MLL_PREFIX "unknown codec", MLL_COMMON); - else + + if (md->protocol && md->protocol->rtp) { + rtp_pt = __rtp_stats_codec(md); + if (!rtp_pt) + ilog(LOG_INFO, MLL_PREFIX "unknown codec", MLL_COMMON); + else + ilog(LOG_INFO, MLL_PREFIX STR_FORMAT, MLL_COMMON, + STR_FMT(&rtp_pt->encoding_with_params)); + } + else { ilog(LOG_INFO, MLL_PREFIX STR_FORMAT, MLL_COMMON, - STR_FMT(&rtp_pt->encoding_with_params)); + STR_FMT(&md->format_str)); + } for (o = md->streams.head; o; o = o->next) { ps = o->data; diff --git a/daemon/redis.c b/daemon/redis.c index fb43d3ccd..269e65c36 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1281,6 +1281,8 @@ static int json_medias(struct call *c, struct redis_list *medias, JsonReader *ro if (redis_hash_get_str(&s, rh, "type")) return -1; call_str_cpy(c, &med->type, &s); + if (!redis_hash_get_str(&s, rh, "format_str")) + call_str_cpy(c, &med->format_str, &s); if (!redis_hash_get_str(&s, rh, "media_id")) call_str_cpy(c, &med->media_id, &s); @@ -2034,6 +2036,8 @@ char* redis_encode_json(struct call *c) { JSON_SET_SIMPLE("tag","%u",media->monologue->unique_id); JSON_SET_SIMPLE("index","%u",media->index); JSON_SET_SIMPLE_STR("type",&media->type); + if (media->format_str.s) + JSON_SET_SIMPLE_STR("format_str",&media->format_str); if (media->media_id.s) JSON_SET_SIMPLE_STR("media_id",&media->media_id); JSON_SET_SIMPLE_CSTR("protocol",media->protocol ? media->protocol->name : ""); diff --git a/daemon/sdp.c b/daemon/sdp.c index 00fa92e98..931fe4877 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1268,6 +1268,7 @@ int sdp_streams(const GQueue *sessions, GQueue *streams, struct sdp_ng_flags *fl if (attr && attr->value.s) sp->ptime = str_to_i(&attr->value, 0); + sp->format_str = media->formats; errstr = "Invalid RTP payload types"; if (__rtp_payload_types(sp, media)) goto error; @@ -1463,9 +1464,24 @@ static int replace_transport_protocol(struct sdp_chopper *chop, return 0; } +static int replace_format_str(struct sdp_chopper *chop, + struct sdp_media *media, struct call_media *cm) +{ + if (!cm->format_str.s) + return 0; + chopper_append_c(chop, " "); + chopper_append_str(chop, &cm->format_str); + if (skip_over(chop, &media->formats)) + return -1; + return 0; +} + static int replace_codec_list(struct sdp_chopper *chop, struct sdp_media *media, struct call_media *cm) { + if (cm->protocol && !cm->protocol->rtp) + return replace_format_str(chop, media, cm); + if (cm->codecs_prefs_recv.length == 0) return 0; // legacy protocol or usage error diff --git a/include/call.h b/include/call.h index f838be9e0..d6a3d6798 100644 --- a/include/call.h +++ b/include/call.h @@ -211,6 +211,7 @@ struct stream_params { struct endpoint rtcp_endpoint; unsigned int consecutive_ports; const struct transport_protocol *protocol; + str format_str; GQueue sdes_params; // slice-alloc'd str direction[2]; sockfamily_t *desired_family; @@ -298,6 +299,7 @@ struct call_media { str type; enum media_type type_id; const struct transport_protocol *protocol; + str format_str; sockfamily_t *desired_family; const struct logical_intf *logical_intf;