From 91cb0cab7174e4414d41f38072afec87135aaaac Mon Sep 17 00:00:00 2001 From: Oleksandr Gershkul Date: Thu, 22 Feb 2024 21:17:03 +0200 Subject: [PATCH] Enable Late Offer Answer Mode (LOAM) feature in the pjsua This feature enables empty SDP in the INVITE request. The messages exchanged between the caller (user agent client) and the called party (user agent server) are identical, but responsibility for choosing the media shifts from one to the other. --- pjsip-apps/src/pjsua/pjsua_app.c | 3 +++ pjsip-apps/src/pjsua/pjsua_app_common.h | 1 + pjsip-apps/src/pjsua/pjsua_app_config.c | 14 +++++++++++++- pjsip-apps/src/pjsua/pjsua_app_legacy.c | 10 ++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c index f072b39083..3c819b34ec 100644 --- a/pjsip-apps/src/pjsua/pjsua_app.c +++ b/pjsip-apps/src/pjsua/pjsua_app.c @@ -1998,6 +1998,9 @@ static pj_status_t app_init(void) pjsua_call_setting_default(&call_opt); call_opt.aud_cnt = app_config.aud_cnt; call_opt.vid_cnt = app_config.vid.vid_cnt; + if (app_config.enable_loam) { + call_opt.flag |= PJSUA_CALL_NO_SDP_OFFER; + } #if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 /* Wipe out TLS key settings in transport configs */ diff --git a/pjsip-apps/src/pjsua/pjsua_app_common.h b/pjsip-apps/src/pjsua/pjsua_app_common.h index 06c81718d5..f3359a3792 100644 --- a/pjsip-apps/src/pjsua/pjsua_app_common.h +++ b/pjsip-apps/src/pjsua/pjsua_app_common.h @@ -78,6 +78,7 @@ typedef struct pjsua_app_config pj_bool_t ipv6; pj_bool_t enable_qos; pj_bool_t no_mci; + pj_bool_t enable_loam; pj_bool_t no_tcp; pj_bool_t no_udp; pj_bool_t use_tls; diff --git a/pjsip-apps/src/pjsua/pjsua_app_config.c b/pjsip-apps/src/pjsua/pjsua_app_config.c index 6168f7789a..07dae8d228 100644 --- a/pjsip-apps/src/pjsua/pjsua_app_config.c +++ b/pjsip-apps/src/pjsua/pjsua_app_config.c @@ -95,6 +95,7 @@ static void usage(void) #endif puts (" --set-qos Enable QoS tagging for SIP and media."); puts (" --no-mci Disable message composition indication (RFC 3994)"); + puts (" --set-loam Enable Late offer answer model"); puts (" --local-port=port Set TCP/UDP port. This implicitly enables both "); puts (" TCP and UDP transports on the specified port, unless"); puts (" if TCP or UDP is disabled."); @@ -393,7 +394,8 @@ static pj_status_t parse_args(int argc, char *argv[], OPT_TLS_NEG_TIMEOUT, OPT_TLS_CIPHER, OPT_CAPTURE_DEV, OPT_PLAYBACK_DEV, OPT_CAPTURE_LAT, OPT_PLAYBACK_LAT, OPT_NO_TONES, OPT_JB_MAX_SIZE, - OPT_STDOUT_REFRESH, OPT_STDOUT_REFRESH_TEXT, OPT_IPV6, OPT_QOS, OPT_MCI, + OPT_STDOUT_REFRESH, OPT_STDOUT_REFRESH_TEXT, OPT_IPV6, OPT_QOS, + OPT_MCI, OPT_LOAM, #ifdef _IONBF OPT_STDOUT_NO_BUF, #endif @@ -535,6 +537,7 @@ static pj_status_t parse_args(int argc, char *argv[], #endif { "set-qos", 0, 0, OPT_QOS}, { "no-mci", 0, 0, OPT_MCI}, + { "set-loam", 0, 0, OPT_LOAM}, { "use-timer", 1, 0, OPT_TIMER}, { "timer-se", 1, 0, OPT_TIMER_SE}, { "timer-min-se", 1, 0, OPT_TIMER_MIN_SE}, @@ -1471,6 +1474,9 @@ static pj_status_t parse_args(int argc, char *argv[], case OPT_MCI: cfg->no_mci = PJ_TRUE; break; + case OPT_LOAM: + cfg->enable_loam = PJ_TRUE; + break; case OPT_VIDEO: cfg->vid.vid_cnt = 1; cfg->vid.in_auto_show = PJ_TRUE; @@ -1988,6 +1994,12 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max) if (config->no_mci) { pj_strcat2(&cfg, "--no-mci\n"); } + + /* Late Offer Answer Model */ + if (config->enable_loam) { + pj_strcat2(&cfg, "--set-loam\n"); + } + /* UDP Transport. */ pj_ansi_snprintf(line, sizeof(line), "--local-port %d\n", config->udp_cfg.port); diff --git a/pjsip-apps/src/pjsua/pjsua_app_legacy.c b/pjsip-apps/src/pjsua/pjsua_app_legacy.c index fbc011bf8a..079aadedb1 100644 --- a/pjsip-apps/src/pjsua/pjsua_app_legacy.c +++ b/pjsip-apps/src/pjsua/pjsua_app_legacy.c @@ -734,6 +734,9 @@ static void ui_make_new_call() pjsua_msg_data_init(&msg_data_); TEST_MULTIPART(&msg_data_); + if (app_config.enable_loam) { + call_opt.flag |= PJSUA_CALL_NO_SDP_OFFER; + } pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, &msg_data_, ¤t_call); @@ -773,6 +776,10 @@ static void ui_make_multi_call() tmp = pj_str(result.uri_result); } + if (app_config.enable_loam) { + call_opt.flag |= PJSUA_CALL_NO_SDP_OFFER; + } + for (i=0; i