[asterisk-commits] dlee: branch dlee/stasis-http r385119 - in /team/dlee/stasis-http: ./ apps/ b...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 9 13:54:02 CDT 2013
Author: dlee
Date: Tue Apr 9 13:53:58 2013
New Revision: 385119
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385119
Log:
Merged revisions 384910-385088 from http://svn.asterisk.org/svn/asterisk/trunk
Added:
team/dlee/stasis-http/include/asterisk/stasis_channels.h
- copied unchanged from r385088, trunk/include/asterisk/stasis_channels.h
team/dlee/stasis-http/main/stasis_channels.c
- copied unchanged from r385088, trunk/main/stasis_channels.c
team/dlee/stasis-http/tests/test_stasis_channels.c
- copied unchanged from r385088, trunk/tests/test_stasis_channels.c
Modified:
team/dlee/stasis-http/ (props changed)
team/dlee/stasis-http/CHANGES
team/dlee/stasis-http/Makefile
team/dlee/stasis-http/apps/app_dial.c
team/dlee/stasis-http/apps/app_stasis.c
team/dlee/stasis-http/apps/app_userevent.c
team/dlee/stasis-http/apps/stasis_json.c
team/dlee/stasis-http/build_tools/make_buildopts_h
team/dlee/stasis-http/build_tools/make_linker_version_script
team/dlee/stasis-http/build_tools/make_version
team/dlee/stasis-http/build_tools/mkpkgconfig
team/dlee/stasis-http/configs/extconfig.conf.sample
team/dlee/stasis-http/include/asterisk/app_stasis.h
team/dlee/stasis-http/include/asterisk/channel.h
team/dlee/stasis-http/main/channel.c
team/dlee/stasis-http/main/channel_internal_api.c
team/dlee/stasis-http/main/dial.c
team/dlee/stasis-http/main/features.c
team/dlee/stasis-http/main/manager_channels.c
team/dlee/stasis-http/main/pbx.c
team/dlee/stasis-http/pbx/pbx_realtime.c
team/dlee/stasis-http/res/res_http_websocket.c
team/dlee/stasis-http/res/res_stasis_websocket.c
team/dlee/stasis-http/res/stasis_http/resource_channels.c
Propchange: team/dlee/stasis-http/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Propchange: team/dlee/stasis-http/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Apr 9 13:53:58 2013
@@ -1,1 +1,1 @@
-/trunk:1-384879
+/trunk:1-385115
Modified: team/dlee/stasis-http/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/CHANGES?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/CHANGES (original)
+++ team/dlee/stasis-http/CHANGES Tue Apr 9 13:53:58 2013
@@ -53,6 +53,12 @@
* The deprecated use of | (pipe) as a separator in the channelvars setting in
manager.conf has been removed.
+ * Channel Variables conveyed with a channel no longer contain the name of the
+ channel as part of the key field, i.e., ChanVariable(SIP/foo): bar=baz is now
+ ChanVariable: bar=baz. When multiple channels are present in a single AMI
+ event, the various ChanVariable fields will contain a suffix that specifies
+ which channel they correspond to.
+
Channel Drivers
------------------
@@ -82,6 +88,10 @@
* PARKINGSLOT and PARKEDLOT channel variables will now be set for a parked
channel even when comebactoorigin=yes
+
+ * You can now have the settings for a channel updated using the FEATURE()
+ and FEATUREMAP() functions inherited to child channels by setting
+ FEATURE(inherit)=yes.
Logging
-------------------
Modified: team/dlee/stasis-http/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/Makefile?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/Makefile (original)
+++ team/dlee/stasis-http/Makefile Tue Apr 9 13:53:58 2013
@@ -81,6 +81,8 @@
# should go directly to ASTLDFLAGS
#--- paths to various commands
+# The makeopts include below tries to set these if they're found during
+# configure.
export CC
export CXX
export AR
@@ -221,10 +223,13 @@
_ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
endif
-ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
-
-ifneq ($(wildcard .version),)
- ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
+ifneq ($(GREP),)
+ ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
+endif
+ifneq ($(AWK),)
+ ifneq ($(wildcard .version),)
+ ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
+ endif
endif
ifneq ($(wildcard .svn),)
@@ -453,7 +458,11 @@
$(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
done
-doc/core-en_US.xml: makeopts cleantest $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
+ifneq ($(GREP),)
+ XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
+endif
+
+doc/core-en_US.xml: makeopts cleantest $(XML_core_en_US)
@printf "Building Documentation For: "
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
@echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
@@ -467,7 +476,11 @@
@echo
@echo "</docs>" >> $@
-doc/full-en_US.xml: makeopts cleantest $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
+ifneq ($(GREP),)
+ XMX_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
+endif
+
+doc/full-en_US.xml: makeopts cleantest $(XML_full_en_US)
ifeq ($(PYTHON),:)
@echo "--------------------------------------------------------------------------"
@echo "--- Please install python to build full documentation ---"
Modified: team/dlee/stasis-http/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/apps/app_dial.c?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/apps/app_dial.c (original)
+++ team/dlee/stasis-http/apps/app_dial.c Tue Apr 9 13:53:58 2013
@@ -67,6 +67,7 @@
#include "asterisk/ccss.h"
#include "asterisk/indications.h"
#include "asterisk/framehook.h"
+#include "asterisk/stasis_channels.h"
/*** DOCUMENTATION
<application name="Dial" language="en_US">
@@ -818,63 +819,6 @@
return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : "";
}
-static void senddialevent(struct ast_channel *src, struct ast_channel *dst, const char *dialstring)
-{
- struct ast_channel *chans[] = { src, dst };
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a dial action has started.</synopsis>
- <syntax>
- <parameter name="SubEvent">
- <para>A sub event type, specifying whether the dial action has begun or ended.</para>
- <enumlist>
- <enum name="Begin"/>
- <enum name="End"/>
- </enumlist>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- ast_manager_event_multichan(EVENT_FLAG_CALL, "Dial", 2, chans,
- "SubEvent: Begin\r\n"
- "Channel: %s\r\n"
- "Destination: %s\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "ConnectedLineNum: %s\r\n"
- "ConnectedLineName: %s\r\n"
- "UniqueID: %s\r\n"
- "DestUniqueID: %s\r\n"
- "Dialstring: %s\r\n",
- ast_channel_name(src), ast_channel_name(dst),
- S_COR(ast_channel_caller(src)->id.number.valid, ast_channel_caller(src)->id.number.str, "<unknown>"),
- S_COR(ast_channel_caller(src)->id.name.valid, ast_channel_caller(src)->id.name.str, "<unknown>"),
- S_COR(ast_channel_connected(src)->id.number.valid, ast_channel_connected(src)->id.number.str, "<unknown>"),
- S_COR(ast_channel_connected(src)->id.name.valid, ast_channel_connected(src)->id.name.str, "<unknown>"),
- ast_channel_uniqueid(src), ast_channel_uniqueid(dst),
- dialstring ? dialstring : "");
-}
-
-static void senddialendevent(struct ast_channel *src, const char *dialstatus)
-{
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a dial action has ended.</synopsis>
- <syntax>
- <parameter name="DialStatus">
- <para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- ast_manager_event(src, EVENT_FLAG_CALL, "Dial",
- "SubEvent: End\r\n"
- "Channel: %s\r\n"
- "UniqueID: %s\r\n"
- "DialStatus: %s\r\n",
- ast_channel_name(src), ast_channel_uniqueid(src), dialstatus);
-}
-
/*!
* helper function for wait_for_answer()
*
@@ -1069,7 +1013,7 @@
num->nochan++;
} else {
ast_channel_lock_both(c, in);
- senddialevent(in, c, stuff);
+ ast_channel_publish_dial(c, in, stuff, NULL);
ast_channel_unlock(in);
ast_channel_unlock(c);
/* Hangup the original channel now, in case we needed it */
@@ -1089,6 +1033,33 @@
char privintro[1024];
char status[256];
};
+
+static const char *hangup_cause_to_dial_status(int hangup_cause)
+{
+ switch(hangup_cause) {
+ case AST_CAUSE_BUSY:
+ return "BUSY";
+ case AST_CAUSE_CONGESTION:
+ return "CONGESTION";
+ case AST_CAUSE_NO_ROUTE_DESTINATION:
+ case AST_CAUSE_UNREGISTERED:
+ return "CHANUNAVAIL";
+ case AST_CAUSE_NO_ANSWER:
+ default:
+ return "NOANSWER";
+ }
+}
+
+static void publish_dial_end_event(struct ast_channel *in, struct dial_head *out_chans, struct ast_channel *exception, const char *status)
+{
+ struct chanlist *outgoing;
+ AST_LIST_TRAVERSE(out_chans, outgoing, node) {
+ if (!outgoing->chan || outgoing->chan == exception) {
+ continue;
+ }
+ ast_channel_publish_dial(in, outgoing->chan, NULL, status);
+ }
+}
static struct ast_channel *wait_for_answer(struct ast_channel *in,
struct dial_head *out_chans, int *to, struct ast_flags64 *peerflags,
@@ -1133,6 +1104,7 @@
*to = -1;
strcpy(pa->status, "CONGESTION");
ast_cdr_failed(ast_channel_cdr(in));
+ ast_channel_publish_dial(in, outgoing->chan, NULL, pa->status);
return NULL;
}
}
@@ -1293,6 +1265,7 @@
#ifdef HAVE_EPOLL
ast_poll_channel_del(in, c);
#endif
+ ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
ast_hangup(c);
c = o->chan = NULL;
ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1333,6 +1306,8 @@
}
}
peer = c;
+ ast_channel_publish_dial(in, peer, NULL, "ANSWER");
+ publish_dial_end_event(in, out_chans, peer, "CANCEL");
if (ast_channel_cdr(peer)) {
ast_channel_cdr(peer)->answer = ast_tvnow();
ast_channel_cdr(peer)->disposition = AST_CDR_ANSWERED;
@@ -1346,9 +1321,10 @@
DIAL_NOFORWARDHTML);
ast_channel_dialcontext_set(c, "");
ast_channel_exten_set(c, "");
- if (CAN_EARLY_BRIDGE(peerflags, in, peer))
+ if (CAN_EARLY_BRIDGE(peerflags, in, peer)) {
/* Setup early bridge if appropriate */
ast_channel_early_bridge(in, peer);
+ }
}
/* If call has been answered, then the eventual hangup is likely to be normal hangup */
ast_channel_hangupcause_set(in, AST_CAUSE_NORMAL_CLEARING);
@@ -1357,6 +1333,7 @@
case AST_CONTROL_BUSY:
ast_verb(3, "%s is busy\n", ast_channel_name(c));
ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
+ ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
ast_hangup(c);
c = o->chan = NULL;
ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1365,6 +1342,7 @@
case AST_CONTROL_CONGESTION:
ast_verb(3, "%s is circuit-busy\n", ast_channel_name(c));
ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
+ ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
ast_hangup(c);
c = o->chan = NULL;
ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1572,6 +1550,7 @@
*to = -1;
strcpy(pa->status, "CANCEL");
ast_cdr_noanswer(ast_channel_cdr(in));
+ publish_dial_end_event(in, out_chans, NULL, pa->status);
if (f) {
if (f->data.uint32) {
ast_channel_hangupcause_set(in, f->data.uint32);
@@ -1596,6 +1575,7 @@
ast_cdr_noanswer(ast_channel_cdr(in));
*result = f->subclass.integer;
strcpy(pa->status, "CANCEL");
+ publish_dial_end_event(in, out_chans, NULL, pa->status);
ast_frfree(f);
ast_channel_unlock(in);
if (is_cc_recall) {
@@ -1612,6 +1592,7 @@
*to = 0;
strcpy(pa->status, "CANCEL");
ast_cdr_noanswer(ast_channel_cdr(in));
+ publish_dial_end_event(in, out_chans, NULL, pa->status);
ast_frfree(f);
if (is_cc_recall) {
ast_cc_completed(in, "CC completed, but the caller hung up with DTMF");
@@ -1707,6 +1688,7 @@
if (!*to) {
ast_verb(3, "Nobody picked up in %d ms\n", orig);
+ publish_dial_end_event(in, out_chans, NULL, "NOANSWER");
}
if (!*to || ast_check_hangup(in)) {
ast_cdr_noanswer(ast_channel_cdr(in));
@@ -2621,7 +2603,7 @@
continue;
}
- senddialevent(chan, tmp->chan, tmp->number);
+ ast_channel_publish_dial(chan, tmp->chan, tmp->number, NULL);
ast_channel_unlock(chan);
ast_verb(3, "Called %s\n", tmp->interface);
@@ -3098,7 +3080,6 @@
ast_channel_early_bridge(chan, NULL);
hanguptree(&out_chans, NULL, ast_channel_hangupcause(chan)==AST_CAUSE_ANSWERED_ELSEWHERE || ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE) ? 1 : 0 ); /* forward 'answered elsewhere' if we received it */
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
- senddialendevent(chan, pa.status);
ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_INCOMPLETE)) {
Modified: team/dlee/stasis-http/apps/app_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/apps/app_stasis.c?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/apps/app_stasis.c (original)
+++ team/dlee/stasis-http/apps/app_stasis.c Tue Apr 9 13:53:58 2013
@@ -39,6 +39,7 @@
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/strings.h"
+#include "asterisk/stasis_channels.h"
/*** DOCUMENTATION
<application name="Stasis" language="en_US">
Modified: team/dlee/stasis-http/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/apps/app_userevent.c?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/apps/app_userevent.c (original)
+++ team/dlee/stasis-http/apps/app_userevent.c Tue Apr 9 13:53:58 2013
@@ -34,6 +34,7 @@
#include "asterisk/manager.h"
#include "asterisk/app.h"
#include "asterisk/json.h"
+#include "asterisk/stasis_channels.h"
/*** DOCUMENTATION
<application name="UserEvent" language="en_US">
Modified: team/dlee/stasis-http/apps/stasis_json.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/apps/stasis_json.c?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/apps/stasis_json.c (original)
+++ team/dlee/stasis-http/apps/stasis_json.c Tue Apr 9 13:53:58 2013
@@ -28,6 +28,7 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app_stasis.h"
+#include "asterisk/stasis_channels.h"
struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot)
{
Modified: team/dlee/stasis-http/build_tools/make_buildopts_h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/build_tools/make_buildopts_h?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/build_tools/make_buildopts_h (original)
+++ team/dlee/stasis-http/build_tools/make_buildopts_h Tue Apr 9 13:53:58 2013
@@ -1,4 +1,7 @@
#!/bin/sh
+
+GREP=${GREP:-grep}
+MD5=${MD5:-md5sum}
cat << END
/*
Modified: team/dlee/stasis-http/build_tools/make_linker_version_script
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/build_tools/make_linker_version_script?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/build_tools/make_linker_version_script (original)
+++ team/dlee/stasis-http/build_tools/make_linker_version_script Tue Apr 9 13:53:58 2013
@@ -1,5 +1,6 @@
#!/bin/sh
+
+AWK=${AWK:-awk}
test -f ${1}.exports.in && ${AWK} "{sub(\"LINKER_SYMBOL_PREFIX\", \"${2}\"); print;}" ${1}.exports.in > ${1}.exports && exit 0
test -f ${1}.exports.in || rm -f ${1}.exports && cp ${3}/default.exports ${1}.exports && exit 0
-
Modified: team/dlee/stasis-http/build_tools/make_version
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/build_tools/make_version?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/build_tools/make_version (original)
+++ team/dlee/stasis-http/build_tools/make_version Tue Apr 9 13:53:58 2013
@@ -1,4 +1,8 @@
#!/bin/sh
+
+AWK=${AWK:-awk}
+GIT=${GIT:-git}
+GREP=${GREP:-grep}
if [ -f ${1}/.version ]; then
cat ${1}/.version
@@ -92,7 +96,7 @@
# If the first log commit messages indicates that this is checked into
# subversion, we'll just use the SVN- form of the revision.
MODIFIED=""
- SVN_REV=`${GIT} log --pretty=full -1 | grep -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
+ SVN_REV=`${GIT} log --pretty=full -1 | ${GREP} -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
if [ -z "$SVN_REV" ]; then
VERSION=GIT-`${GIT} describe --long --always --tags --dirty=M 2> /dev/null`
if [ $? -ne 0 ]; then
@@ -105,7 +109,7 @@
fi
echo ${VERSION}
else
- PARTS=`LANG=C ${GIT} log --pretty=full | grep -F "git-svn-id:" | head -1 | awk '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`
+ PARTS=`LANG=C ${GIT} log --pretty=full | ${GREP} -F "git-svn-id:" | head -1 | ${AWK} '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`
BRANCH=0
TEAM=0
TAG=0
Modified: team/dlee/stasis-http/build_tools/mkpkgconfig
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/build_tools/mkpkgconfig?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/build_tools/mkpkgconfig (original)
+++ team/dlee/stasis-http/build_tools/mkpkgconfig Tue Apr 9 13:53:58 2013
@@ -1,5 +1,6 @@
#!/bin/sh
PPATH="$1"
+GREP=${GREP:-grep}
## Make sure we were called from Makefile
if [ "x$ASTERISKVERSIONNUM" = "x" ]; then
Modified: team/dlee/stasis-http/configs/extconfig.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/configs/extconfig.conf.sample?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/configs/extconfig.conf.sample (original)
+++ team/dlee/stasis-http/configs/extconfig.conf.sample Tue Apr 9 13:53:58 2013
@@ -58,13 +58,17 @@
; start at 1 and be sequential (i.e. if you have only priorities 1, 2,
; and 4, then 4 will be ignored, because there is no 3).
;
+;
+; Possible driver backends:
+;
; "odbc" is shown in the examples below, but is not the only valid realtime
-; engine. There is:
+; engine. Here are several of the possible options:
; odbc ... res_config_odbc
; sqlite ... res_config_sqlite
; pgsql ... res_config_pgsql
; curl ... res_config_curl
; ldap ... res_config_ldap
+; mysql ... res_config_mysql (available via add-ons in menuselect)
;
; Note: The res_config_pgsql and res_config_sqlite backends configure the
; database used in their respective configuration files and ignore the
Modified: team/dlee/stasis-http/include/asterisk/app_stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/include/asterisk/app_stasis.h?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/include/asterisk/app_stasis.h (original)
+++ team/dlee/stasis-http/include/asterisk/app_stasis.h Tue Apr 9 13:53:58 2013
@@ -48,6 +48,8 @@
#include "asterisk/channel.h"
#include "asterisk/json.h"
+
+struct ast_channel_snapshot;
/*! @{ */
Modified: team/dlee/stasis-http/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/include/asterisk/channel.h?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/include/asterisk/channel.h (original)
+++ team/dlee/stasis-http/include/asterisk/channel.h Tue Apr 9 13:53:58 2013
@@ -365,7 +365,7 @@
* PSTN gateway).
*
* \todo Implement settings for transliteration between UTF8 Caller ID names in
- * to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
+ * to ASCII Caller ID's (DAHDI). Ãsten Ã
sklund might be transliterated into
* Osten Asklund or Oesten Aasklund depending upon language and person...
* We need automatic routines for incoming calls and static settings for
* our own accounts.
@@ -3015,7 +3015,7 @@
*
* \details
* This function will generate an effective party id.
- *
+ *
* Each party id component of the party id 'base' is overwritten
* by components of the party id 'overlay' if the overlay
* component is marked as valid. However the component 'tag' of
@@ -3788,7 +3788,7 @@
void ast_channel_unlink(struct ast_channel *chan);
/*!
- * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
+ * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
* on the given channel
*
* \param chan channel on which to set the cause information
@@ -4125,69 +4125,6 @@
*/
struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan);
-/*! \addtogroup StasisTopicsAndMessages
- * @{
- */
-
-/*!
- * \since 12
- * \brief Structure representing a snapshot of channel state.
- *
- * While not enforced programmatically, this object is shared across multiple
- * threads, and should be threated as an immutable object.
- */
-struct ast_channel_snapshot {
- AST_DECLARE_STRING_FIELDS(
- AST_STRING_FIELD(name); /*!< ASCII unique channel name */
- AST_STRING_FIELD(accountcode); /*!< Account code for billing */
- AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
- AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
- AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */
- AST_STRING_FIELD(linkedid); /*!< Linked Channel Identifier -- gets propagated by linkage */
- AST_STRING_FIELD(parkinglot); /*!< Default parking lot, if empty, default parking lot */
- AST_STRING_FIELD(hangupsource); /*!< Who is responsible for hanging up this channel */
- AST_STRING_FIELD(appl); /*!< Current application */
- AST_STRING_FIELD(data); /*!< Data passed to current application */
- AST_STRING_FIELD(context); /*!< Dialplan: Current extension context */
- AST_STRING_FIELD(exten); /*!< Dialplan: Current extension number */
- AST_STRING_FIELD(caller_name); /*!< Caller ID Name */
- AST_STRING_FIELD(caller_number); /*!< Caller ID Number */
- AST_STRING_FIELD(connected_name); /*!< Connected Line Name */
- AST_STRING_FIELD(connected_number); /*!< Connected Line Number */
- );
-
- struct timeval creationtime; /*!< The time of channel creation */
- enum ast_channel_state state; /*!< State of line */
- int priority; /*!< Dialplan: Current extension priority */
- int amaflags; /*!< AMA flags for billing */
- int hangupcause; /*!< Why is the channel hanged up. See causes.h */
- int caller_pres; /*!< Caller ID presentation. */
-
- struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */
-
- struct varshead *manager_vars; /*!< Variables to be appended to manager events */
-};
-
-/*!
- * \since 12
- * \brief Generate a snapshot of the channel state. This is an ao2 object, so
- * ao2_cleanup() to deallocate.
- *
- * \param chan The channel from which to generate a snapshot
- *
- * \retval pointer on success (must be ast_freed)
- * \retval NULL on error
- */
-struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan);
-
-/*!
- * \since 12
- * \brief Message type for \ref ast_channel_snapshot.
- *
- * \retval Message type for \ref ast_channel_snapshot.
- */
-struct stasis_message_type *ast_channel_snapshot_type(void);
-
/*!
* \since 12
* \brief A topic which publishes the events for a particular channel.
@@ -4201,81 +4138,4 @@
*/
struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
-/*!
- * \since 12
- * \brief A topic which publishes the events for all channels.
- * \retval Topic for all channel events.
- */
-struct stasis_topic *ast_channel_topic_all(void);
-
-/*!
- * \since 12
- * \brief A caching topic which caches \ref ast_channel_snapshot messages from
- * ast_channel_events_all(void).
- *
- * \retval Topic for all channel events.
- */
-struct stasis_caching_topic *ast_channel_topic_all_cached(void);
-
-/*!
- * \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.
- */
-struct ast_channel_blob {
- /*! Channel blob is associated with (or NULL for global/all channels) */
- struct ast_channel_snapshot *snapshot;
- /*! JSON blob of data */
- struct ast_json *blob;
-};
-
-/*!
- * \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 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 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.
- * \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 Publish a \ref ast_channel_varset for a channel.
- *
- * \param chan Channel to pulish the event for, or \c NULL for 'none'.
- * \param variable Name of the variable being set
- * \param value Value.
- */
-void ast_channel_publish_varset(struct ast_channel *chan,
- const char *variable, const char *value);
-
#endif /* _ASTERISK_CHANNEL_H */
Modified: team/dlee/stasis-http/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/main/channel.c?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/main/channel.c (original)
+++ team/dlee/stasis-http/main/channel.c Tue Apr 9 13:53:58 2013
@@ -74,6 +74,7 @@
#include "asterisk/channel_internal.h"
#include "asterisk/features.h"
#include "asterisk/test.h"
+#include "asterisk/stasis_channels.h"
/*** DOCUMENTATION
***/
@@ -151,15 +152,6 @@
/*! \brief All active channels on the system */
static struct ao2_container *channels;
-
-/*! \brief Message type for channel snapshot events */
-static struct stasis_message_type *channel_snapshot_type;
-
-static struct stasis_message_type *channel_blob_type;
-
-struct stasis_topic *channel_topic_all;
-
-struct stasis_caching_topic *channel_topic_all_cached;
/*! \brief map AST_CAUSE's to readable string representations
*
@@ -223,116 +215,6 @@
{ AST_CAUSE_INTERWORKING, "INTERWORKING", "Interworking, unspecified" },
};
-static void publish_channel_state(struct ast_channel *chan)
-{
- RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
-
- snapshot = ast_channel_snapshot_create(chan);
- if (!snapshot) {
- ast_log(LOG_ERROR, "Allocation error\n");
- return;
- }
-
- message = stasis_message_create(ast_channel_snapshot_type(), snapshot);
- if (!message) {
- return;
- }
-
- ast_assert(ast_channel_topic(chan) != NULL);
- stasis_publish(ast_channel_topic(chan), message);
-}
-
-static void publish_channel_blob(struct ast_channel *chan, struct ast_json *blob)
-{
- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
- if (blob) {
- message = ast_channel_blob_create(chan, blob);
- }
- if (message) {
- stasis_publish(ast_channel_topic(chan), message);
- }
-}
-
-
-static void channel_blob_dtor(void *obj)
-{
- struct ast_channel_blob *event = obj;
- ao2_cleanup(event->snapshot);
- ast_json_unref(event->blob);
-}
-
-struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
- struct ast_json *blob)
-{
- RAII_VAR(struct ast_channel_blob *, obj, NULL, ao2_cleanup);
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
- struct ast_json *type;
-
- ast_assert(blob != NULL);
-
- type = ast_json_object_get(blob, "type");
- if (type == NULL) {
- ast_log(LOG_ERROR, "Invalid ast_channel_blob; missing type field");
- return NULL;
- }
-
- obj = ao2_alloc(sizeof(*obj), channel_blob_dtor);
- if (!obj) {
- return NULL;
- }
-
- if (chan) {
- obj->snapshot = ast_channel_snapshot_create(chan);
- if (obj->snapshot == NULL) {
- return NULL;
- }
- }
-
- obj->blob = ast_json_ref(blob);
-
- msg = stasis_message_create(ast_channel_blob_type(), obj);
- if (!msg) {
- return NULL;
- }
-
- ao2_ref(msg, +1);
- return msg;
-}
-
-const char *ast_channel_blob_json_type(struct ast_channel_blob *obj)
-{
- if (obj == NULL) {
- return NULL;
- }
-
- return ast_json_string_get(ast_json_object_get(obj->blob, "type"));
-}
-
-void ast_channel_publish_varset(struct ast_channel *chan, const char *name, const char *value)
-{
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
- RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
-
- ast_assert(name != NULL);
- ast_assert(value != NULL);
-
- blob = ast_json_pack("{s: s, s: s, s: s}",
- "type", "varset",
- "variable", name,
- "value", value);
- publish_channel_blob(chan, blob);
-}
-
-
-static void publish_cache_clear(struct ast_channel *chan)
-{
- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
-
- message = stasis_cache_clear_create(ast_channel_snapshot_type(), ast_channel_uniqueid(chan));
- stasis_publish(ast_channel_topic(chan), message);
-}
-
struct ast_variable *ast_channeltype_list(void)
{
struct chanlist *cl;
@@ -932,6 +814,34 @@
return causes[x].cause;
return -1;
+}
+
+static void publish_channel_state(struct ast_channel *chan)
+{
+ RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+
+ snapshot = ast_channel_snapshot_create(chan);
+ if (!snapshot) {
+ ast_log(LOG_ERROR, "Allocation error\n");
+ return;
+ }
+
+ message = stasis_message_create(ast_channel_snapshot_type(), snapshot);
+ if (!message) {
+ return;
+ }
+
+ ast_assert(ast_channel_topic(chan) != NULL);
+ stasis_publish(ast_channel_topic(chan), message);
+}
+
+static void publish_cache_clear(struct ast_channel *chan)
+{
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+
+ message = stasis_cache_clear_create(ast_channel_snapshot_type(), ast_channel_uniqueid(chan));
+ stasis_publish(ast_channel_topic(chan), message);
}
/*! \brief Gives the string form of a given channel state.
@@ -1455,6 +1365,18 @@
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
{
return __ast_queue_frame(chan, fin, 1, NULL);
+}
+
+/*! \internal \brief Publish a channel blob message */
+static void publish_channel_blob(struct ast_channel *chan, struct ast_json *blob)
+{
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+ if (blob) {
+ message = ast_channel_blob_create(chan, blob);
+ }
+ if (message) {
+ stasis_publish(ast_channel_topic(chan), message);
+ }
}
/*! \brief Queue a hangup frame for channel */
@@ -8700,14 +8622,11 @@
static void channels_shutdown(void)
{
+
+ ast_stasis_channels_shutdown();
+
free_channelvars();
- ao2_cleanup(channel_snapshot_type);
- channel_snapshot_type = NULL;
- ao2_cleanup(channel_blob_type);
- channel_blob_type = NULL;
- ao2_cleanup(channel_topic_all);
- channel_topic_all = NULL;
- channel_topic_all_cached = stasis_caching_unsubscribe(channel_topic_all_cached);
+
ast_data_unregister(NULL);
ast_cli_unregister_multiple(cli_channel, ARRAY_LEN(cli_channel));
if (channels) {
@@ -8717,16 +8636,6 @@
}
}
-static const char *channel_snapshot_get_id(struct stasis_message *message)
-{
- struct ast_channel_snapshot *snapshot;
- if (ast_channel_snapshot_type() != stasis_message_type(message)) {
- return NULL;
- }
- snapshot = stasis_message_data(message);
- return snapshot->uniqueid;
-}
-
void ast_channels_init(void)
{
channels = ao2_container_alloc(NUM_CHANNEL_BUCKETS,
@@ -8735,11 +8644,7 @@
ao2_container_register("channels", channels, prnt_channel_key);
}
- channel_snapshot_type = stasis_message_type_create("ast_channel_snapshot");
- channel_blob_type = stasis_message_type_create("ast_channel_blob");
-
- channel_topic_all = stasis_topic_create("ast_channel_topic_all");
- channel_topic_all_cached = stasis_caching_topic_create(channel_topic_all, channel_snapshot_get_id);
+ ast_stasis_channels_init();
ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
@@ -11322,83 +11227,6 @@
return 0;
}
-static void ast_channel_snapshot_dtor(void *obj)
-{
- struct ast_channel_snapshot *snapshot = obj;
- ast_string_field_free_memory(snapshot);
- ao2_cleanup(snapshot->manager_vars);
-}
-
-struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
-{
- RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
-
- snapshot = ao2_alloc(sizeof(*snapshot), ast_channel_snapshot_dtor);
- if (ast_string_field_init(snapshot, 1024)) {
- return NULL;
- }
-
- ast_string_field_set(snapshot, name, ast_channel_name(chan));
- ast_string_field_set(snapshot, accountcode, ast_channel_accountcode(chan));
- ast_string_field_set(snapshot, peeraccount, ast_channel_peeraccount(chan));
- ast_string_field_set(snapshot, userfield, ast_channel_userfield(chan));
- ast_string_field_set(snapshot, uniqueid, ast_channel_uniqueid(chan));
- ast_string_field_set(snapshot, linkedid, ast_channel_linkedid(chan));
- ast_string_field_set(snapshot, parkinglot, ast_channel_parkinglot(chan));
- ast_string_field_set(snapshot, hangupsource, ast_channel_hangupsource(chan));
- if (ast_channel_appl(chan)) {
- ast_string_field_set(snapshot, appl, ast_channel_appl(chan));
- }
- if (ast_channel_data(chan)) {
- ast_string_field_set(snapshot, data, ast_channel_data(chan));
- }
- ast_string_field_set(snapshot, context, ast_channel_context(chan));
- ast_string_field_set(snapshot, exten, ast_channel_exten(chan));
-
- ast_string_field_set(snapshot, caller_name,
- S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, ""));
- ast_string_field_set(snapshot, caller_number,
- S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""));
-
- ast_string_field_set(snapshot, connected_name,
- S_COR(ast_channel_connected(chan)->id.name.valid, ast_channel_connected(chan)->id.name.str, ""));
- ast_string_field_set(snapshot, connected_number,
- S_COR(ast_channel_connected(chan)->id.number.valid, ast_channel_connected(chan)->id.number.str, ""));
-
- snapshot->creationtime = ast_channel_creationtime(chan);
- snapshot->state = ast_channel_state(chan);
- snapshot->priority = ast_channel_priority(chan);
- snapshot->amaflags = ast_channel_amaflags(chan);
- snapshot->hangupcause = ast_channel_hangupcause(chan);
- snapshot->flags = *ast_channel_flags(chan);
- snapshot->caller_pres = ast_party_id_presentation(&ast_channel_caller(chan)->id);
-
- snapshot->manager_vars = ast_channel_get_manager_vars(chan);
-
- ao2_ref(snapshot, +1);
- return snapshot;
-}
-
-struct stasis_message_type *ast_channel_blob_type(void)
-{
- return channel_blob_type;
-}
-
-struct stasis_message_type *ast_channel_snapshot_type(void)
-{
- return channel_snapshot_type;
-}
-
-struct stasis_topic *ast_channel_topic_all(void)
-{
- return channel_topic_all;
-}
-
-struct stasis_caching_topic *ast_channel_topic_all_cached(void)
-{
- return channel_topic_all_cached;
-}
-
/* DO NOT PUT ADDITIONAL FUNCTIONS BELOW THIS BOUNDARY
*
* ONLY FUNCTIONS FOR PROVIDING BACKWARDS ABI COMPATIBILITY BELONG HERE
Modified: team/dlee/stasis-http/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/main/channel_internal_api.c?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/main/channel_internal_api.c (original)
+++ team/dlee/stasis-http/main/channel_internal_api.c Tue Apr 9 13:53:58 2013
@@ -42,6 +42,7 @@
#include "asterisk/stringfields.h"
#include "asterisk/data.h"
#include "asterisk/indications.h"
+#include "asterisk/stasis_channels.h"
#include "asterisk/channel_internal.h"
#include "asterisk/test.h"
@@ -1400,4 +1401,7 @@
chan->topic = stasis_topic_create(topic_name);
chan->forwarder = stasis_forward_all(chan->topic, ast_channel_topic_all());
-}
+
+ ast_assert(chan->topic != NULL);
+ ast_assert(chan->forwarder != NULL);
+}
Modified: team/dlee/stasis-http/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/main/dial.c?view=diff&rev=385119&r1=385118&r2=385119
==============================================================================
--- team/dlee/stasis-http/main/dial.c (original)
+++ team/dlee/stasis-http/main/dial.c Tue Apr 9 13:53:58 2013
@@ -42,6 +42,8 @@
#include "asterisk/pbx.h"
#include "asterisk/musiconhold.h"
#include "asterisk/app.h"
+#include "asterisk/causes.h"
+#include "asterisk/stasis_channels.h"
/*! \brief Main dialing structure. Contains global options, channels being dialed, and more! */
struct ast_dial {
@@ -316,6 +318,7 @@
} else {
if (chan)
ast_poll_channel_add(chan, channel->owner);
+ ast_channel_publish_dial(chan, channel->owner, channel->device, NULL);
res = 1;
ast_verb(3, "Called %s\n", numsubst);
}
@@ -413,15 +416,18 @@
AST_LIST_REMOVE(&dial->channels, channel, list);
AST_LIST_INSERT_HEAD(&dial->channels, channel, list);
AST_LIST_UNLOCK(&dial->channels);
+ ast_channel_publish_dial(chan, channel->owner, channel->device, "ANSWER");
set_state(dial, AST_DIAL_RESULT_ANSWERED);
break;
case AST_CONTROL_BUSY:
ast_verb(3, "%s is busy\n", ast_channel_name(channel->owner));
+ ast_channel_publish_dial(chan, channel->owner, channel->device, "BUSY");
ast_hangup(channel->owner);
channel->owner = NULL;
break;
case AST_CONTROL_CONGESTION:
ast_verb(3, "%s is circuit-busy\n", ast_channel_name(channel->owner));
+ ast_channel_publish_dial(chan, channel->owner, channel->device, "CONGESTION");
ast_hangup(channel->owner);
channel->owner = NULL;
break;
[... 647 lines stripped ...]
More information about the asterisk-commits
mailing list