MT#55283 switch o= strings to `str`

So we can attach other attributes to the strings

Change-Id: I3e6090c8557879efb40ddeb6635ed4b10e742112
pull/1870/head
Richard Fuchs 9 months ago
parent 7099aab46b
commit 8b26bf2761

@ -2672,14 +2672,14 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, struct c
/* sdp session name */
if (flags->session_sdp_name.len &&
(!ml->sdp_session_name || /* if not set yet */
(ml->sdp_session_name && !flags->replace_sess_name))) /* replace_sess_name = do not replace if possible*/
(!ml->sdp_session_name.len || /* if not set yet */
(ml->sdp_session_name.len && !flags->replace_sess_name))) /* replace_sess_name = do not replace if possible*/
{
ml->sdp_session_name = call_strdup_str(&flags->session_sdp_name);
ml->sdp_session_name = call_str_cpy(&flags->session_sdp_name);
}
/* sdp session timing */
if (flags->session_timing.len)
ml->sdp_session_timing = call_strdup_str(&flags->session_timing);
ml->sdp_session_timing = call_str_cpy(&flags->session_timing);
/* sdp bandwidth per session level
* 0 value is supported (e.g. b=RR:0 and b=RS:0), to be able to disable rtcp */
ml->sdp_session_bandwidth.as = flags->session_bandwidth.as;
@ -2689,7 +2689,7 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, struct c
ml->sdp_session_bandwidth.tias = flags->session_bandwidth.tias;
/* sdp session group */
if (flags->session_group.len)
ml->sdp_session_group = call_strdup_str(&flags->session_group);
ml->sdp_session_group = call_str_cpy(&flags->session_group);
}
// reset offer ipv4/ipv6/mixed media stats

@ -1490,10 +1490,10 @@ static int redis_tags(call_t *c, struct redis_list *tags, parser_arg arg) {
/* s= */
if (!redis_hash_get_str(&s, rh, "sdp_session_name"))
ml->sdp_session_name = call_strdup_str(&s);
ml->sdp_session_name = call_str_cpy(&s);
/* t= */
if (!redis_hash_get_str(&s, rh, "sdp_session_timing"))
ml->sdp_session_timing = call_strdup_str(&s);
ml->sdp_session_timing = call_str_cpy(&s);
/* o= */
if (!redis_hash_get_str(&s, rh, "sdp_orig_parsed")) {
ml->session_sdp_orig = g_slice_alloc0(sizeof(*ml->session_sdp_orig));
@ -2553,8 +2553,8 @@ static str redis_encode_json(ng_parser_ctx_t *ctx, call_t *c, void **to_free) {
if (ml->metadata.s)
JSON_SET_SIMPLE_STR("metadata", &ml->metadata);
JSON_SET_SIMPLE_CSTR("sdp_session_name", ml->sdp_session_name ? ml->sdp_session_name : "");
JSON_SET_SIMPLE_CSTR("sdp_session_timing", ml->sdp_session_timing ? ml->sdp_session_timing : "");
JSON_SET_SIMPLE_STR("sdp_session_name", &ml->sdp_session_name);
JSON_SET_SIMPLE_STR("sdp_session_timing", &ml->sdp_session_timing);
if (ml->session_sdp_orig) {
JSON_SET_SIMPLE_STR("sdp_orig_username", &ml->session_sdp_orig->username);

@ -2761,10 +2761,11 @@ static void sdp_out_add_origin(GString *out, struct call_monologue *monologue,
static void sdp_out_add_session_name(GString *out, struct call_monologue *monologue)
{
g_string_append(out, "s=");
/* PUBLISH exceptionally doesn't include sdp session name from SDP.
* The session name and other values should be copied only from a source SDP,
* if that is also a media source. For a publish request that's not the case. */
const char * sdp_session_name = rtpe_config.software_id;
/* for the offer/answer model or subscribe don't use the given monologues SDP,
* but try the one of the subscription, because the given monologue itself
@ -2775,22 +2776,27 @@ static void sdp_out_add_session_name(GString *out, struct call_monologue *monolo
/* if a session name was empty in the s= attr of the coming message,
* while processing this ml in `__call_monologue_init_from_flags()`,
* then just keep it empty. */
sdp_session_name = (ms->monologue->sdp_session_name) ? : "";
if (ms->monologue->sdp_session_name.len)
g_string_append_len(out, ms->monologue->sdp_session_name.s, ms->monologue->sdp_session_name.len);
}
else
g_string_append(out, rtpe_config.software_id);
g_string_append_printf(out, "s=%s\r\n", sdp_session_name);
g_string_append(out, "\r\n");
}
static void sdp_out_add_timing(GString *out, struct call_monologue *monologue)
{
const char * sdp_session_timing = "0 0"; /* default */
/* sdp timing per session level */
g_string_append(out, "t=");
struct media_subscription *ms = call_get_top_media_subscription(monologue);
if (ms && ms->monologue && ms->monologue->sdp_session_timing)
sdp_session_timing = ms->monologue->sdp_session_timing;
if (ms && ms->monologue && ms->monologue->sdp_session_timing.len)
g_string_append_len(out, ms->monologue->sdp_session_timing.s, ms->monologue->sdp_session_timing.len);
else
g_string_append(out, "0 0"); /* default */
/* sdp timing per session level */
g_string_append_printf(out, "t=%s\r\n", sdp_session_timing);
g_string_append(out, "\r\n");
}
static void sdp_out_add_other(GString *out, struct call_monologue *monologue,
@ -2811,8 +2817,8 @@ static void sdp_out_add_other(GString *out, struct call_monologue *monologue,
append_attr_to_gstring(out, "ice-lite", NULL, flags, media->type_id);
/* group */
if (ms && ms->monologue && ms->monologue->sdp_session_group && flags->ice_option == ICE_FORCE_RELAY)
append_attr_to_gstring(out, "group", &STR(ms->monologue->sdp_session_group), flags, media->type_id);
if (ms && ms->monologue && ms->monologue->sdp_session_group.len && flags->ice_option == ICE_FORCE_RELAY)
append_attr_to_gstring(out, "group", &ms->monologue->sdp_session_group, flags, media->type_id);
/* carry other session level a= attributes to the outgoing SDP */
monologue->sdp_attr_print(out, monologue, flags);

@ -595,9 +595,9 @@ struct call_monologue {
sdp_origin * session_sdp_orig; /* actual origin belonging to this monologue */
sdp_origin * session_last_sdp_orig; /* previously used origin by other other side */
char *sdp_session_name;
char *sdp_session_timing;
char *sdp_session_group; /* a=group: e.g. BUNDLE */
str sdp_session_name;
str sdp_session_timing;
str sdp_session_group; /* a=group: e.g. BUNDLE */
struct ssrc_hash *ssrc_hash;
str metadata;
struct janus_session *janus_session;

Loading…
Cancel
Save