[asterisk-commits] qwell: branch qwell/fun_with_transports r387957 - in /team/qwell/fun_with_tra...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 8 09:30:27 CDT 2013


Author: qwell
Date: Wed May  8 09:29:52 2013
New Revision: 387957

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387957
Log:
Multiple revisions 387523,387549,387567,387574,387580,387582,387598,387637,387667,387695,387747,387808,387831,387911,387939

........
  r387523 | root | 2013-05-02 16:18:04 -0500 (Thu, 02 May 2013) | 11 lines
  
  Migrate AMI VarSet events raised by GoSub local variables
  
  This patch moves VarSet events for local variables raised by GoSub
  over to Stasis-Core. It also tweaks up the post-processing documentation
  scripts to not combine parameters if both parameters are already documented.
  
  (issue ASTERISK-21462)
  ........
  
  Merged revisions 387519 from file:///srv/subversion/repos/asterisk/trunk
........
  r387549 | root | 2013-05-03 07:18:36 -0500 (Fri, 03 May 2013) | 7 lines
  
  Use the configured formats for Gulp sessions if there are no joint formats between requested formats and configured formats.
  
  (closes issue ASTERISK-21756)
  ........
  
  Merged revisions 387545 from file:///srv/subversion/repos/asterisk/trunk
........
  r387567 | qwell | 2013-05-03 09:12:27 -0500 (Fri, 03 May 2013) | 1 line
  
  Fix svn:keywords property.
........
  r387574 | kharwell | 2013-05-03 10:42:05 -0500 (Fri, 03 May 2013) | 13 lines
  
  SIP Messaging for new channel driver.
  
  Adds messaging support to the new SIP work being done in Asterisk. For the most
  part this replicates the existing messaging features found in chan_sip.  For
  instance, this module supports both out of call and in-dialog MESSAGE requests,
  sending an out of call MESSAGE request via the MessageSend application, and
  exposes handled requests in the MESSAGE/MESSAGE_DATA functions just to name
  a few.
  
  (closes issue ASTERISK-21076)
  Reported by: Matt Jordan
  Review: https://reviewboard.asterisk.org/r/2423/
........
  r387580 | kharwell | 2013-05-03 11:22:32 -0500 (Fri, 03 May 2013) | 23 lines
  
  SIP Media negotiations
  
  Added a dialplan function GULP_MEDIA_OFFER that accepts a codec type (example:
  'audio') and allows overriding, or re-ordering, of an endpoints codecs
  prior to dialing (e.g. using a pre-dial handler).  This adds functionality
  for outbound requests only.
  
  ; sets the outgoing codecs to be ulaw,g722
  Example: Set(GULP_MEDIA_OFFER(audio)=ulaw,g722)
  
  Note that using this function and setting new media offers completely
  overrides what is specified on the endpoint.  Currently it is allowed to
  even list a codec that was not previously specified on the endpoint.
  
  The code allows for un/registering of media offer types that can be
  associated with the function itself.  This allows for future expansion of
  other types, for example T.38.  Types 'audio' and 'video' are currently
  supported.
  
  (closes issue ASTERISK-21186)
  Reported by: Matt Jordan
  Review: https://reviewboard.asterisk.org/r/2445/
........
  r387582 | kharwell | 2013-05-03 11:32:47 -0500 (Fri, 03 May 2013) | 14 lines
  
  Call forwarding & diversion headers
  
  Adds call forwarding support (Josh's patch) to the new SIP work being done in
  Asterisk.  This also includes the ability to add a diversion header to an
  outgoing response/request when appropriate.  The diversion header feature can
  be turned off by setting the send_diversion=false (defaults to true) on an
  endpoint within the configuration file.
  
  (closes issue ASTERISK-21426)
  Reported by: Matt Jordan
  Patches:
  	call-forwarding.diff uploaded by jcolp
  Review: https://reviewboard.asterisk.org/r/2466/
........
  r387598 | root | 2013-05-03 13:18:23 -0500 (Fri, 03 May 2013) | 8 lines
  
  Stasis: Convert network change events into network change stasis messages
  
  (issue ASTERISK-21103)
  Review: https://reviewboard.asterisk.org/r/2490/
  ........
  
  Merged revisions 387594 from file:///srv/subversion/repos/asterisk/trunk
........
  r387637 | root | 2013-05-04 11:18:45 -0500 (Sat, 04 May 2013) | 26 lines
  
  Multiple revisions 387630,387633
  
  ........
    r387630 | mjordan | 2013-05-04 10:24:31 -0500 (Sat, 04 May 2013) | 8 lines
    
    Migrate SHARED's use of the VarSet AMI event to Stasis-Core
    
    This patch removes the direct call to AMI from the SHARED function
    and instead call Stasis-Core. Stasis-Core delivers the notification
    that a shared variable has changed on a channel to all interested
    consumers.
    
    (issue ASTERISK-21462)
  ........
    r387633 | mjordan | 2013-05-04 11:00:46 -0500 (Sat, 04 May 2013) | 7 lines
    
    Clean up documentation; prevent ref leak on exit
    
    This patch:
     * Cleans up some doxygen
     * Prevents leaking the system level Stasis topics and messages
       on exit (users of valgrind will be happier)
  ........
  
  Merged revisions 387630,387633 from file:///srv/subversion/repos/asterisk/trunk
........
  r387667 | root | 2013-05-06 08:18:54 -0500 (Mon, 06 May 2013) | 17 lines
  
  Add support for observers and JSON objectset creation to sorcery.
  
  This change adds the ability for modules to add themselves as observers
  to sorcery object types. Observers can be notified when objects are
  created, updated, or deleted as well as when the object type is loaded or
  reloaded. Observer notifications are done using a thread pool in a serialized
  fashion so the caller of the sorcery API calls is minimally impacted.
  
  This also adds the ability to create JSON changesets of a sorcery object.
  
  Tests are also present to confirm all of the above functionality.
  
  Review: https://reviewboard.asterisk.org/r/2477/
  ........
  
  Merged revisions 387662 from file:///srv/subversion/repos/asterisk/trunk
........
  r387695 | root | 2013-05-06 11:18:10 -0500 (Mon, 06 May 2013) | 26 lines
  
  Make SLA reload more paranoid.
  
  Reload support was originally not included for SLA.  It was added later,
  but in a fairly non-traditional way.  It basically sets a flag
  indicating that a reload is pending, and then waits for a time where it
  thinks everything SLA related is idle and unused, and *then* executes
  the reload.  It does this because the reload process is destructive.  It
  starts by throwing everything away and starting over.
  
  There are a number of problems with this approach.  One of them is that
  the check to see if anything in use was incomplete.  This patch makes it
  more complete and thus less likely for a crash to occur during reload
  processing.  However, this approach still has problems so some much more
  significant reworking of this code will need to come in as a next step.
  
  Patch credit and testing by CoreDial, LLC.
  ........
  
  Merged revisions 387688 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 387689 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 387690 from file:///srv/subversion/repos/asterisk/trunk
........
  r387747 | root | 2013-05-06 12:18:40 -0500 (Mon, 06 May 2013) | 18 lines
  
  Multiple revisions 387738,387740-387741
  
  ........
    r387738 | qwell | 2013-05-06 12:01:41 -0500 (Mon, 06 May 2013) | 1 line
    
    Fix building with LOW_MEMORY defined.
  ........
    r387740 | rmudgett | 2013-05-06 12:09:50 -0500 (Mon, 06 May 2013) | 2 lines
    
    Make a log NOTICE more explicit that the event comes from DAHDI and not PRI.
  ........
    r387741 | rmudgett | 2013-05-06 12:15:20 -0500 (Mon, 06 May 2013) | 1 line
    
    Update ao2_destructor_fn doxygen.
  ........
  
  Merged revisions 387738,387740-387741 from file:///srv/subversion/repos/asterisk/trunk
........
  r387808 | root | 2013-05-07 13:18:35 -0500 (Tue, 07 May 2013) | 14 lines
  
  Multiple revisions 387802-387803
  
  ........
    r387802 | qwell | 2013-05-07 12:53:50 -0500 (Tue, 07 May 2013) | 1 line
    
    Fix build breakage, from LOW_MEMORY fix.
  ........
    r387803 | dlee | 2013-05-07 13:12:26 -0500 (Tue, 07 May 2013) | 1 line
    
    Better explained the depths of reference stealing.
  ........
  
  Merged revisions 387802-387803 from file:///srv/subversion/repos/asterisk/trunk
........
  r387831 | root | 2013-05-07 14:18:39 -0500 (Tue, 07 May 2013) | 21 lines
  
  Multiple revisions 387824-387825
  
  ........
    r387824 | dlee | 2013-05-07 13:30:55 -0500 (Tue, 07 May 2013) | 7 lines
    
    Minor fixups to Doxygen comments.
    
    The \example tags marks an entire file as an example, not a code snippet.
    ........
    
    Merged revisions 387823 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r387825 | dlee | 2013-05-07 13:32:34 -0500 (Tue, 07 May 2013) | 4 lines
    
    Fixed up \example marker in lock.h Doxygen comment.
    
    The \example tags marks an entire file as an example, not a code snippet.
  ........
  
  Merged revisions 387824-387825 from file:///srv/subversion/repos/asterisk/trunk
........
  r387911 | root | 2013-05-08 03:18:33 -0500 (Wed, 08 May 2013) | 28 lines
  
  chan_sip: NOTIFYs for BLF start queuing up and fail to be sent out after retries fail
  
  RFC6665 4.2.2: ... after a failed NOTIFY transaction remove the subscription
  
  The problem is that the State Notify requests rely on the 200OK reponse for pacing control
  and to not confuse the notify susbsystem.
  The issue is, the pendinginvite isn't cleared if a response isn't received,
  thus further notify's are never sent.
  
  The solution, follow RFC 6665 4.2.2.2's 'SHOULD' and remove the subscription after failure.
    
  (closes issue ASTERISK-21677)
  
  Reported by: alecdavis
  Tested by: alecdavis
  alecdavis (license 585)
  
  Review https://reviewboard.asterisk.org/r/2475/
  ........
  
  Merged revisions 387875 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 387880 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 387885 from file:///srv/subversion/repos/asterisk/trunk
........
  r387939 | root | 2013-05-08 09:19:01 -0500 (Wed, 08 May 2013) | 34 lines
  
  Initial support for endpoints.
  
  An endpoint is an external device/system that may offer/accept
  channels to/from Asterisk. While this is a very useful concept for end
  users, it is surprisingly not a core concept within Asterisk itself.
  
  This patch defines ast_endpoint as a separate object, which channel
  drivers may use to expose their concept of an endpoint. As the channel
  driver creates channels, it can use ast_endpoint_add_channel() to
  associate channels to the endpoint. This updated the endpoint
  appropriately, and forwards all of the channel's events to the
  endpoint's topic.
  
  In order to avoid excessive locking on the endpoint object itself, the
  mutable state is not accessible via getters. Instead, you can create a
  snapshot using ast_endpoint_snapshot_create() to get a consistent
  snapshot of the internal state.
  
  This patch also includes a set of topics and messages associated with
  endpoints, and implementations of the endpoint-related RESTful
  API. chan_sip was updated to create endpoints with SIP peers, but the
  state of the endpoints is not updated with the state of the peer.
  
  Along for the ride in this patch is a Stasis test API. This is a
  stasis_message_sink object, which can be subscribed to a Stasis
  topic. It has functions for blocking while waiting for conditions in
  the message sink to be fulfilled.
  
  (closes issue ASTERISK-21421)
  Review: https://reviewboard.asterisk.org/r/2492/
  ........
  
  Merged revisions 387932 from file:///srv/subversion/repos/asterisk/trunk
........

Merged revisions 387523,387549,387567,387574,387580,387582,387598,387637,387667,387695,387747,387808,387831,387911,387939 from http://svn.asterisk.org/svn/asterisk/team/group/pimp_my_sip

Added:
    team/qwell/fun_with_transports/include/asterisk/endpoints.h
      - copied unchanged from r387939, team/group/pimp_my_sip/include/asterisk/endpoints.h
    team/qwell/fun_with_transports/include/asterisk/stasis_endpoints.h
      - copied unchanged from r387939, team/group/pimp_my_sip/include/asterisk/stasis_endpoints.h
    team/qwell/fun_with_transports/include/asterisk/stasis_test.h
      - copied unchanged from r387939, team/group/pimp_my_sip/include/asterisk/stasis_test.h
    team/qwell/fun_with_transports/main/endpoints.c
      - copied unchanged from r387939, team/group/pimp_my_sip/main/endpoints.c
    team/qwell/fun_with_transports/main/stasis_endpoints.c
      - copied unchanged from r387939, team/group/pimp_my_sip/main/stasis_endpoints.c
    team/qwell/fun_with_transports/res/res_sip_diversion.c
      - copied unchanged from r387939, team/group/pimp_my_sip/res/res_sip_diversion.c
    team/qwell/fun_with_transports/res/res_sip_messaging.c
      - copied unchanged from r387939, team/group/pimp_my_sip/res/res_sip_messaging.c
    team/qwell/fun_with_transports/res/res_stasis_test.c
      - copied unchanged from r387939, team/group/pimp_my_sip/res/res_stasis_test.c
    team/qwell/fun_with_transports/res/res_stasis_test.exports.in
      - copied unchanged from r387939, team/group/pimp_my_sip/res/res_stasis_test.exports.in
    team/qwell/fun_with_transports/tests/test_endpoints.c
      - copied unchanged from r387939, team/group/pimp_my_sip/tests/test_endpoints.c
    team/qwell/fun_with_transports/tests/test_stasis_endpoints.c
      - copied unchanged from r387939, team/group/pimp_my_sip/tests/test_stasis_endpoints.c
Modified:
    team/qwell/fun_with_transports/   (props changed)
    team/qwell/fun_with_transports/apps/app_meetme.c
    team/qwell/fun_with_transports/apps/app_stack.c
    team/qwell/fun_with_transports/build_tools/post_process_documentation.py
    team/qwell/fun_with_transports/channels/chan_dahdi.c
    team/qwell/fun_with_transports/channels/chan_gulp.c
    team/qwell/fun_with_transports/channels/chan_iax2.c
    team/qwell/fun_with_transports/channels/chan_sip.c
    team/qwell/fun_with_transports/channels/sip/include/sip.h
    team/qwell/fun_with_transports/funcs/func_global.c
    team/qwell/fun_with_transports/include/asterisk.h
    team/qwell/fun_with_transports/include/asterisk/astobj2.h
    team/qwell/fun_with_transports/include/asterisk/json.h
    team/qwell/fun_with_transports/include/asterisk/lock.h
    team/qwell/fun_with_transports/include/asterisk/res_sip.h
    team/qwell/fun_with_transports/include/asterisk/res_sip_session.h
    team/qwell/fun_with_transports/include/asterisk/sorcery.h
    team/qwell/fun_with_transports/include/asterisk/stasis.h
    team/qwell/fun_with_transports/main/asterisk.c
    team/qwell/fun_with_transports/main/astobj2.c
    team/qwell/fun_with_transports/main/channel_internal_api.c
    team/qwell/fun_with_transports/main/event.c
    team/qwell/fun_with_transports/main/manager.c
    team/qwell/fun_with_transports/main/sorcery.c
    team/qwell/fun_with_transports/main/stasis_cache.c
    team/qwell/fun_with_transports/res/res_config_pgsql.c
    team/qwell/fun_with_transports/res/res_sip.c
    team/qwell/fun_with_transports/res/res_sip/sip_configuration.c
    team/qwell/fun_with_transports/res/res_sip_sdp_rtp.c
    team/qwell/fun_with_transports/res/res_sip_session.c
    team/qwell/fun_with_transports/res/res_sip_session.exports.in
    team/qwell/fun_with_transports/res/res_sorcery_astdb.c
    team/qwell/fun_with_transports/res/res_stasis_http_endpoints.c
    team/qwell/fun_with_transports/res/res_stun_monitor.c
    team/qwell/fun_with_transports/res/stasis_http/resource_endpoints.c
    team/qwell/fun_with_transports/res/stasis_http/resource_endpoints.h
    team/qwell/fun_with_transports/rest-api/api-docs/endpoints.json
    team/qwell/fun_with_transports/tests/test_sorcery.c

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
--- pimp_my_sip-integrated (original)
+++ pimp_my_sip-integrated Wed May  8 09:29:52 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-387509
+/team/group/pimp_my_sip:1-387956

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed May  8 09:29:52 2013
@@ -1,1 +1,1 @@
-/trunk:1-387426
+/trunk:1-387938

Modified: team/qwell/fun_with_transports/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_meetme.c?view=diff&rev=387957&r1=387956&r2=387957
==============================================================================
--- team/qwell/fun_with_transports/apps/app_meetme.c (original)
+++ team/qwell/fun_with_transports/apps/app_meetme.c Wed May  8 09:29:52 2013
@@ -6447,8 +6447,8 @@
 	struct sla_station *station;
 	struct sla_trunk *trunk;
 
-	if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks) 
-		|| !AST_LIST_EMPTY(&sla.ringing_stations)) {
+	if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks)
+		|| !AST_LIST_EMPTY(&sla.ringing_stations) || !AST_LIST_EMPTY(&sla.failed_stations)) {
 		return;
 	}
 
@@ -6464,8 +6464,9 @@
 
 	AST_RWLIST_RDLOCK(&sla_trunks);
 	AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) {
-		if (trunk->ref_count)
+		if (trunk->ref_count || trunk->chan || trunk->active_stations || trunk->hold_stations) {
 			break;
+		}
 	}
 	AST_RWLIST_UNLOCK(&sla_trunks);
 	if (trunk) {
@@ -6718,7 +6719,7 @@
 		return 0;
 	}
 
-	AST_RWLIST_RDLOCK(&sla_stations);
+	AST_RWLIST_WRLOCK(&sla_stations);
 	station = sla_find_station(station_name);
 	if (station)
 		ast_atomic_fetchadd_int((int *) &station->ref_count, 1);
@@ -6930,7 +6931,7 @@
 		}
 	}
 
-	AST_RWLIST_RDLOCK(&sla_trunks);
+	AST_RWLIST_WRLOCK(&sla_trunks);
 	trunk = sla_find_trunk(args.trunk_name);
 	if (trunk)
 		ast_atomic_fetchadd_int((int *) &trunk->ref_count, 1);

Modified: team/qwell/fun_with_transports/apps/app_stack.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_stack.c?view=diff&rev=387957&r1=387956&r2=387957
==============================================================================
--- team/qwell/fun_with_transports/apps/app_stack.c (original)
+++ team/qwell/fun_with_transports/apps/app_stack.c Wed May  8 09:29:52 2013
@@ -40,6 +40,7 @@
 #include "asterisk/manager.h"
 #include "asterisk/channel.h"
 #include "asterisk/agi.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<application name="Gosub" language="en_US">
@@ -202,7 +203,32 @@
 			<para>Cause the channel to execute the specified dialplan subroutine,
 			returning to the dialplan with execution of a Return().</para>
 		</description>
+		<see-also>
+			<ref type="application">GoSub</ref>
+		</see-also>
 	</agi>
+	<managerEvent language="en_US" name="VarSet">
+		<managerEventInstance class="EVENT_FLAG_DIALPLAN">
+			<synopsis>Raised when a variable local to the gosub stack frame is set due to a subroutine call.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Variable">
+					<para>The LOCAL variable being set.</para>
+					<note><para>The variable name will always be enclosed with
+					<literal>LOCAL()</literal></para></note>
+				</parameter>
+				<parameter name="Value">
+					<para>The new value of the variable.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="application">GoSub</ref>
+				<ref type="agi">gosub</ref>
+				<ref type="function">LOCAL</ref>
+				<ref type="function">LOCAL_PEEK</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
  ***/
 
 static const char app_gosub[] = "Gosub";
@@ -235,6 +261,8 @@
 {
 	struct ast_var_t *variables;
 	int found = 0;
+	int len;
+	RAII_VAR(char *, local_buffer, NULL, ast_free);
 
 	/* Does this variable already exist? */
 	AST_LIST_TRAVERSE(&frame->varshead, variables, entries) {
@@ -252,20 +280,13 @@
 		pbx_builtin_setvar_helper(chan, var, value);
 	}
 
-	/*** DOCUMENTATION
-	<managerEventInstance>
-		<synopsis>Raised when a LOCAL channel variable is set due to a subroutine call.</synopsis>
-		<see-also>
-			<ref type="application">GoSub</ref>
-		</see-also>
-	</managerEventInstance>
-	***/
-	manager_event(EVENT_FLAG_DIALPLAN, "VarSet",
-		"Channel: %s\r\n"
-		"Variable: LOCAL(%s)\r\n"
-		"Value: %s\r\n"
-		"Uniqueid: %s\r\n",
-		ast_channel_name(chan), var, value, ast_channel_uniqueid(chan));
+	len = 8 + strlen(var); /* LOCAL() + var */
+	local_buffer = ast_malloc(len);
+	if (!local_buffer) {
+		return 0;
+	}
+	sprintf(local_buffer, "LOCAL(%s)", var);
+	ast_channel_publish_varset(chan, local_buffer, value);
 	return 0;
 }
 

Modified: team/qwell/fun_with_transports/build_tools/post_process_documentation.py
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/build_tools/post_process_documentation.py?view=diff&rev=387957&r1=387956&r2=387957
==============================================================================
--- team/qwell/fun_with_transports/build_tools/post_process_documentation.py (original)
+++ team/qwell/fun_with_transports/build_tools/post_process_documentation.py Wed May  8 09:29:52 2013
@@ -22,9 +22,9 @@
 
     def __swap_parameter_documentation(one, two):
         # See who has the better documentation and use it
-        if (one.hasChildNodes()):
+        if (one.hasChildNodes() and not two.hasChildNodes()):
             two.parentNode.replaceChild(one.cloneNode(True), two)
-        elif (two.hasChildNodes()):
+        elif (two.hasChildNodes() and not one.hasChildNodes()):
             one.parentNode.replaceChild(two.cloneNode(True), one)
 
     def __merge_parameter(param, other_instances):

Modified: team/qwell/fun_with_transports/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_dahdi.c?view=diff&rev=387957&r1=387956&r2=387957
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_dahdi.c (original)
+++ team/qwell/fun_with_transports/channels/chan_dahdi.c Wed May  8 09:29:52 2013
@@ -3271,7 +3271,7 @@
 		}
 		/* Fall through */
 	default:
-		ast_log(LOG_NOTICE, "PRI got event: %s (%d) on D-channel of span %d\n",
+		ast_log(LOG_NOTICE, "Got DAHDI event: %s (%d) on D-channel of span %d\n",
 			event2str(x), x, pri->span);
 		break;
 	}

Modified: team/qwell/fun_with_transports/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_gulp.c?view=diff&rev=387957&r1=387956&r2=387957
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_gulp.c (original)
+++ team/qwell/fun_with_transports/channels/chan_gulp.c Wed May  8 09:29:52 2013
@@ -77,6 +77,19 @@
 			<para>Returns a properly formatted dial string for dialing all contacts on an AOR.</para>
 		</description>
 	</function>
+	<function name="GULP_MEDIA_OFFER" language="en_US">
+		<synopsis>
+			Media and codec offerings to be set on an outbound SIP channel prior to dialing.
+		</synopsis>
+		<syntax>
+			<parameter name="media" required="true">
+				<para>types of media offered</para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>Returns the codecs offered based upon the media choice</para>
+		</description>
+	</function>
  ***/
 
 static const char desc[] = "Gulp SIP Channel";
@@ -247,6 +260,105 @@
 	.read = gulp_dial_contacts,
 };
 
+static int media_offer_read_av(struct ast_sip_session *session, char *buf,
+			       size_t len, enum ast_format_type media_type)
+{
+	int i, size = 0;
+	struct ast_format fmt;
+	const char *name;
+
+	for (i = 0; ast_codec_pref_index(&session->override_prefs, i, &fmt); ++i) {
+		if (AST_FORMAT_GET_TYPE(fmt.id) != media_type) {
+			continue;
+		}
+
+		name = ast_getformatname(&fmt);
+
+		if (ast_strlen_zero(name)) {
+			ast_log(LOG_WARNING, "GULP_MEDIA_OFFER unrecognized format %s\n", name);
+			continue;
+		}
+
+		/* add one since we'll include a comma */
+		size = strlen(name) + 1;
+		len -= size;
+		if ((len) < 0) {
+			break;
+		}
+
+		/* no reason to use strncat here since we have already ensured buf has
+                   enough space, so strcat can be safely used */
+		strcat(buf, name);
+		strcat(buf, ",");
+	}
+
+	if (size) {
+		/* remove the extra comma */
+		buf[strlen(buf) - 1] = '\0';
+	}
+	return 0;
+}
+
+struct media_offer_data {
+	struct ast_sip_session *session;
+	enum ast_format_type media_type;
+	const char *value;
+};
+
+static int media_offer_write_av(void *obj)
+{
+	struct media_offer_data *data = obj;
+	int i;
+	struct ast_format fmt;
+	/* remove all of the given media type first */
+	for (i = 0; ast_codec_pref_index(&data->session->override_prefs, i, &fmt); ++i) {
+		if (AST_FORMAT_GET_TYPE(fmt.id) == data->media_type) {
+			ast_codec_pref_remove(&data->session->override_prefs, &fmt);
+		}
+	}
+	ast_format_cap_remove_bytype(data->session->req_caps, data->media_type);
+	ast_parse_allow_disallow(&data->session->override_prefs, data->session->req_caps, data->value, 1);
+
+	return 0;
+}
+
+static int media_offer_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(chan);
+
+	if (!strcmp(data, "audio")) {
+		return media_offer_read_av(pvt->session, buf, len, AST_FORMAT_TYPE_AUDIO);
+	} else if (!strcmp(data, "video")) {
+		return media_offer_read_av(pvt->session, buf, len, AST_FORMAT_TYPE_VIDEO);
+	}
+
+	return 0;
+}
+
+static int media_offer_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(chan);
+
+	struct media_offer_data mdata = {
+		.session = pvt->session,
+		.value = value
+	};
+
+	if (!strcmp(data, "audio")) {
+		mdata.media_type = AST_FORMAT_TYPE_AUDIO;
+	} else if (!strcmp(data, "video")) {
+		mdata.media_type = AST_FORMAT_TYPE_VIDEO;
+	}
+
+	return ast_sip_push_task_synchronous(pvt->session->serializer, media_offer_write_av, &mdata);
+}
+
+static struct ast_custom_function media_offer_function = {
+	.name = "GULP_MEDIA_OFFER",
+	.read = media_offer_read,
+	.write = media_offer_write
+};
+
 /*! \brief Function called by RTP engine to get local audio RTP peer */
 static enum ast_rtp_glue_result gulp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
 {
@@ -434,7 +546,7 @@
 	pvt->media[SIP_MEDIA_VIDEO] = ao2_find(session->media, "video", OBJ_KEY);
 	ast_channel_tech_pvt_set(chan, pvt);
 
-	if (ast_format_cap_is_empty(session->req_caps)) {
+	if (ast_format_cap_is_empty(session->req_caps) || !ast_format_cap_has_joint(session->req_caps, session->endpoint->codecs)) {
 		ast_format_cap_copy(ast_channel_nativeformats(chan), session->endpoint->codecs);
 	} else {
 		ast_format_cap_copy(ast_channel_nativeformats(chan), session->req_caps);
@@ -935,16 +1047,17 @@
 static int call(void *data)
 {
 	struct ast_sip_session *session = data;
-	pjsip_tx_data *packet;
-
-	if (pjsip_inv_invite(session->inv_session, &packet) != PJ_SUCCESS) {
+	pjsip_tx_data *tdata;
+
+	int res = ast_sip_session_create_invite(session, &tdata);
+
+	if (res) {
 		ast_queue_hangup(session->channel);
 	} else {
-		ast_sip_session_send_request(session, packet);
-	}
-
+		ast_sip_session_send_request(session, tdata);
+	}
 	ao2_ref(session, -1);
-	return 0;
+	return res;
 }
 
 /*! \brief Function called by core to actually start calling a remote party */
@@ -1164,9 +1277,66 @@
 	return session->channel;
 }
 
+struct sendtext_data {
+	struct ast_sip_session *session;
+	char text[0];
+};
+
+static void sendtext_data_destroy(void *obj)
+{
+	struct sendtext_data *data = obj;
+	ao2_ref(data->session, -1);
+}
+
+static struct sendtext_data* sendtext_data_create(struct ast_sip_session *session, const char *text)
+{
+	int size = strlen(text) + 1;
+	struct sendtext_data *data = ao2_alloc(sizeof(*data)+size, sendtext_data_destroy);
+
+	if (!data) {
+		return NULL;
+	}
+
+	data->session = session;
+	ao2_ref(data->session, +1);
+	ast_copy_string(data->text, text, size);
+	return data;
+}
+
+static int sendtext(void *obj)
+{
+	RAII_VAR(struct sendtext_data *, data, obj, ao2_cleanup);
+	pjsip_tx_data *tdata;
+
+	const struct ast_sip_body body = {
+		.type = "text",
+		.subtype = "plain",
+		.body_text = data->text
+	};
+
+	/* NOT ast_strlen_zero, because a zero-length message is specifically
+	 * allowed by RFC 3428 (See section 10, Examples) */
+	if (!data->text) {
+		return 0;
+	}
+
+	ast_sip_create_request("MESSAGE", data->session->inv_session->dlg, data->session->endpoint, NULL, &tdata);
+	ast_sip_add_body(tdata, &body);
+	ast_sip_send_request(tdata, data->session->inv_session->dlg, data->session->endpoint);
+
+	return 0;
+}
+
 /*! \brief Function called by core to send text on Gulp session */
 static int gulp_sendtext(struct ast_channel *ast, const char *text)
 {
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+	struct sendtext_data *data = sendtext_data_create(pvt->session, text);
+
+	if (!data || ast_sip_push_task(pvt->session->serializer, sendtext, data)) {
+		ao2_ref(data, -1);
+		return -1;
+	}
 	return 0;
 }
 
@@ -1300,7 +1470,6 @@
 static int gulp_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
 {
 	pjsip_tx_data *packet = NULL;
-	int res = AST_PBX_FAILED;
 
 	if (session->channel) {
 		return 0;
@@ -1314,6 +1483,14 @@
 		ast_log(LOG_ERROR, "Failed to allocate new GULP channel on incoming SIP INVITE\n");
 		return -1;
 	}
+	/* channel gets created on incoming request, but we wait to call start
+           so other supplements have a chance to run */
+	return 0;
+}
+
+static int pbx_start_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
+{
+	int res;
 
 	ast_setstate(session->channel, AST_STATE_RING);
 	res = ast_pbx_start(session->channel);
@@ -1338,6 +1515,12 @@
 
 	return (res == AST_PBX_SUCCESS) ? 0 : -1;
 }
+
+static struct ast_sip_session_supplement pbx_start_supplement = {
+	.method = "INVITE",
+	.priority = AST_SIP_SESSION_SUPPLEMENT_PRIORITY_LAST,
+	.incoming_request = pbx_start_incoming_request,
+};
 
 /*! \brief Function called when a response is received on the session */
 static void gulp_incoming_response(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
@@ -1406,13 +1589,24 @@
 		goto end;
 	}
 
+	if (ast_custom_function_register(&media_offer_function)) {
+		ast_log(LOG_WARNING, "Unable to register GULP_MEDIA_OFFER dialplan function\n");
+	}
+
 	if (ast_sip_session_register_supplement(&gulp_supplement)) {
 		ast_log(LOG_ERROR, "Unable to register Gulp supplement\n");
 		goto end;
 	}
 
+	if (ast_sip_session_register_supplement(&pbx_start_supplement)) {
+		ast_log(LOG_ERROR, "Unable to register Gulp pbx start supplement\n");
+		ast_sip_session_unregister_supplement(&gulp_supplement);
+		goto end;
+	}
+
 	if (ast_sip_session_register_supplement(&gulp_ack_supplement)) {
 		ast_log(LOG_ERROR, "Unable to register Gulp ACK supplement\n");
+		ast_sip_session_unregister_supplement(&pbx_start_supplement);
 		ast_sip_session_unregister_supplement(&gulp_supplement);
 		goto end;
 	}
@@ -1420,6 +1614,7 @@
 	return 0;
 
 end:
+	ast_custom_function_unregister(&media_offer_function);
 	ast_custom_function_unregister(&gulp_dial_contacts_function);
 	ast_channel_unregister(&gulp_tech);
 	ast_rtp_glue_unregister(&gulp_rtp_glue);
@@ -1436,7 +1631,11 @@
 /*! \brief Unload the Gulp channel from Asterisk */
 static int unload_module(void)
 {
+	ast_custom_function_unregister(&media_offer_function);
+
 	ast_sip_session_unregister_supplement(&gulp_supplement);
+	ast_sip_session_unregister_supplement(&pbx_start_supplement);
+
 	ast_custom_function_unregister(&gulp_dial_contacts_function);
 	ast_channel_unregister(&gulp_tech);
 	ast_rtp_glue_unregister(&gulp_rtp_glue);

Modified: team/qwell/fun_with_transports/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_iax2.c?view=diff&rev=387957&r1=387956&r2=387957
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_iax2.c (original)
+++ team/qwell/fun_with_transports/channels/chan_iax2.c Wed May  8 09:29:52 2013
@@ -283,9 +283,9 @@
 static char language[MAX_LANGUAGE] = "";
 static char regcontext[AST_MAX_CONTEXT] = "";
 
-static struct ast_event_sub *network_change_event_subscription; /*!< subscription id for network change events */
+static struct stasis_subscription *network_change_sub; /*!< subscription id for network change events */
 static struct stasis_subscription *acl_change_sub; /*!< subscription id for ACL change events */
-static int network_change_event_sched_id = -1;
+static int network_change_sched_id = -1;
 
 static int maxauthreq = 3;
 static int max_retries = 4;
@@ -1254,7 +1254,7 @@
 static int get_unused_callno(enum callno_type type, int validated, callno_entry *entry);
 static int replace_callno(const void *obj);
 static void sched_delay_remove(struct sockaddr_in *sin, callno_entry entry);
-static void network_change_event_cb(const struct ast_event *, void *);
+static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 
 static struct ast_channel_tech iax2_tech = {
@@ -1323,18 +1323,18 @@
 	 * is time to send MWI, since it is only sent with a REGACK. */
 }
 
-static void network_change_event_subscribe(void)
-{
-	if (!network_change_event_subscription) {
-		network_change_event_subscription = ast_event_subscribe(AST_EVENT_NETWORK_CHANGE,
-			network_change_event_cb, "IAX2 Network Change", NULL, AST_EVENT_IE_END);
-	}
-}
-
-static void network_change_event_unsubscribe(void)
-{
-	if (network_change_event_subscription) {
-		network_change_event_subscription = ast_event_unsubscribe(network_change_event_subscription);
+static void network_change_stasis_subscribe(void)
+{
+	if (!network_change_sub) {
+		network_change_sub = stasis_subscribe(ast_system_topic(),
+			network_change_stasis_cb, NULL);
+	}
+}
+
+static void network_change_stasis_unsubscribe(void)
+{
+	if (network_change_sub) {
+		network_change_sub = stasis_unsubscribe(network_change_sub);
 	}
 }
 
@@ -1353,10 +1353,10 @@
 	}
 }
 
-static int network_change_event_sched_cb(const void *data)
+static int network_change_sched_cb(const void *data)
 {
 	struct iax2_registry *reg;
-	network_change_event_sched_id = -1;
+	network_change_sched_id = -1;
 	AST_LIST_LOCK(&registrations);
 	AST_LIST_TRAVERSE(&registrations, reg, entry) {
 		iax2_do_register(reg);
@@ -1366,13 +1366,18 @@
 	return 0;
 }
 
-static void network_change_event_cb(const struct ast_event *event, void *userdata)
-{
-	ast_debug(1, "IAX, got a network change event, renewing all IAX registrations.\n");
-	if (network_change_event_sched_id == -1) {
-		network_change_event_sched_id = iax2_sched_add(sched, 1000, network_change_event_sched_cb, NULL);
-	}
-
+static void network_change_stasis_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic, struct stasis_message *message)
+{
+	/* This callback is only concerned with network change messages from the system topic. */
+	if (stasis_message_type(message) != ast_network_change_type()) {
+		return;
+	}
+
+	ast_verb(1, "IAX, got a network change message, renewing all IAX registrations.\n");
+	if (network_change_sched_id == -1) {
+		network_change_sched_id = iax2_sched_add(sched, 1000, network_change_sched_cb, NULL);
+	}
 }
 
 static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub,
@@ -13442,9 +13447,9 @@
 	}
 
 	if (subscribe_network_change) {
-		network_change_event_subscribe();
+		network_change_stasis_subscribe();
 	} else {
-		network_change_event_unsubscribe();
+		network_change_stasis_unsubscribe();
 	}
 
 	if (defaultsockfd < 0) {
@@ -14287,7 +14292,7 @@
 	struct ast_context *con;
 	int x;
 
-	network_change_event_unsubscribe();
+	network_change_stasis_unsubscribe();
 	acl_change_stasis_unsubscribe();
 
 	ast_manager_unregister("IAXpeers");
@@ -14789,7 +14794,7 @@
 
 	ast_realtime_require_field("iaxpeers", "name", RQ_CHAR, 10, "ipaddr", RQ_CHAR, 15, "port", RQ_UINTEGER2, 5, "regseconds", RQ_UINTEGER2, 6, SENTINEL);
 
-	network_change_event_subscribe();
+	network_change_stasis_subscribe();
 
 	return AST_MODULE_LOAD_SUCCESS;
 }

Modified: team/qwell/fun_with_transports/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_sip.c?view=diff&rev=387957&r1=387956&r2=387957
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_sip.c (original)
+++ team/qwell/fun_with_transports/channels/chan_sip.c Wed May  8 09:29:52 2013
@@ -294,6 +294,7 @@
 #include "sip/include/security_events.h"
 #include "asterisk/sip_api.h"
 #include "asterisk/app.h"
+#include "asterisk/stasis_endpoints.h"
 
 /*** DOCUMENTATION
 	<application name="SIPDtmfMode" language="en_US">
@@ -842,9 +843,9 @@
 static struct ast_flags global_flags[3] = {{0}};  /*!< global SIP_ flags */
 static int global_t38_maxdatagram;                /*!< global T.38 FaxMaxDatagram override */
 
-static struct ast_event_sub *network_change_event_subscription; /*!< subscription id for network change events */
+static struct stasis_subscription *network_change_sub; /*!< subscription id for network change events */
 static struct stasis_subscription *acl_change_sub; /*!< subscription id for named ACL system change events */
-static int network_change_event_sched_id = -1;
+static int network_change_sched_id = -1;
 
 static char used_context[AST_MAX_CONTEXT];        /*!< name of automatically created context for unloading */
 
@@ -1285,7 +1286,7 @@
 static void sip_poke_all_peers(void);
 static void sip_peer_hold(struct sip_pvt *p, int hold);
 static void mwi_event_cb(void *, struct stasis_subscription *, struct stasis_topic *, struct stasis_message *);
-static void network_change_event_cb(const struct ast_event *, void *);
+static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 static void sip_keepalive_all_peers(void);
 
@@ -5324,6 +5325,9 @@
 	peer->caps = ast_format_cap_destroy(peer->caps);
 
 	ast_rtp_dtls_cfg_free(&peer->dtls_cfg);
+
+	ast_endpoint_shutdown(peer->endpoint);
+	peer->endpoint = NULL;
 }
 
 /*! \brief Update peer data in database (if used) */
@@ -8010,6 +8014,14 @@
 		return NULL;
 	}
 
+	if (i->relatedpeer) {
+		if (ast_endpoint_add_channel(i->relatedpeer->endpoint, tmp)) {
+			ast_channel_unref(tmp);
+			sip_pvt_lock(i);
+			return NULL;
+		}
+	}
+
 	/* If we sent in a callid, bind it to the channel. */
 	if (callid) {
 		ast_channel_callid_set(tmp, callid);
@@ -14771,7 +14783,20 @@
 
 	p->pendinginvite = p->ocseq;	/* Remember that we have a pending NOTIFY in order not to confuse the NOTIFY subsystem */
 
-	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
+	/* Send as XMIT_CRITICAL as we may never receive a 200 OK Response which clears p->pendinginvite.
+	 *
+	 * extensionstate_update() uses p->pendinginvite for queuing control.
+	 * Updates stall if pendinginvite <> 0.
+	 *
+	 * The most appropriate solution is to remove the subscription when the NOTIFY transaction fails.
+	 * The client will re-subscribe after restarting or maxexpiry timeout.
+	 */
+
+	/* RFC6665 4.2.2.  Sending State Information to Subscribers
+	 * If the NOTIFY request fails due to expiration of SIP Timer F (transaction timeout),

[... 2541 lines stripped ...]



More information about the asterisk-commits mailing list