res_pjsip_session: Add ability to accept multiple sdp answers

pjproject by default currently will follow media forked during an INVITE
on outbound calls if the To tag is different on a subsequent response as
that on an earlier response.  We handle this correctly.  There have
been reported cases where the To tag is the same but we still need to
follow the media.  The pjproject patch in this commit adds the
capability to sip_inv and also adds the capability to control it at
runtime.  The original "different tag" behavior was always controllable
at runtime but we never did anything with it and left it to default to
TRUE.

So, along with the pjproject patch, this commit adds options to both the
system and endpoint objects to control the two behaviors, and a small
logic change to session_inv_on_media_update in res_pjsip_session to
control the behavior at the endpoint level.

The default behavior for "different tags" remains the same at TRUE and
the default for "same tag" is FALSE.

Change-Id: I64d071942b79adb2f0a4e13137389b19404fe3d6
ASTERISK-27936
Reported-by: Ross Beer
This commit is contained in:
George Joseph
2018-06-18 20:22:17 -06:00
parent 017b7849bc
commit 880fbff6b7
13 changed files with 505 additions and 0 deletions

View File

@@ -52,6 +52,13 @@ struct system_config {
} threadpool;
/*! Nonzero to disable switching from UDP to TCP transport */
unsigned int disable_tcp_switch;
/*!
* Although early media is enabled in pjproject by default, it's only
* enabled when the To tags are different. These options allow turning
* on or off the feature for different tags and same tags.
*/
unsigned int follow_early_media_fork;
unsigned int accept_multiple_sdp_answers;
};
static struct ast_threadpool_options sip_threadpool_options = {
@@ -96,6 +103,16 @@ static int system_apply(const struct ast_sorcery *system_sorcery, void *obj)
pjsip_cfg()->tsx.t1 = system->timert1;
pjsip_cfg()->tsx.td = system->timerb;
pjsip_cfg()->endpt.follow_early_media_fork = system->follow_early_media_fork;
#ifdef HAVE_PJSIP_INV_ACCEPT_MULTIPLE_SDP_ANSWERS
pjsip_cfg()->endpt.accept_multiple_sdp_answers = system->accept_multiple_sdp_answers;
#else
if (system->accept_multiple_sdp_answers) {
ast_log(LOG_WARNING,
"The accept_multiple_sdp_answers flag is not supported in this version of pjproject. Ignoring\n");
}
#endif
if (system->compactheaders) {
extern pj_bool_t pjsip_use_compact_form;
@@ -184,6 +201,10 @@ int ast_sip_initialize_system(void)
OPT_UINT_T, 0, FLDSET(struct system_config, threadpool.max_size));
ast_sorcery_object_field_register(system_sorcery, "system", "disable_tcp_switch", "yes",
OPT_BOOL_T, 1, FLDSET(struct system_config, disable_tcp_switch));
ast_sorcery_object_field_register(system_sorcery, "system", "follow_early_media_fork", "yes",
OPT_BOOL_T, 1, FLDSET(struct system_config, follow_early_media_fork));
ast_sorcery_object_field_register(system_sorcery, "system", "accept_multiple_sdp_answers", "no",
OPT_BOOL_T, 1, FLDSET(struct system_config, accept_multiple_sdp_answers));
ast_sorcery_load(system_sorcery);

View File

@@ -1902,6 +1902,8 @@ int ast_res_pjsip_initialize_configuration(void)
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bundle", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.bundle));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "webrtc", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, media.webrtc));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "incoming_mwi_mailbox", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, incoming_mwi_mailbox));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "follow_early_media_fork", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.follow_early_media_fork));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "accept_multiple_sdp_answers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.accept_multiple_sdp_answers));
if (ast_sip_initialize_sorcery_transport()) {
ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");