mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Geolocation: chan_pjsip Capability Preview
This commit adds res_pjsip_geolocation which gives chan_pjsip the ability to use the core geolocation capabilities. This commit message is intentionally short because this isn't a simple capability. See the documentation at https://wiki.asterisk.org/wiki/display/AST/Geolocation for more information. THE CAPABILITIES IMPLEMENTED HERE MAY CHANGE BASED ON USER FEEDBACK! ASTERISK-30128 Change-Id: Ie2e2bcd87243c2cfabc43eb823d4427c7086f4d9
This commit is contained in:
committed by
Friendly Automation
parent
639d72e98c
commit
1fa568e76f
@@ -21,6 +21,7 @@
|
||||
#include <pjsip.h>
|
||||
#include <pjsip_ua.h>
|
||||
|
||||
#include "asterisk/res_geolocation.h"
|
||||
#include "asterisk/res_pjsip.h"
|
||||
#include "include/res_pjsip_private.h"
|
||||
#include "asterisk/res_pjsip_cli.h"
|
||||
@@ -1539,6 +1540,36 @@ static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *o
|
||||
}
|
||||
}
|
||||
|
||||
if (!ast_strlen_zero(endpoint->geoloc_incoming_call_profile) ||
|
||||
!ast_strlen_zero(endpoint->geoloc_outgoing_call_profile)) {
|
||||
|
||||
if (!ast_geoloc_is_loaded()) {
|
||||
ast_log(LOG_ERROR, "A geoloc incoming and/or outgoing call_profile was specified on endpoint '%s'"
|
||||
" but res_geolocation is not loaded.\n", ast_sorcery_object_get_id(endpoint));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ast_strlen_zero(endpoint->geoloc_incoming_call_profile)) {
|
||||
struct ast_geoloc_profile *profile = ast_geoloc_get_profile(endpoint->geoloc_incoming_call_profile);
|
||||
if (!profile) {
|
||||
ast_log(LOG_ERROR, "geoloc_incoming_call_profile '%s' on endpoint '%s' doesn't exist\n",
|
||||
endpoint->geoloc_incoming_call_profile, ast_sorcery_object_get_id(endpoint));
|
||||
return -1;
|
||||
}
|
||||
ao2_cleanup(profile);
|
||||
}
|
||||
|
||||
if (!ast_strlen_zero(endpoint->geoloc_outgoing_call_profile)) {
|
||||
struct ast_geoloc_profile *profile = ast_geoloc_get_profile(endpoint->geoloc_outgoing_call_profile);
|
||||
if (!profile) {
|
||||
ast_log(LOG_ERROR, "geoloc_outgoing_call_profile '%s' on endpoint '%s' doesn't exist\n",
|
||||
endpoint->geoloc_outgoing_call_profile, ast_sorcery_object_get_id(endpoint));
|
||||
return -1;
|
||||
}
|
||||
ao2_cleanup(profile);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2194,6 +2225,8 @@ int ast_res_pjsip_initialize_configuration(void)
|
||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "stir_shaken", "off", stir_shaken_handler, stir_shaken_to_str, NULL, 0, 0);
|
||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "stir_shaken_profile", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, stir_shaken_profile));
|
||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_unauthenticated_options", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_unauthenticated_options));
|
||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "geoloc_incoming_call_profile", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, geoloc_incoming_call_profile));
|
||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "geoloc_outgoing_call_profile", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, geoloc_outgoing_call_profile));
|
||||
|
||||
if (ast_sip_initialize_sorcery_transport()) {
|
||||
ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
|
||||
@@ -2354,6 +2387,12 @@ void *ast_sip_endpoint_alloc(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ast_string_field_init_extended(endpoint, geoloc_incoming_call_profile) ||
|
||||
ast_string_field_init_extended(endpoint, geoloc_outgoing_call_profile)) {
|
||||
ao2_cleanup(endpoint);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(endpoint->media.codecs = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
|
||||
ao2_cleanup(endpoint);
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user