diff options
author | Jonathan Rose <jrose@digium.com> | 2011-12-23 20:42:21 +0000 |
---|---|---|
committer | Jonathan Rose <jrose@digium.com> | 2011-12-23 20:42:21 +0000 |
commit | 19a4928fee5647b78f58d3b5457117360e09c54c (patch) | |
tree | c4fa60642e82ac9556f660e7cb539d3cec14df3a /channels | |
parent | 03596bcb47858095a6f42492768808def97dcbbe (diff) |
INFO/Record request configurable to use dynamic features
Adds two new options to SIP peers allowing them to specify features (dynamic or builtin)
to use when sending INFO/record requests. Recordonfeature activates whatever feature
is specified when recieving a record: on request while recordofffeature activates
whatever feature is specified when receiving a record: off request. Both of these
features can be disabled by setting the feature to an empty string.
(closes issue ASTERISK-16507)
Reported by: Jon Bright
Review: https://reviewboard.asterisk.org/r/1634/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@349098 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 50 | ||||
-rw-r--r-- | channels/sip/include/sip.h | 6 |
2 files changed, 47 insertions, 9 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 3f12e6e1b..99fb9b024 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -17751,6 +17751,8 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct ao2_t_ref(credentials, -1, "Unref peer auth for show"); } ast_cli(fd, " Context : %s\n", peer->context); + ast_cli(fd, " Record On feature : %s\n", peer->record_on_feature); + ast_cli(fd, " Record Off feature : %s\n", peer->record_off_feature); ast_cli(fd, " Subscr.Cont. : %s\n", S_OR(peer->subscribecontext, "<Not set>") ); ast_cli(fd, " Language : %s\n", peer->language); ast_cli(fd, " Tonezone : %s\n", peer->zone[0] != '\0' ? peer->zone : "<Not set>"); @@ -18502,6 +18504,8 @@ static char *sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_ ast_cli(a->fd, " Allowed transports: %s\n", get_transport_list(default_transports)); ast_cli(a->fd, " Outbound transport: %s\n", sip_get_transport(default_primary_transport)); ast_cli(a->fd, " Context: %s\n", sip_cfg.default_context); + ast_cli(a->fd, " Record on feature: %s\n", sip_cfg.default_record_on_feature); + ast_cli(a->fd, " Record off feature: %s\n", sip_cfg.default_record_off_feature); ast_cli(a->fd, " Force rport: %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[0], SIP_NAT_FORCE_RPORT))); ast_cli(a->fd, " DTMF: %s\n", dtmfmode2str(ast_test_flag(&global_flags[0], SIP_DTMF))); ast_cli(a->fd, " Qualify: %d\n", default_qualify); @@ -19204,15 +19208,13 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req) return; } else if (!ast_strlen_zero(c = sip_get_header(req, "Record"))) { /* INFO messages generated by some phones to start/stop recording - on phone calls. - OEJ: I think this should be something that is enabled/disabled - per device. I don't want incoming callers to record calls in my - pbx. - */ - - struct ast_call_feature *feat; + * on phone calls. + */ + + struct ast_call_feature *feat = NULL; int j; struct ast_frame f = { AST_FRAME_DTMF, }; + int suppress_warning = 0; /* Supress warning if the feature is blank */ if (!p->owner) { /* not a PBX call */ transmit_response(p, "481 Call leg/transaction does not exist", req); @@ -19222,9 +19224,27 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req) /* first, get the feature string, if it exists */ ast_rdlock_call_features(); - feat = ast_find_call_feature("automon"); + if (p->relatedpeer) { + if (!strcasecmp(c, "on")) { + if (ast_strlen_zero(p->relatedpeer->record_on_feature)) { + suppress_warning = 1; + } else { + feat = ast_find_call_feature(p->relatedpeer->record_on_feature); + } + } else if (!strcasecmp(c, "off")) { + if (ast_strlen_zero(p->relatedpeer->record_on_feature)) { + suppress_warning = 1; + } else { + feat = ast_find_call_feature(p->relatedpeer->record_off_feature); + } + } else { + ast_log(LOG_ERROR, "Received INFO requesting to record with invalid value: %s\n", c); + } + } if (!feat || ast_strlen_zero(feat->exten)) { - ast_log(LOG_WARNING, "Recording requested, but no One Touch Monitor registered. (See features.conf)\n"); + if (!suppress_warning) { + ast_log(LOG_WARNING, "Recording requested, but no One Touch Monitor registered. (See features.conf)\n"); + } /* 403 means that we don't support this feature, so don't request it again */ transmit_response(p, "403 Forbidden", req); ast_unlock_call_features(); @@ -27666,6 +27686,8 @@ static void set_peer_defaults(struct sip_peer *peer) ast_copy_flags(&peer->flags[1], &global_flags[1], SIP_PAGE2_FLAGS_TO_COPY); ast_copy_flags(&peer->flags[2], &global_flags[2], SIP_PAGE3_FLAGS_TO_COPY); ast_string_field_set(peer, context, sip_cfg.default_context); + ast_string_field_set(peer, record_on_feature, sip_cfg.default_record_on_feature); + ast_string_field_set(peer, record_off_feature, sip_cfg.default_record_off_feature); ast_string_field_set(peer, messagecontext, sip_cfg.messagecontext); ast_string_field_set(peer, subscribecontext, sip_cfg.default_subscribecontext); ast_string_field_set(peer, language, default_language); @@ -27975,6 +27997,10 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str } else if (!strcasecmp(v->name, "context")) { ast_string_field_set(peer, context, v->value); ast_set_flag(&peer->flags[1], SIP_PAGE2_HAVEPEERCONTEXT); + } else if (!strcasecmp(v->name, "recordonfeature")) { + ast_string_field_set(peer, record_on_feature, v->value); + } else if (!strcasecmp(v->name, "recordofffeature")) { + ast_string_field_set(peer, record_off_feature, v->value); } else if (!strcasecmp(v->name, "outofcall_message_context")) { ast_string_field_set(peer, messagecontext, v->value); } else if (!strcasecmp(v->name, "subscribecontext")) { @@ -28734,6 +28760,8 @@ static int reload_config(enum channelreloadreason reason) /* Initialize some reasonable defaults at SIP reload (used both for channel and as default for devices */ ast_copy_string(sip_cfg.default_context, DEFAULT_CONTEXT, sizeof(sip_cfg.default_context)); + ast_copy_string(sip_cfg.default_record_on_feature, DEFAULT_RECORD_FEATURE, sizeof(sip_cfg.default_record_on_feature)); + ast_copy_string(sip_cfg.default_record_off_feature, DEFAULT_RECORD_FEATURE, sizeof(sip_cfg.default_record_off_feature)); sip_cfg.default_subscribecontext[0] = '\0'; sip_cfg.default_max_forwards = DEFAULT_MAX_FORWARDS; default_language[0] = '\0'; @@ -28801,6 +28829,10 @@ static int reload_config(enum channelreloadreason reason) if (!strcasecmp(v->name, "context")) { ast_copy_string(sip_cfg.default_context, v->value, sizeof(sip_cfg.default_context)); + } else if (!strcasecmp(v->name, "recordonfeature")) { + ast_copy_string(sip_cfg.default_record_on_feature, v->value, sizeof(sip_cfg.default_record_on_feature)); + } else if (!strcasecmp(v->name, "recordofffeature")) { + ast_copy_string(sip_cfg.default_record_off_feature, v->value, sizeof(sip_cfg.default_record_off_feature)); } else if (!strcasecmp(v->name, "subscribecontext")) { ast_copy_string(sip_cfg.default_subscribecontext, v->value, sizeof(sip_cfg.default_subscribecontext)); } else if (!strcasecmp(v->name, "callcounter")) { diff --git a/channels/sip/include/sip.h b/channels/sip/include/sip.h index 84f3af93b..ad9e7819f 100644 --- a/channels/sip/include/sip.h +++ b/channels/sip/include/sip.h @@ -34,6 +34,7 @@ #include "asterisk/astobj.h" #include "asterisk/indications.h" #include "asterisk/security_events.h" +#include "asterisk/features.h" #ifndef FALSE #define FALSE 0 @@ -182,6 +183,7 @@ */ /*@{*/ #define DEFAULT_CONTEXT "default" /*!< The default context for [general] section as well as devices */ +#define DEFAULT_RECORD_FEATURE "automon" /*!< The default feature specified for use with INFO */ #define DEFAULT_MOHINTERPRET "default" /*!< The default music class */ #define DEFAULT_MOHSUGGEST "" #define DEFAULT_VMEXTEN "asterisk" /*!< Default voicemail extension */ @@ -744,6 +746,8 @@ struct sip_settings { struct sip_proxy outboundproxy; /*!< Outbound proxy */ char default_context[AST_MAX_CONTEXT]; char default_subscribecontext[AST_MAX_CONTEXT]; + char default_record_on_feature[FEATURE_MAX_LEN]; + char default_record_off_feature[FEATURE_MAX_LEN]; struct ast_ha *contact_ha; /*! \brief Global list of addresses dynamic peers are not allowed to use */ struct ast_format_cap *caps; /*!< Supported codecs */ int tcp_enabled; @@ -1243,6 +1247,8 @@ struct sip_peer { AST_STRING_FIELD(engine); /*!< RTP Engine to use */ AST_STRING_FIELD(unsolicited_mailbox); /*!< Mailbox to store received unsolicited MWI NOTIFY messages information in */ AST_STRING_FIELD(zone); /*!< Tonezone for this device */ + AST_STRING_FIELD(record_on_feature); /*!< Feature to use when receiving INFO with record: on during a call */ + AST_STRING_FIELD(record_off_feature); /*!< Feature to use when receiving INFO with record: off during a call */ ); struct sip_socket socket; /*!< Socket used for this peer */ enum sip_transport default_outbound_transport; /*!< Peer Registration may change the default outbound transport. |