[asterisk-commits] dlee: branch dlee/playback r388050 - in /team/dlee/playback: ./ apps/ build_t...

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


Author: dlee
Date: Wed May  8 16:09:05 2013
New Revision: 388050

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388050
Log:
Merged revisions 387545-388046 from http://svn.asterisk.org/svn/asterisk/trunk

Added:
    team/dlee/playback/include/asterisk/endpoints.h
      - copied unchanged from r388046, trunk/include/asterisk/endpoints.h
    team/dlee/playback/include/asterisk/stasis_endpoints.h
      - copied unchanged from r388046, trunk/include/asterisk/stasis_endpoints.h
    team/dlee/playback/include/asterisk/stasis_test.h
      - copied unchanged from r388046, trunk/include/asterisk/stasis_test.h
    team/dlee/playback/main/endpoints.c
      - copied unchanged from r388046, trunk/main/endpoints.c
    team/dlee/playback/main/stasis_endpoints.c
      - copied unchanged from r388046, trunk/main/stasis_endpoints.c
    team/dlee/playback/res/res_stasis_test.c
      - copied unchanged from r388046, trunk/res/res_stasis_test.c
    team/dlee/playback/res/res_stasis_test.exports.in
      - copied unchanged from r388046, trunk/res/res_stasis_test.exports.in
    team/dlee/playback/tests/test_endpoints.c
      - copied unchanged from r388046, trunk/tests/test_endpoints.c
    team/dlee/playback/tests/test_stasis_endpoints.c
      - copied unchanged from r388046, trunk/tests/test_stasis_endpoints.c
Modified:
    team/dlee/playback/   (props changed)
    team/dlee/playback/apps/app_directory.c
    team/dlee/playback/apps/app_meetme.c
    team/dlee/playback/apps/app_userevent.c
    team/dlee/playback/build_tools/cflags.xml
    team/dlee/playback/channels/chan_dahdi.c
    team/dlee/playback/channels/chan_gulp.c
    team/dlee/playback/channels/chan_iax2.c
    team/dlee/playback/channels/chan_sip.c
    team/dlee/playback/channels/sip/include/sip.h
    team/dlee/playback/funcs/func_global.c
    team/dlee/playback/include/asterisk.h
    team/dlee/playback/include/asterisk/astobj2.h
    team/dlee/playback/include/asterisk/inline_api.h
    team/dlee/playback/include/asterisk/json.h
    team/dlee/playback/include/asterisk/lock.h
    team/dlee/playback/include/asterisk/sorcery.h
    team/dlee/playback/include/asterisk/stasis.h
    team/dlee/playback/include/asterisk/stasis_channels.h
    team/dlee/playback/main/asterisk.c
    team/dlee/playback/main/astobj2.c
    team/dlee/playback/main/channel.c
    team/dlee/playback/main/channel_internal_api.c
    team/dlee/playback/main/enum.c
    team/dlee/playback/main/event.c
    team/dlee/playback/main/manager.c
    team/dlee/playback/main/manager_channels.c
    team/dlee/playback/main/sorcery.c
    team/dlee/playback/main/srv.c
    team/dlee/playback/main/stasis_cache.c
    team/dlee/playback/main/stasis_channels.c
    team/dlee/playback/res/res_config_pgsql.c
    team/dlee/playback/res/res_sip_sdp_rtp.c
    team/dlee/playback/res/res_sorcery_astdb.c
    team/dlee/playback/res/res_stasis_http_endpoints.c
    team/dlee/playback/res/res_stun_monitor.c
    team/dlee/playback/res/stasis_http/resource_endpoints.c
    team/dlee/playback/res/stasis_http/resource_endpoints.h
    team/dlee/playback/res/stasis_http/resource_events.h
    team/dlee/playback/rest-api/api-docs/endpoints.json
    team/dlee/playback/tests/test_sorcery.c
    team/dlee/playback/tests/test_stasis_channels.c
    team/dlee/playback/utils/   (props changed)

Propchange: team/dlee/playback/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/dlee/playback/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed May  8 16:09:05 2013
@@ -1,1 +1,1 @@
-/trunk:1-387538
+/trunk:1-388049

Modified: team/dlee/playback/apps/app_directory.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/apps/app_directory.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/apps/app_directory.c (original)
+++ team/dlee/playback/apps/app_directory.c Wed May  8 16:09:05 2013
@@ -440,7 +440,7 @@
 static struct ast_config *realtime_directory(char *context)
 {
 	struct ast_config *cfg;
-	struct ast_config *rtdata;
+	struct ast_config *rtdata = NULL;
 	struct ast_category *cat;
 	struct ast_variable *var;
 	char *mailbox;
@@ -475,7 +475,7 @@
 			rtdata = ast_load_realtime_multientry("voicemail", "mailbox LIKE", "%", "context", "default", SENTINEL);
 			context = "default";
 		}
-	} else {
+	} else if (!ast_strlen_zero(context)) {
 		rtdata = ast_load_realtime_multientry("voicemail", "mailbox LIKE", "%", "context", context, SENTINEL);
 	}
 

Modified: team/dlee/playback/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/apps/app_meetme.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/apps/app_meetme.c (original)
+++ team/dlee/playback/apps/app_meetme.c Wed May  8 16:09:05 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/dlee/playback/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/apps/app_userevent.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/apps/app_userevent.c (original)
+++ team/dlee/playback/apps/app_userevent.c Wed May  8 16:09:05 2013
@@ -93,7 +93,6 @@
 	}
 
 	blob = ast_json_pack("{s: s, s: s, s: s}",
-			     "type", "userevent",
 			     "eventname", args.eventname,
 			     "body", ast_str_buffer(body));
 	if (!blob) {
@@ -101,7 +100,8 @@
 		return -1;
 	}
 
-	msg = ast_channel_blob_create(chan, blob);
+	msg = ast_channel_blob_create(
+		chan, ast_channel_user_event_type(), blob);
 	if (!msg) {
 		return -1;
 	}

Modified: team/dlee/playback/build_tools/cflags.xml
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/build_tools/cflags.xml?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/build_tools/cflags.xml (original)
+++ team/dlee/playback/build_tools/cflags.xml Wed May  8 16:09:05 2013
@@ -22,6 +22,12 @@
 			<support_level>extended</support_level>
 		</member>
 		<member name="LOW_MEMORY" displayname="Optimize for Low Memory Usage">
+			<support_level>extended</support_level>
+		</member>
+		<member name="DISABLE_INLINE" displayname="Disable the inline API">
+			<!-- Added to work around GCC bug
+			     See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47816
+			  -->
 			<support_level>extended</support_level>
 		</member>
 		<member name="BETTER_BACKTRACES" displayname="Use libbfd (GPL) to generate better inline backtraces">

Modified: team/dlee/playback/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/channels/chan_dahdi.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/channels/chan_dahdi.c (original)
+++ team/dlee/playback/channels/chan_dahdi.c Wed May  8 16:09:05 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/dlee/playback/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/channels/chan_gulp.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/channels/chan_gulp.c (original)
+++ team/dlee/playback/channels/chan_gulp.c Wed May  8 16:09:05 2013
@@ -434,7 +434,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);

Modified: team/dlee/playback/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/channels/chan_iax2.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/channels/chan_iax2.c (original)
+++ team/dlee/playback/channels/chan_iax2.c Wed May  8 16:09:05 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/dlee/playback/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/channels/chan_sip.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/channels/chan_sip.c (original)
+++ team/dlee/playback/channels/chan_sip.c Wed May  8 16:09:05 2013
@@ -295,6 +295,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">
@@ -843,9 +844,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 */
 
@@ -1286,7 +1287,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);
 
@@ -5326,6 +5327,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) */
@@ -8012,6 +8016,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);
@@ -14805,7 +14817,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),
+	 * the notifier SHOULD remove the subscription.
+	 */
+	return send_request(p, &req, XMIT_CRITICAL, p->ocseq);
 }
 
 /*! \brief Notify user of messages waiting in voicemail (RFC3842)
@@ -16707,18 +16732,18 @@
 	}
 }
 
-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, "SIP 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);
 	}
 }
 
@@ -16731,26 +16756,31 @@
 
 }
 
-static void acl_change_event_unsubscribe(void)
+static void acl_change_event_stasis_unsubscribe(void)
 {
 	if (acl_change_sub) {
 		acl_change_sub = stasis_unsubscribe(acl_change_sub);
 	}
 }
 
-static int network_change_event_sched_cb(const void *data)
-{
-	network_change_event_sched_id = -1;
+static int network_change_sched_cb(const void *data)
+{
+	network_change_sched_id = -1;
 	sip_send_all_registers();
 	sip_send_all_mwi_subscriptions();
 	return 0;
 }
 
-static void network_change_event_cb(const struct ast_event *event, void *userdata)
-{
-	ast_debug(1, "SIP, got a network change event, renewing all SIP registrations.\n");
-	if (network_change_event_sched_id == -1) {
-		network_change_event_sched_id = ast_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, "SIP, got a network change message, renewing all SIP registrations.\n");
+	if (network_change_sched_id == -1) {
+		network_change_sched_id = ast_sched_add(sched, 1000, network_change_sched_cb, NULL);
 	}
 }
 
@@ -30750,6 +30780,9 @@
 			firstpass = 0;
 	} else {
 		if (!(peer = ao2_t_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct"))) {
+			return NULL;
+		}
+		if (!(peer->endpoint = ast_endpoint_create("SIP", name))) {
 			return NULL;
 		}
 		if (!(peer->caps = ast_format_cap_alloc_nolock())) {
@@ -32329,9 +32362,9 @@
 	}
 
 	if (subscribe_network_change) {
-		network_change_event_subscribe();
+		network_change_stasis_subscribe();
 	} else {
-		network_change_event_unsubscribe();
+		network_change_stasis_unsubscribe();
 	}
 
 	if (global_t1 < global_t1min) {
@@ -34819,7 +34852,7 @@
 
 
 	sip_register_tests();
-	network_change_event_subscribe();
+	network_change_stasis_subscribe();
 
 	ast_websocket_add_protocol("sip", sip_websocket_callback);
 
@@ -34839,8 +34872,8 @@
 
 	ast_websocket_remove_protocol("sip", sip_websocket_callback);
 
-	network_change_event_unsubscribe();
-	acl_change_event_unsubscribe();
+	network_change_stasis_unsubscribe();
+	acl_change_event_stasis_unsubscribe();
 
 	ast_sched_dump(sched);
 

Modified: team/dlee/playback/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/channels/sip/include/sip.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/channels/sip/include/sip.h (original)
+++ team/dlee/playback/channels/sip/include/sip.h Wed May  8 16:09:05 2013
@@ -1377,6 +1377,8 @@
 	unsigned int disallowed_methods;
 	struct ast_cc_config_params *cc_params;
 
+	struct ast_endpoint *endpoint;
+
 	struct ast_rtp_dtls_cfg dtls_cfg;
 };
 

Modified: team/dlee/playback/funcs/func_global.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/funcs/func_global.c?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/funcs/func_global.c (original)
+++ team/dlee/playback/funcs/func_global.c Wed May  8 16:09:05 2013
@@ -39,7 +39,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/channel.h"
 #include "asterisk/app.h"
-#include "asterisk/manager.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<function name="GLOBAL" language="en_US">
@@ -83,7 +83,25 @@
 			using it in a set of calculations (or you might be surprised by the result).</para>
 		</description>
 	</function>
-
+	<managerEvent language="en_US" name="VarSet">
+		<managerEventInstance class="EVENT_FLAG_DIALPLAN">
+			<synopsis>Raised when a variable is shared between channels.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Variable">
+					<para>The SHARED variable being set.</para>
+					<note><para>The variable name will always be enclosed with
+					<literal>SHARED()</literal></para></note>
+				</parameter>
+				<parameter name="Value">
+					<para>The new value of the variable.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="function">SHARED</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
  ***/
 
 static void shared_variable_free(void *data);
@@ -197,6 +215,8 @@
 		AST_APP_ARG(chan);
 	);
 	struct ast_channel *c_ref = NULL;
+	int len;
+	RAII_VAR(char *, shared_buffer, NULL, ast_free);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "SHARED() requires an argument: SHARED(<var>[,<chan>])\n");
@@ -213,6 +233,15 @@
 			return -1;
 		}
 		chan = c_ref;
+	}
+
+	len = 9 + strlen(args.var); /* SHARED() + var */
+	shared_buffer = ast_malloc(len);
+	if (!shared_buffer) {
+		if (c_ref) {
+			ast_channel_unref(c_ref);
+		}
+		return -1;
 	}
 
 	ast_channel_lock(chan);
@@ -255,13 +284,9 @@
 
 	var = ast_var_assign(args.var, S_OR(value, ""));
 	AST_LIST_INSERT_HEAD(varshead, var, entries);
-	manager_event(EVENT_FLAG_DIALPLAN, "VarSet", 
-		"Channel: %s\r\n"
-		"Variable: SHARED(%s)\r\n"
-		"Value: %s\r\n"
-		"Uniqueid: %s\r\n", 
-		chan ? ast_channel_name(chan) : "none", args.var, value, 
-		chan ? ast_channel_uniqueid(chan) : "none");
+
+	sprintf(shared_buffer, "SHARED(%s)", args.var);
+	ast_channel_publish_varset(chan, shared_buffer, value);
 
 	ast_channel_unlock(chan);
 

Modified: team/dlee/playback/include/asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk.h (original)
+++ team/dlee/playback/include/asterisk.h Wed May  8 16:09:05 2013
@@ -200,6 +200,27 @@
 #define ast_mark(a, b) do { } while (0)
 #endif /* LOW_MEMORY */
 
+/*!
+ * \since 12
+ * \brief A \ref stasis topic which publishes messages regarding system changes
+ *
+ * \retval \ref stasis_topic for system level changes
+ * \retval NULL on error
+ */
+struct stasis_topic *ast_system_topic(void);
+
+/*!
+ * \since 12
+ * \brief A \ref stasis_message_type for network changes
+ *
+ * \retval NULL on error
+ * \retval \ref stasis_message_type for network changes
+ *
+ * \note Messages of this type should always be issued on and expected from
+ *       the \ref ast_system_topic \ref stasis topic
+ */
+struct stasis_message_type *ast_network_change_type(void);
+
 /*! \brief
  * Definition of various structures that many asterisk files need,
  * but only because they need to know that the type exists.

Modified: team/dlee/playback/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/astobj2.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk/astobj2.h (original)
+++ team/dlee/playback/include/asterisk/astobj2.h Wed May  8 16:09:05 2013
@@ -383,12 +383,19 @@
 
 
 
-/*! \brief
- * Typedef for an object destructor. This is called just before freeing
- * the memory for the object. It is passed a pointer to the user-defined
- * data of the object.
- */
-typedef void (*ao2_destructor_fn)(void *);
+/*!
+ * \brief Typedef for an object destructor.
+ *
+ * \param vdoomed Object to destroy.
+ *
+ * \details
+ * This is called just before freeing the memory for the object.
+ * It is passed a pointer to the user-defined data of the
+ * object.
+ *
+ * \return Nothing
+ */
+typedef void (*ao2_destructor_fn)(void *vdoomed);
 
 /*! \brief Options available when allocating an ao2 object. */
 enum ao2_alloc_opts {
@@ -1883,4 +1890,55 @@
 #define ao2_cleanup(obj) __ao2_cleanup(obj)
 #endif
 void ao2_iterator_cleanup(struct ao2_iterator *iter);
+
+
+/* XXX TODO BUGBUG and all the other things...
+ * These functions should eventually be moved elsewhere, but the utils folder
+ * won't compile with them in strings.h
+ */
+
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+#define ast_str_container_alloc(buckets) ast_str_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, buckets)
+
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param opts Options to be provided to the container
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+struct ao2_container *ast_str_container_alloc_options(enum ao2_container_opts opts, int buckets);
+
+/*!
+ * \since 12
+ * \brief Adds a string to a string container allocated by ast_str_container_alloc
+ *
+ * \param str_container The container to which to add a string
+ * \param add The string to add to the container
+ *
+ * \retval zero on success
+ * \retval non-zero if the operation failed
+ */
+int ast_str_container_add(struct ao2_container *str_container, const char *add);
+
+/*!
+ * \since 12
+ * \brief Removes a string from a string container allocated by ast_str_container_alloc
+ *
+ * \param str_container The container from which to remove a string
+ * \param remove The string to remove from the container
+ */
+void ast_str_container_remove(struct ao2_container *str_container, const char *remove);
+
 #endif /* _ASTERISK_ASTOBJ2_H */

Modified: team/dlee/playback/include/asterisk/inline_api.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/inline_api.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk/inline_api.h (original)
+++ team/dlee/playback/include/asterisk/inline_api.h Wed May  8 16:09:05 2013
@@ -43,7 +43,7 @@
   including the header file
  */
 
-#if !defined(LOW_MEMORY)
+#if !defined(LOW_MEMORY) && !defined(DISABLE_INLINE)
 
 #if !defined(AST_API_MODULE)
 #define AST_INLINE_API(hdr, body) hdr; extern inline hdr body

Modified: team/dlee/playback/include/asterisk/json.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/json.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk/json.h (original)
+++ team/dlee/playback/include/asterisk/json.h Wed May  8 16:09:05 2013
@@ -24,9 +24,54 @@
  * \brief Asterisk JSON abstraction layer.
  * \since 12.0.0
  *
- * This is a very thin wrapper around the Jansson API. For more details on it, see its
- * docs at http://www.digip.org/jansson/doc/2.4/apiref.html.
-
+ * This is a very thin wrapper around the Jansson API. For more details on it,
+ * see its docs at http://www.digip.org/jansson/doc/2.4/apiref.html.
+ *
+ * Rather than provide the multiple ways of doing things that the Jansson API
+ * does, the Asterisk wrapper is always reference-stealing, and always NULL
+ * safe.
+ *
+ * And by always, I mean that the reference is stolen even if the function
+ * fails. This avoids lots of conditional logic, and also avoids having to track
+ * zillions of local variables when building complex JSON objects. You can
+ * instead chain \c ast_json_* calls together safely and only worry about
+ * cleaning up the root object.
+ *
+ * In the cases where you have a need to introduce intermediate objects, just
+ * wrap them with json_ref() when passing them to other \c ast_json_*()
+ * functions.
+ *
+ * \code
+ *	// Example of how to use the Asterisk JSON API
+ *	static struct ast_json *foo(void) {
+ *		RAII_VAR(struct ast_json *, array, NULL, ast_json_unref);
+ *		RAII_VAR(struct ast_json *, obj, NULL, ast_json_unref);
+ *		int i, res;
+ *
+ *		array = ast_json_array_create();
+ *		if (!array) { return NULL; }
+ *
+ *		for (i = 0; i < 10; ++i) {
+ *			// NULL safety and object stealing means calls can
+ *			// be chained together directly.
+ *			res = ast_json_array_append(array,
+ *				ast_json_integer_create(i));
+ *			if (res != 0) { return NULL; }
+ *		}
+ *
+ *		obj = ast_json_object_create();
+ *		if (!obj) { return NULL; }
+ *
+ *		// If you already have an object reference, ast_json_ref()
+ *		// can be used inline to bump the ref before passing it along
+ *		// to a ref-stealing call
+ *		res = ast_json_object_set(obj, "foo", ast_json_ref(array));
+ *		if (!res) { return NULL; }
+ *
+ *		return obj;
+ *	}
+ * \endcode
+ *
  * \author David M. Lee, II <dlee at digium.com>
  */
 

Modified: team/dlee/playback/include/asterisk/lock.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/lock.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk/lock.h (original)
+++ team/dlee/playback/include/asterisk/lock.h Wed May  8 16:09:05 2013
@@ -569,7 +569,7 @@
  * the lock. When the lock goes out of scope, it will automatically
  * be unlocked.
  *
- * \example
+ * \code
  * int some_function(struct ast_channel *chan)
  * {
  *     SCOPED_LOCK(lock, chan, ast_channel_lock, ast_channel_unlock);
@@ -580,6 +580,7 @@
  *
  *     return -1;
  * }
+ * \endcode
  *
  * In the above example, neither return path requires explicit unlocking
  * of the channel.

Modified: team/dlee/playback/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/sorcery.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk/sorcery.h (original)
+++ team/dlee/playback/include/asterisk/sorcery.h Wed May  8 16:09:05 2013
@@ -232,6 +232,21 @@
 	void (*close)(void *data);
 };
 
+/*! \brief Interface for a sorcery object type observer */
+struct ast_sorcery_observer {
+	/*! \brief Callback for when an object is created */
+	void (*created)(const void *object);
+
+	/*! \brief Callback for when an object is updated */
+	void (*updated)(const void *object);
+
+	/*! \brief Callback for when an object is deleted */
+	void (*deleted)(const void *object);
+
+	/*! \brief Callback for when an object type is loaded/reloaded */
+	void (*loaded)(const char *object_type);
+};
+
 /*! \brief Structure which contains details about a sorcery object */
 struct ast_sorcery_object_details {
 	/*! \brief Unique identifier of this object */
@@ -472,6 +487,19 @@
 struct ast_variable *ast_sorcery_objectset_create(const struct ast_sorcery *sorcery, const void *object);
 
 /*!
+ * \brief Create an object set in JSON format for an object
+ *
+ * \param sorcery Pointer to a sorcery structure
+ * \param object Pointer to a sorcery object
+ *
+ * \retval non-NULL success
+ * \retval NULL if error occurred
+ *
+ * \note The returned ast_json object must be unreferenced using ast_json_unref
+ */
+struct ast_json *ast_sorcery_objectset_json_create(const struct ast_sorcery *sorcery, const void *object);
+
+/*!
  * \brief Apply an object set (KVP list) to an object
  *
  * \param sorcery Pointer to a sorcery structure
@@ -541,6 +569,30 @@
 int ast_sorcery_diff(const struct ast_sorcery *sorcery, const void *original, const void *modified, struct ast_variable **changes);
 
 /*!
+ * \brief Add an observer to a specific object type
+ *
+ * \param sorcery Pointer to a sorcery structure
+ * \param type Type of object that should be observed
+ * \param callbacks Implementation of the observer interface
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks);
+
+/*!
+ * \brief Remove an observer from a specific object type
+ *
+ * \param sorcery Pointer to a sorcery structure
+ * \param type Type of object that should no longer be observed
+ * \param callbacks Implementation of the observer interface
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+void ast_sorcery_observer_remove(const struct ast_sorcery *sorcery, const char *type, struct ast_sorcery_observer *callbacks);
+
+/*!
  * \brief Create and potentially persist an object using an available wizard
  *
  * \param sorcery Pointer to a sorcery structure

Modified: team/dlee/playback/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/stasis.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk/stasis.h (original)
+++ team/dlee/playback/include/asterisk/stasis.h Wed May  8 16:09:05 2013
@@ -431,6 +431,22 @@
 };
 
 /*!
+ * \brief Cache clear message.
+ */
+struct stasis_cache_clear {
+	/*! Type of object being cleared from the cache */
+	struct stasis_message_type *type;
+	/*! Id of the object being cleared from the cache */
+	char id[];
+};
+
+/*!
+ * \brief Message type for \ref stasis_cache_clear.
+ * \since 12
+ */
+struct stasis_message_type *stasis_cache_clear_type(void);
+
+/*!
  * \brief A message which instructs the caching topic to remove an entry from its cache.
  * \param type Message type.
  * \param id Unique id of the snapshot to clear.
@@ -527,6 +543,43 @@
 /*! @{ */
 
 /*!
+ * \brief Boiler-plate removing macro for defining message types.
+ *
+ * \param name Name of message type.
+ * \since 12
+ */
+#define STASIS_MESSAGE_TYPE_DEFN(name)				\
+	static struct stasis_message_type *__ ## name;	\
+	struct stasis_message_type *name(void) {	\
+		ast_assert(__ ## name != NULL);		\
+		return __ ## name;			\
+	}
+
+/*!
+ * \brief Boiler-plate removing macro for initializing message types.
+ *
+ * \param name Name of message type.
+ * \return 0 if initialization is successful.
+ * \return Non-zero on failure.
+ * \since 12
+ */
+#define STASIS_MESSAGE_TYPE_INIT(name)				\
+	({						\
+	__ ## name = stasis_message_type_create(#name);	\
+	__ ## name ? 0 : -1;				\
+	})
+
+#define STASIS_MESSAGE_TYPE_CLEANUP(name)		\
+	({					\
+		ao2_cleanup(__ ## name);	\
+		__ ## name = NULL;		\
+	})
+
+/*! @} */
+
+/*! @{ */
+
+/*!
  * \brief Initialize the Stasis subsystem
  * \return 0 on success.
  * \return Non-zero on error.

Modified: team/dlee/playback/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/stasis_channels.h?view=diff&rev=388050&r1=388049&r2=388050
==============================================================================
--- team/dlee/playback/include/asterisk/stasis_channels.h (original)
+++ team/dlee/playback/include/asterisk/stasis_channels.h Wed May  8 16:09:05 2013
@@ -71,8 +71,7 @@
  * \since 12
  * \brief Blob of data associated with a channel.
  *
- * The \c blob is actually a JSON object of structured data. It has a "type" field
- * which contains the type string describing this blob.
+ * This blob is actually shared amongst several \ref stasis_message_type's.
  */
 struct ast_channel_blob {
 	/*! Channel blob is associated with (or NULL for global/all channels) */
@@ -113,14 +112,6 @@
 
 /*!
  * \since 12
- * \brief Message type for \ref ast_channel_blob messages.
- *
- * \retval Message type for \ref ast_channel_blob messages.
- */
-struct stasis_message_type *ast_channel_blob_type(void);
-
-/*!
- * \since 12
  * \brief Generate a snapshot of the channel state. This is an ao2 object, so
  * ao2_cleanup() to deallocate.
  *
@@ -129,44 +120,35 @@
  * \retval pointer on success (must be ast_freed)
  * \retval NULL on error
  */
-struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan);
+struct ast_channel_snapshot *ast_channel_snapshot_create(
+	struct ast_channel *chan);
 
 /*!
  * \since 12
  * \brief Creates a \ref ast_channel_blob message.
  *
- * The \a blob JSON object requires a \c "type" field describing the blob. It
- * should also be treated as immutable and not modified after it is put into the
- * message.
- *
- * \param chan Channel blob is associated with, or NULL for global/all channels.
- * \param blob JSON object representing the data.
+ * The given \a blob should be treated as immutable and not modified after it is
+ * put into the message.
+ *
+ * \param chan Channel blob is associated with, or \c NULL for global/all channels.
+ * \param type Message type for this blob.
+ * \param blob JSON object representing the data, or \c NULL for no data. If
+ *             \c NULL, ast_json_null() is put into the object.
+ *
  * \return \ref ast_channel_blob message.
  * \return \c NULL on error
  */
 struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
-					       struct ast_json *blob);
-
-/*!
- * \since 12
- * \brief Extracts the type field from a \ref ast_channel_blob.
- * Returned \c char* is still owned by \a obj
- * \param obj Channel blob object.
- * \return Type field value from the blob.
- * \return \c NULL on error.
- */
-const char *ast_channel_blob_json_type(struct ast_channel_blob *obj);
-
-/*!
- * \since 12
- * \brief Create a \ref ast_multi_channel_blob suitable for a \ref stasis_message
- *
- * \note Similar to a \ref ast_channel_blob, the \ref ast_multi_channel_blob requires
- * a \a blob JSON object containing a \c "type" field describing the blob. It
- * should also be treated as immutable and not modified after it is put into the
- * message.
- *

[... 2487 lines stripped ...]



More information about the asterisk-commits mailing list