[svn-commits] jrose: trunk r349098 - in /trunk: channels/ channels/sip/include/ configs/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 23 14:42:26 CST 2011


Author: jrose
Date: Fri Dec 23 14:42:21 2011
New Revision: 349098

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=349098
Log:
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/


Modified:
    trunk/channels/chan_sip.c
    trunk/channels/sip/include/sip.h
    trunk/configs/sip.conf.sample
    trunk/main/features.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=349098&r1=349097&r2=349098
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Dec 23 14:42:21 2011
@@ -17751,6 +17751,8 @@
 			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 @@
 	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 @@
 		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 @@
 
 		/* 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 @@
 	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 @@
 			} 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 @@
 
 	/* 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 @@
 
 		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")) {

Modified: trunk/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/sip.h?view=diff&rev=349098&r1=349097&r2=349098
==============================================================================
--- trunk/channels/sip/include/sip.h (original)
+++ trunk/channels/sip/include/sip.h Fri Dec 23 14:42:21 2011
@@ -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_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 @@
 		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.

Modified: trunk/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=349098&r1=349097&r2=349098
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Fri Dec 23 14:42:21 2011
@@ -143,6 +143,16 @@
                                 ; In this case Realm will be based on request 'From'/'To' header
                                 ; and should match one of domain names.
                                 ; Otherwise default 'realm=...' will be used.
+;recordonfeature=automixmon	; Default feature to use when receiving 'Record: on' header
+				; from an INFO message. Defaults to 'automon'. Works with
+				; dynamic features. Feature must be usable on requesting
+				; channel for it to work. Setting this value to a blank
+				; will disable it.
+;recordofffeature=automixmon	; Default feature to use when receiving 'Record: off' header
+				; from an INFO message. Defaults to 'automon'. Works with
+				; dynamic features. Feature must be usable on requesting
+				; channel for it to work. Setting this value to a blank
+				; will disable it.
 
 ; With the current situation, you can do one of four things:
 ;  a) Listen on a specific IPv4 address.      Example: bindaddr=192.0.2.1
@@ -1268,6 +1278,8 @@
 ;[grandstream1]
 ;type=friend
 ;context=from-sip                ; Where to start in the dialplan when this phone calls
+;recordonfeature=dynamicfeature1 ; Feature to use when INFO with Record: on is received.
+;recordofffeature=dynamicfeature2 ; Feature to use when INFO with Record: off is received.
 ;callerid=John Doe <1234>        ; Full caller ID, to override the phones config
                                  ; on incoming calls to Asterisk
 ;description=Courtesy Phone      ; Description of the peer. Shown when doing 'sip show peers'.

Modified: trunk/main/features.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/features.c?view=diff&rev=349098&r1=349097&r2=349098
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Fri Dec 23 14:42:21 2011
@@ -3015,7 +3015,8 @@
 		if (!strcasecmp(name, builtin_features[x].sname))
 			return &builtin_features[x];
 	}
-	return NULL;
+
+	return find_dynamic_feature(name);
 }
 
 /*!




More information about the svn-commits mailing list