[Freeswitch-branches] [commit] r3161 - in freeswitch/branches/knhor/trunk: . conf libs/codec/gsm libs/codec/gsm/inc libs/codec/gsm/src libs/libdingaling libs/libdingaling/src scripts/socket src src/include src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/applications/mod_playback src/mod/applications/mod_skel src/mod/dialplans src/mod/endpoints src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_sofia src/mod/event_handlers/mod_event_socket src/mod/formats/mod_sndfile src/mod/languages w32/Setup
Freeswitch SVN
knhor at freeswitch.org
Sun Oct 22 16:46:51 EDT 2006
Author: knhor
Date: Sun Oct 22 16:46:47 2006
New Revision: 3161
Modified:
freeswitch/branches/knhor/trunk/ (props changed)
freeswitch/branches/knhor/trunk/AUTHORS
freeswitch/branches/knhor/trunk/Freeswitch.sln
freeswitch/branches/knhor/trunk/conf/freeswitch.xml
freeswitch/branches/knhor/trunk/libs/codec/gsm/inc/private.h
freeswitch/branches/knhor/trunk/libs/codec/gsm/libgsm.vcproj
freeswitch/branches/knhor/trunk/libs/codec/gsm/src/long_term.c
freeswitch/branches/knhor/trunk/libs/codec/gsm/src/preprocess.c
freeswitch/branches/knhor/trunk/libs/codec/gsm/src/rpe.c
freeswitch/branches/knhor/trunk/libs/codec/gsm/src/short_term.c
freeswitch/branches/knhor/trunk/libs/libdingaling/.update
freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c
freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.h
freeswitch/branches/knhor/trunk/scripts/socket/ (props changed)
freeswitch/branches/knhor/trunk/scripts/socket/fsconsole.pl
freeswitch/branches/knhor/trunk/src/ (props changed)
freeswitch/branches/knhor/trunk/src/include/switch_channel.h
freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/branches/knhor/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/branches/knhor/trunk/src/mod/applications/mod_playback/mod_playback.c
freeswitch/branches/knhor/trunk/src/mod/applications/mod_skel/mod_skel.c
freeswitch/branches/knhor/trunk/src/mod/dialplans/ (props changed)
freeswitch/branches/knhor/trunk/src/mod/endpoints/ (props changed)
freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/ (props changed)
freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/branches/knhor/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/branches/knhor/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c
freeswitch/branches/knhor/trunk/src/mod/languages/ (props changed)
freeswitch/branches/knhor/trunk/src/switch_channel.c
freeswitch/branches/knhor/trunk/src/switch_core.c
freeswitch/branches/knhor/trunk/w32/Setup/ (props changed)
Log:
Merged revisions 3127-3160 via svnmerge from trunk
Modified: freeswitch/branches/knhor/trunk/AUTHORS
==============================================================================
--- freeswitch/branches/knhor/trunk/AUTHORS (original)
+++ freeswitch/branches/knhor/trunk/AUTHORS Sun Oct 22 16:46:47 2006
@@ -28,6 +28,7 @@
Justin Unger - <justinunger at gmail dot com> Lots of help with patches and SIP testing. Thanks!
Paul D. Tinsley - Various patches and support. <pdt at jackhammer.org>
Ken Rice of Asteria Solutions Group, INC <ken AT asteriasgi.com> - xmlcdr, sofia improvements, load testing.
+ Neal Horman <neal at wanlink dot com> - conference improvements and other tweaks.
A big THANK YOU goes to:
Modified: freeswitch/branches/knhor/trunk/Freeswitch.sln
==============================================================================
--- freeswitch/branches/knhor/trunk/Freeswitch.sln (original)
+++ freeswitch/branches/knhor/trunk/Freeswitch.sln Sun Oct 22 16:46:47 2006
@@ -243,13 +243,13 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dingaling", "src\mod\endpoints\mod_dingaling\mod_dingaling.vcproj", "{FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}"
ProjectSection(ProjectDependencies) = postProject
- {1906D736-08BD-4EE1-924F-B536249B9A54} = {1906D736-08BD-4EE1-924F-B536249B9A54}
- {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}
{E727E8F6-935D-46FE-8B0E-37834748A0E3} = {E727E8F6-935D-46FE-8B0E-37834748A0E3}
+ {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}
{101130D1-3EA6-4ED2-B65D-CEB5243A20ED} = {101130D1-3EA6-4ED2-B65D-CEB5243A20ED}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {1906D736-08BD-4EE1-924F-B536249B9A54} = {1906D736-08BD-4EE1-924F-B536249B9A54}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_commands", "src\mod\applications\mod_commands\mod_commands.vcproj", "{30A5B29C-983E-4580-9FD0-D647CCDCC7EB}"
@@ -292,10 +292,11 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_conference", "src\mod\applications\mod_conference\mod_conference.vcproj", "{C24FB505-05D7-4319-8485-7540B44C8603}"
ProjectSection(ProjectDependencies) = postProject
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}
{101130D1-3EA6-4ED2-B65D-CEB5243A20ED} = {101130D1-3EA6-4ED2-B65D-CEB5243A20ED}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dptools", "src\mod\applications\mod_dptools\mod_dptools.vcproj", "{B5881A85-FE70-4F64-8607-2CAAE52669C6}"
Modified: freeswitch/branches/knhor/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/knhor/trunk/conf/freeswitch.xml (original)
+++ freeswitch/branches/knhor/trunk/conf/freeswitch.xml Sun Oct 22 16:46:47 2006
@@ -484,17 +484,65 @@
<section name="directory" description="User Directory">
<!--the domain or ip (the right hand side of the @ in the addr-->
- <domain name="mydomain.com">
+ <domain name="jabber.org">
<!--the user id (the left hand side of the @ in the addr-->
- <user id="1000">
- <!-- omit password for authless registration -->
- <param name="password" value="mypass"/>
- <!--various endpoints and application will look for user specific settings here -->
- <param name="mypref" value="myval"/>
+ <user id="stpeter">
+ <params>
+ <!-- omit password for authless registration -->
+ <param name="password" value="mypass"/>
+ </params>
+
+ <vcard xmlns='vcard-temp'>
+ <FN>Peter Saint-Andre</FN>
+ <N>
+ <FAMILY>Saint-Andre</FAMILY>
+ <GIVEN>Peter</GIVEN>
+ <MIDDLE/>
+ </N>
+ <NICKNAME>stpeter</NICKNAME>
+ <URL>http://www.jabber.org/people/stpeter.php</URL>
+ <BDAY>1966-08-06</BDAY>
+ <ORG>
+ <ORGNAME>Jabber Software Foundation</ORGNAME>
+ <ORGUNIT>Jabber Software Foundation</ORGUNIT>
+ </ORG>
+ <TITLE>Executive Director</TITLE>
+ <ROLE>Patron Saint</ROLE>
+ <TEL><WORK/><VOICE/><NUMBER>303-308-3282</NUMBER></TEL>
+ <TEL><WORK/><FAX/><NUMBER/></TEL>
+ <TEL><WORK/><MSG/><NUMBER/></TEL>
+ <ADR>
+ <WORK/>
+ <EXTADD>Suite 600</EXTADD>
+ <STREET>1899 Wynkoop Street</STREET>
+ <LOCALITY>Denver</LOCALITY>
+ <REGION>CO</REGION>
+ <PCODE>80202</PCODE>
+ <CTRY>USA</CTRY>
+ </ADR>
+ <TEL><HOME/><VOICE/><NUMBER>303-555-1212</NUMBER></TEL>
+ <TEL><HOME/><FAX/><NUMBER/></TEL>
+ <TEL><HOME/><MSG/><NUMBER/></TEL>
+ <ADR>
+ <HOME/>
+ <EXTADD/>
+ <STREET/>
+ <LOCALITY>Denver</LOCALITY>
+ <REGION>CO</REGION>
+ <PCODE>80209</PCODE>
+ <CTRY>USA</CTRY>
+ </ADR>
+ <EMAIL><INTERNET/><PREF/><USERID>stpeter at jabber.org</USERID></EMAIL>
+ <JABBERID>stpeter at jabber.org</JABBERID>
+ <DESC>
+ More information about me is located on my
+ personal website: http://www.saint-andre.com/
+ </DESC>
+ </vcard>
+
</user>
</domain>
</section>
-
</document>
Modified: freeswitch/branches/knhor/trunk/libs/codec/gsm/inc/private.h
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/codec/gsm/inc/private.h (original)
+++ freeswitch/branches/knhor/trunk/libs/codec/gsm/inc/private.h Sun Oct 22 16:46:47 2006
@@ -33,7 +33,7 @@
word v[9]; /* short_term.c, synthesis */
word msr; /* decoder.c, Postprocessing */
- char verbose; /* only used if !NDEBUG */
+ int verbose; /* only used if !NDEBUG */
char fast; /* only used if FAST */
char wav_fmt; /* only used if WAV49 defined */
Modified: freeswitch/branches/knhor/trunk/libs/codec/gsm/libgsm.vcproj
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/codec/gsm/libgsm.vcproj (original)
+++ freeswitch/branches/knhor/trunk/libs/codec/gsm/libgsm.vcproj Sun Oct 22 16:46:47 2006
@@ -46,9 +46,10 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
+ DisableSpecificWarnings="4131;4100"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -107,9 +108,10 @@
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
+ DisableSpecificWarnings="4131;4100"
/>
<Tool
Name="VCManagedResourceCompilerTool"
Modified: freeswitch/branches/knhor/trunk/libs/codec/gsm/src/long_term.c
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/codec/gsm/src/long_term.c (original)
+++ freeswitch/branches/knhor/trunk/libs/codec/gsm/src/long_term.c Sun Oct 22 16:46:47 2006
@@ -194,7 +194,7 @@
/* Initialization of a working array wt
*/
- for (k = 0; k <= 39; k++) wt[k] = SASR( d[k], scal );
+ for (k = 0; k <= 39; k++) wt[k] = (word)SASR( d[k], scal );
/* Search for the maximum cross-correlation and coding of the LTP lag
*/
@@ -231,7 +231,7 @@
if (L_result > L_max) {
- Nc = lambda;
+ Nc = (word)lambda;
L_max = L_result;
}
}
Modified: freeswitch/branches/knhor/trunk/libs/codec/gsm/src/preprocess.c
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/codec/gsm/src/preprocess.c (original)
+++ freeswitch/branches/knhor/trunk/libs/codec/gsm/src/preprocess.c Sun Oct 22 16:46:47 2006
@@ -40,7 +40,7 @@
word z1 = S->z1;
longword L_z2 = S->L_z2;
- word mp = S->mp;
+ word mp = (word)S->mp;
word s1;
longword L_s2;
@@ -59,7 +59,7 @@
/* 4.2.1 Downscaling of the input signal
*/
- SO = SASR( *s, 3 ) << 2;
+ SO = (word)SASR( *s, 3 ) << 2;
s++;
assert (SO >= -0x4000); /* downscaled by */
Modified: freeswitch/branches/knhor/trunk/libs/codec/gsm/src/rpe.c
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/codec/gsm/src/rpe.c (original)
+++ freeswitch/branches/knhor/trunk/libs/codec/gsm/src/rpe.c Sun Oct 22 16:46:47 2006
@@ -232,7 +232,7 @@
*/
exp = 0;
- if (xmaxc > 15) exp = SASR(xmaxc, 3) - 1;
+ if (xmaxc > 15) exp = (word)SASR(xmaxc, 3) - 1;
mant = xmaxc - (exp << 3);
if (mant == 0) {
@@ -283,13 +283,13 @@
*/
exp = 0;
- temp = SASR( xmax, 9 );
+ temp = (word)SASR( xmax, 9 );
itest = 0;
for (i = 0; i <= 5; i++) {
itest |= (temp <= 0);
- temp = SASR( temp, 1 );
+ temp = (word)SASR( temp, 1 );
assert(exp <= 5);
if (itest == 0) exp++; /* exp = add (exp, 1) */
@@ -333,7 +333,7 @@
temp = xM[i] << temp1;
temp = (word) GSM_MULT( temp, temp2 );
- temp = SASR(temp, 12);
+ temp = (word)SASR(temp, 12);
xMc[i] = temp + 4; /* see note below */
}
Modified: freeswitch/branches/knhor/trunk/libs/codec/gsm/src/short_term.c
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/codec/gsm/src/short_term.c (original)
+++ freeswitch/branches/knhor/trunk/libs/codec/gsm/src/short_term.c Sun Oct 22 16:46:47 2006
@@ -167,9 +167,9 @@
if (*LARp < 0) {
temp = *LARp == MIN_WORD ? MAX_WORD : -(*LARp);
- *LARp = - ((temp < 11059) ? temp << 1
- : ((temp < 20070) ? temp + 11059
- : (word) GSM_ADD( temp >> 2, 26112 )));
+ *LARp =(word)( - ((temp < 11059) ? (word)(temp << 1)
+ : ((temp < 20070) ? (word)(temp + 11059)
+ : (word) GSM_ADD( temp >> 2, 26112 ))));
} else {
temp = *LARp;
*LARp = (temp < 11059) ? temp << 1
Modified: freeswitch/branches/knhor/trunk/libs/libdingaling/.update
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/libdingaling/.update (original)
+++ freeswitch/branches/knhor/trunk/libs/libdingaling/.update Sun Oct 22 16:46:47 2006
@@ -1 +1 @@
-Fri Oct 20 02:34:55 CDT 2006
+Fri Oct 20 19:58:38 CDT 2006
Modified: freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c (original)
+++ freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c Sun Oct 22 16:46:47 2006
@@ -461,6 +461,19 @@
const char *marker = "TRUE";
+static int on_vcard(void *user_data, ikspak *pak)
+{
+ ldl_handle_t *handle = user_data;
+ char *from = iks_find_attrib(pak->x, "from");
+ char *to = iks_find_attrib(pak->x, "to");
+
+ if (handle->session_callback) {
+ handle->session_callback(handle, NULL, LDL_SIGNAL_VCARD, to, from, pak->id, NULL);
+ }
+
+ return IKS_FILTER_EAT;
+}
+
static int on_disco_info(void *user_data, ikspak *pak)
{
ldl_handle_t *handle = user_data;
@@ -1240,6 +1253,8 @@
IKS_RULE_SUBTYPE, IKS_TYPE_GET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
iks_filter_add_rule(handle->filter, on_disco_reg_out, handle,
IKS_RULE_SUBTYPE, IKS_TYPE_SET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
+ iks_filter_add_rule(handle->filter, on_vcard, handle,
+ IKS_RULE_SUBTYPE, IKS_TYPE_GET, IKS_RULE_NS, "vcard-temp", IKS_RULE_DONE);
} else {
iks_filter_add_rule(handle->filter, on_disco_info, handle,
IKS_RULE_NS, "http://jabber.org/protocol/disco#info", IKS_RULE_DONE);
@@ -1571,14 +1586,68 @@
do_presence(handle, from, to, type, rpid, message);
}
+void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id, char *vcard)
+{
+ iks *vxml, *iq;
+ int e = 0;
+
+ if (!(vxml = iks_tree(vcard, 0, &e))) {
+ globals.logger(DL_LOG_ERR, "Parse returned error [%d]\n", e);
+ return;
+ }
+
+ if (!(iq = iks_new("iq"))) {
+ globals.logger(DL_LOG_ERR, "Memory Error\n");
+ return;
+ }
+
+ iks_insert_attrib(iq, "to", to);
+ iks_insert_attrib(iq, "xmlns", "jabber:client");
+ iks_insert_attrib(iq,"from", from);
+ iks_insert_attrib(iq, "type", "result");
+ iks_insert_attrib(iq, "id", id);
+ iks_insert_node(iq, vxml);
+
+ apr_queue_push(handle->queue, iq);
+
+ iks_free(vxml);
+
+}
+
void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, char *subject, char *body)
{
iks *msg;
-
+ char *t, *e;
+ char *bdup = NULL;
+ int on = 0;
+ int len = 0;
assert(handle != NULL);
assert(body != NULL);
+
+ if (strchr(body, '<')) {
+ len = (int) strlen(body);
+ if (!(bdup = malloc(len))) {
+ return;
+ }
-
+ memset(bdup, 0, len);
+
+ e = bdup;
+ for(t = body; *t; t++) {
+ if (*t == '<') {
+ on = 1;
+ } else if (*t == '>') {
+ t++;
+ on = 0;
+ }
+
+ if (!on) {
+ *e++ = *t;
+ }
+ }
+ body = bdup;
+ }
+
msg = iks_make_msg(IKS_TYPE_NONE, to, body);
iks_insert_attrib(msg, "type", "chat");
@@ -1590,6 +1659,10 @@
if (subject) {
iks_insert_attrib(msg, "subject", subject);
+ }
+
+ if (bdup) {
+ free(bdup);
}
apr_queue_push(handle->queue, msg);
Modified: freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.h
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.h (original)
+++ freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.h Sun Oct 22 16:46:47 2006
@@ -126,6 +126,7 @@
LDL_SIGNAL_ROSTER,
LDL_SIGNAL_SUBSCRIBE,
LDL_SIGNAL_UNSUBSCRIBE,
+ LDL_SIGNAL_VCARD,
LDL_SIGNAL_TERMINATE,
LDL_SIGNAL_ERROR,
LDL_SIGNAL_LOGIN_SUCCESS,
@@ -373,6 +374,16 @@
\param message a status message
*/
void ldl_handle_send_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *rpid, char *message);
+
+/*!
+ \brief Send a vcard
+ \param handle the handle to send with
+ \param from the from address
+ \param to the to address
+ \param id the request id
+ \param vcard the text xml of the vcard
+*/
+void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id, char *vcard);
/*!
\brief Send a message
Modified: freeswitch/branches/knhor/trunk/scripts/socket/fsconsole.pl
==============================================================================
--- freeswitch/branches/knhor/trunk/scripts/socket/fsconsole.pl (original)
+++ freeswitch/branches/knhor/trunk/scripts/socket/fsconsole.pl Sun Oct 22 16:46:47 2006
@@ -225,7 +225,7 @@
#see if we got connected at some point
if(defined($sockets{'localhost'})) {
#send the command
- $sockets{'localhost'}->put($input);
+ $sockets{'localhost'}->put("api $input");
}
}
}
Modified: freeswitch/branches/knhor/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/branches/knhor/trunk/src/include/switch_channel.h (original)
+++ freeswitch/branches/knhor/trunk/src/include/switch_channel.h Sun Oct 22 16:46:47 2006
@@ -137,6 +137,14 @@
uint32_t flags);
/*!
+ \brief Fire A presence event for the channel
+ \param channel the channel to initilize
+ \param rpid the rpid if for the icon to use
+ \param status the status message
+*/
+SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, char *rpid, char *status);
+
+/*!
\brief Uninitalize a channel
\param channel the channel to uninit
*/
Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c Sun Oct 22 16:46:47 2006
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II <anthmct at yahoo.com>
+ * Neal Horman <neal at wanlink dot com>
*
*
* mod_conference.c -- Software Conference Bridge
@@ -196,7 +197,6 @@
};
typedef struct conference_record conference_record_t;
-
/* Function Prototypes */
static uint32_t next_member_id(void);
static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member);
@@ -234,9 +234,9 @@
static void launch_conference_record_thread(conference_obj_t *conference, char *path);
static void conference_member_itterator(conference_obj_t *conference,
- switch_stream_handle_t *stream,
- int (*pfncallback)(conference_obj_t*, conference_member_t*, int, switch_stream_handle_t*, void*),
- void *data);
+ switch_stream_handle_t *stream,
+ int (*pfncallback)(conference_obj_t*, conference_member_t*, int, switch_stream_handle_t*, void*),
+ void *data);
/* Return a Distinct ID # */
static uint32_t next_member_id(void)
@@ -250,7 +250,6 @@
return id;
}
-
static void switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
{
int16_t *p = data;
@@ -286,7 +285,7 @@
if (rel->id == other_member->id) {
break;
}
-
+
/* 0 matches everyone.
(We will still test the others brcause a real match carries more clout) */
@@ -311,7 +310,7 @@
conference_member_t *member = NULL;
for(member = conference->members; member; member = member->next) {
-
+
if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
continue;
}
@@ -320,7 +319,7 @@
break;
}
}
-
+
return member;
}
@@ -409,11 +408,11 @@
switch_event_fire(&event);
}
-
+
if (conference->enter_sound) {
conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN);
}
-
+
if (conference->count == 1 && conference->alone_sound) {
conference_play_file(conference, conference->alone_sound, 0);
}
@@ -480,7 +479,7 @@
if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min)
|| (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0) ) {
- switch_set_flag(conference, CFLAG_DESTRUCT);
+ switch_set_flag(conference, CFLAG_DESTRUCT);
} else {
if (conference->exit_sound) {
conference_play_file(conference, conference->exit_sound, 0);
@@ -489,7 +488,7 @@
conference_play_file(conference, conference->alone_sound, 0);
}
}
-
+
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
@@ -540,7 +539,7 @@
/* Sync the conference to a single timing source */
switch_core_timer_next(&timer);
-
+
switch_mutex_lock(conference->mutex);
ready = 0;
@@ -583,7 +582,7 @@
}
switch_mutex_unlock(imember->audio_in_mutex);
}
-
+
/* If a file or speech event is being played */
if (conference->fnode) {
/* Lead in time */
@@ -594,7 +593,7 @@
if (conference->fnode->type == NODE_TYPE_SPEECH) {
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
uint32_t rate = conference->rate;
-
+
if (switch_core_speech_read_tts(&conference->fnode->sh,
file_frame,
&file_data_len,
@@ -613,7 +612,7 @@
}
}
}
-
+
if (ready) {
/* Build a muxed frame for every member that contains the mixed audio of everyone else */
for (omember = conference->members; omember; omember = omember->next) {
@@ -648,7 +647,7 @@
/* If we are not supposed to hear them then don't let it happen */
if (imember->relationships) {
conference_relationship_t *rel;
-
+
if ((rel = member_get_relationship(imember, omember))) {
if (! switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
continue;
@@ -659,18 +658,17 @@
if (imember->read > imember->len) {
imember->len = imember->read;
}
-
+
bptr = (int16_t *) imember->frame;
muxed = (int16_t *) omember->mux_frame;
-
-
+
for (x = 0; x < imember->read / 2; x++) {
int32_t z = muxed[x] + bptr[x];
switch_normalize_to_16bit(z);
muxed[x] = (int16_t)z;
}
-
+
ready++;
}
}
@@ -683,7 +681,6 @@
switch_mutex_unlock(imember->audio_out_mutex);
}
}
-
if (conference->fnode && conference->fnode->done) {
confernce_file_node_t *fnode;
@@ -704,7 +701,7 @@
switch_core_destroy_memory_pool(&pool);
}
-
+
switch_mutex_unlock(conference->mutex);
} /* Rinse ... Repeat */
@@ -734,7 +731,7 @@
}
switch_mutex_unlock(conference->mutex);
-
+
/* Wait till everybody is out */
switch_clear_flag_locked(conference, CFLAG_RUNNING);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write Lock ON\n");
@@ -759,7 +756,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Inactive");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
-
+
switch_event_fire(&event);
}
switch_mutex_lock(globals.hash_mutex);
@@ -782,7 +779,7 @@
channel = switch_core_session_get_channel(member->session);
- assert(channel != NULL);
+ assert(channel != NULL);
assert(member->conference != NULL);
if (switch_core_timer_init(&timer,
@@ -804,7 +801,7 @@
if (switch_test_flag(member->conference, CFLAG_ANSWERED)) {
switch_channel_answer(channel);
}
-
+
/* Start a thread to read data and feed it into the buffer and use this thread to generate output */
launch_input_thread(member, switch_core_session_get_pool(member->session));
@@ -831,7 +828,6 @@
switch_event_destroy(&event);
}
-#if 1
if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
// test to see if outbound channel has answered
if (switch_channel_test_flag(channel, CF_ANSWERED) && !switch_test_flag(member->conference, CFLAG_ANSWERED)) {
@@ -844,10 +840,10 @@
switch_channel_answer(channel);
}
}
-#endif
- if (switch_channel_has_dtmf(channel)) {
- switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
+ if (switch_channel_has_dtmf(channel)) {
+ switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
+
for (digit = dtmf; *digit; digit++) {
switch(*digit) {
case '0':
@@ -998,7 +994,7 @@
if (member->fnode->type == NODE_TYPE_SPEECH) {
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
uint32_t rate = member->conference->rate;
-
+
if (switch_core_speech_read_tts(&member->fnode->sh,
file_frame,
&file_data_len,
@@ -1037,7 +1033,7 @@
switch_buffer_t *use_buffer = NULL;
uint32_t mux_used = (uint32_t)switch_buffer_inuse(member->mux_buffer);
//uint32_t res_used = member->mux_resampler ? switch_buffer_inuse(member->resample_buffer) : 0;
-
+
if (mux_used) {
/* Flush the output buffer and write all the data (presumably muxed) back to the channel */
switch_mutex_lock(member->audio_out_mutex);
@@ -1052,11 +1048,11 @@
if (member->volume_out_level) {
switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
}
-
+
switch_core_session_write_frame(member->session, &write_frame, -1, 0);
}
}
-
+
switch_mutex_unlock(member->audio_out_mutex);
} else {
switch_core_timer_next(&timer);
@@ -1067,7 +1063,6 @@
switch_clear_flag_locked(member, MFLAG_RUNNING);
switch_core_timer_destroy(&timer);
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel leaving conference, cause: %s\n",
switch_channel_cause2str(switch_channel_get_cause(channel)));
@@ -1082,7 +1077,6 @@
}
}
-
/* Sub-Routine called by a record entity inside a conference */
static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, void *obj)
{
@@ -1145,7 +1139,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path);
goto end;
}
-
+
if ((vval = switch_mprintf("Conference %s", rec->conference->name))) {
switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_TITLE, vval);
switch_safe_free(vval);
@@ -1175,9 +1169,8 @@
switch_core_file_close(&fh);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Recording Stopped\n");
- end:
+end:
-
if (rec->pool) {
switch_memory_pool_t *pool = rec->pool;
rec = NULL;
@@ -1191,7 +1184,6 @@
return NULL;
}
-
/* Make files stop playing in a conference either the current one or all of them */
static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop)
{
@@ -1255,8 +1247,8 @@
switch_mutex_unlock(conference->mutex);
if (!count) {
- return SWITCH_STATUS_FALSE;
- }
+ return SWITCH_STATUS_FALSE;
+ }
#ifdef WIN32
if (*(file +1) != ':' && *file != '/') {
@@ -1296,7 +1288,7 @@
/* Queue the node */
switch_mutex_lock(conference->mutex);
for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
-
+
if (nptr) {
nptr->next = fnode;
} else {
@@ -1307,7 +1299,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
/* Play a file in the conference rooom to a member */
static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin)
{
@@ -1348,7 +1339,7 @@
/* Queue the node */
switch_mutex_lock(member->flag_mutex);
for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
-
+
if (nptr) {
nptr->next = fnode;
} else {
@@ -1403,7 +1394,7 @@
/* Queue the node */
switch_mutex_lock(member->flag_mutex);
for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
-
+
if (nptr) {
nptr->next = fnode;
} else {
@@ -1430,8 +1421,8 @@
switch_mutex_lock(conference->member_mutex);
count = conference->count;
if (!(conference->tts_engine && conference->tts_voice)) {
- count = 0;
- }
+ count = 0;
+ }
switch_mutex_unlock(conference->member_mutex);
switch_mutex_unlock(conference->mutex);
@@ -1466,13 +1457,12 @@
return SWITCH_STATUS_FALSE;
}
-
fnode->pool = pool;
/* Queue the node */
switch_mutex_lock(conference->mutex);
for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
-
+
if (nptr) {
nptr->next = fnode;
} else {
@@ -1551,6 +1541,7 @@
conference_member_t *member = NULL;
switch_mutex_lock(conference->member_mutex);
+ stream->write_function(stream, "<pre>Current Callers:\n");
for (member = conference->members; member; member = member->next) {
switch_channel_t *channel;
@@ -1587,7 +1578,7 @@
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "mute-member");
@@ -1616,7 +1607,7 @@
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unmute-member");
@@ -1642,7 +1633,7 @@
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "deaf-member");
@@ -1668,7 +1659,7 @@
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "undeaf-member");
@@ -1695,11 +1686,11 @@
switch_mutex_unlock(member->flag_mutex);
stream->write_function(stream, "OK kicked %u\n", id);
-
+
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "kick-member");
@@ -1720,31 +1711,31 @@
if (member != NULL || (member = conference_member_get(conference, id))) {
switch_event_t *event;
- if (data) {
- switch_mutex_lock(member->flag_mutex);
- member->energy_level = atoi((char *)data);
- switch_mutex_unlock(member->flag_mutex);
- }
-
- stream->write_function(stream, "Energy %u=%d\n", id, member->energy_level);
+ if (data) {
+ switch_mutex_lock(member->flag_mutex);
+ member->energy_level = atoi((char *)data);
+ switch_mutex_unlock(member->flag_mutex);
+ }
- if (data) {
- if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
- switch_channel_t *channel = switch_core_session_get_channel(member->session);
- switch_channel_event_set_data(channel, event);
-
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level-member");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level);
-
- switch_event_fire(&event);
- }
+ stream->write_function(stream, "Energy %u=%d\n", id, member->energy_level);
+
+ if (data) {
+ if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_t *channel = switch_core_session_get_channel(member->session);
+ switch_channel_event_set_data(channel, event);
+
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level-member");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level);
+
+ switch_event_fire(&event);
}
- } else {
- stream->write_function(stream, "Non-Existant ID %u\n", id);
- err = 1;
}
+ } else {
+ stream->write_function(stream, "Non-Existant ID %u\n", id);
+ err = 1;
+ }
return err;
}
@@ -1762,18 +1753,18 @@
normalize_volume(member->volume_in_level);
switch_mutex_unlock(member->flag_mutex);
}
-
+
stream->write_function(stream, "Volume IN %u=%d\n", id, member->volume_in_level);
if (data) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-in-member");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_in_level);
-
+
switch_event_fire(&event);
}
}
@@ -1798,19 +1789,19 @@
normalize_volume(member->volume_out_level);
switch_mutex_unlock(member->flag_mutex);
}
-
+
stream->write_function(stream, "Volume OUT %u=%d\n", id, member->volume_out_level);
if (data) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-out-member");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_out_level);
-
+
switch_event_fire(&event);
}
}
@@ -1864,11 +1855,11 @@
switch_hash_index_t *hi;
void *val;
char *d = ";";
-
+
if (argv[1]) {
if (argv[2] && !strcasecmp(argv[1], "delim")) {
d = argv[2];
-
+
if (*d == '"') {
if (++d) {
char *p;
@@ -2007,7 +1998,7 @@
if ((tbuf = strdup(buf))) {
if ((name = strstr(tbuf, "saymember "))) {
name += 10;
-
+
if (*name) {
text = strchr(name, ' ');
id = atoi(name);
@@ -2017,7 +2008,7 @@
}
-
+
if ((member = conference_member_get(conference, id))) {
if (text && conference_member_say(conference, member, text, 0) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "(saymember) OK\n");
@@ -2037,13 +2028,13 @@
} else {
stream->write_function(stream, "(saymember) Syntax Error!");
}
-
+
free(tbuf);
goto done;
}
} else if (!strcasecmp(argv[1], "stop")) {
uint8_t current = 0, all = 0;
-
+
if (argc > 2) {
current = strcasecmp(argv[2], "current") ? 0 : 1;
all = strcasecmp(argv[2], "all") ? 0 : 1;
@@ -2072,7 +2063,7 @@
} else if (!strcasecmp(argv[1], "energy")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_energy_member(conference, NULL, id, stream, argv[3]);
@@ -2089,7 +2080,7 @@
} else if (!strcasecmp(argv[1], "volume_in")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_volume_in_member(conference, NULL, id, stream, argv[3]);
@@ -2105,7 +2096,7 @@
} else if (!strcasecmp(argv[1], "volume_out")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_volume_out_member(conference, NULL, id, stream, argv[3]);
@@ -2121,7 +2112,7 @@
} else if (!strcasecmp(argv[1], "mute")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_mute_member(conference, NULL, id, stream, NULL);
@@ -2137,7 +2128,7 @@
} else if (!strcasecmp(argv[1], "unmute")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_unmute_member(conference, NULL, id, stream, NULL);
@@ -2153,7 +2144,7 @@
} else if (!strcasecmp(argv[1], "deaf")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_deaf_member(conference, NULL, id, stream, NULL);
@@ -2169,7 +2160,7 @@
} else if (!strcasecmp(argv[1], "undeaf")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_undeaf_member(conference, NULL, id, stream, NULL);
@@ -2193,7 +2184,7 @@
}
} else if (!strcasecmp(argv[1], "norecord")) {
if (argc > 2) {
- uint8_t all = (strcasecmp(argv[2], "all") == 0 );
+ int all = (strcasecmp(argv[2], "all") == 0 );
if(!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
@@ -2206,7 +2197,7 @@
} else if (!strcasecmp(argv[1], "kick")) {
if (argc > 2) {
uint32_t id = atoi(argv[2]);
- uint8_t all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
+ int all = ( id == 0 && strcasecmp(argv[2], "all") == 0 );
if (!all) {
conference_function_kick_member(conference, NULL, id, stream, NULL);
@@ -2234,9 +2225,9 @@
stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
goto done;
}
-
+
channel = switch_core_session_get_channel(member->session);
-
+
if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[3]))) {
switch_memory_pool_t *pool;
char *conf_name;
@@ -2248,22 +2239,22 @@
}
conf_name = switch_core_strdup(pool, argv[3]);
-
+
if ((profile_name = strchr(conf_name, '@'))) {
*profile_name++ = '\0';
-
+
/* Open the config from the xml registry */
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
goto done;
}
-
+
if ((profiles = switch_xml_child(cfg, "profiles"))) {
profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
}
}
-
+
/* Release the config registry handle */
if (cxml) {
switch_xml_free(cxml);
@@ -2272,19 +2263,19 @@
/* Create the conference object. */
new_conference = conference_new(conf_name, profile, pool);
-
-
+
+
if (!new_conference) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
goto done;
}
-
+
/* Set the minimum number of members (once you go above it you cannot go below it) */
new_conference->min = 1;
-
+
/* Indicate the conference is dynamic */
switch_set_flag_locked(new_conference, CFLAG_DYNAMIC);
-
+
/* Start the conference thread for this conference */
launch_conference_thread(new_conference);
}
@@ -2292,7 +2283,7 @@
conference_del_member(member->last_conference, member);
conference_add_member(new_conference, member);
stream->write_function(stream, "OK Member %u sent to conference %s.\n", id, argv[3]);
-
+
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
@@ -2301,7 +2292,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
switch_event_fire(&event);
}
-
+
} else {
stream->write_function(stream, transfer_usage);
goto done;
@@ -2312,7 +2303,7 @@
uint8_t nospeak = 0, nohear = 0, clear = 0;
nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
nohear = strstr(argv[4], "nohear") ? 1 : 0;
-
+
if (!strcasecmp(argv[4], "clear")) {
clear = 1;
}
@@ -2326,7 +2317,7 @@
conference_member_t *member = NULL;
uint32_t id = atoi(argv[2]);
uint32_t oid = atoi(argv[3]);
-
+
switch_mutex_lock(conference->mutex);
switch_mutex_lock(conference->member_mutex);
if ((member = conference_member_get(conference, id))) {
@@ -2341,7 +2332,7 @@
conference_member_t *member = NULL, *other_member = NULL;
uint32_t id = atoi(argv[2]);
uint32_t oid = atoi(argv[3]);
-
+
switch_mutex_lock(conference->mutex);
switch_mutex_lock(conference->member_mutex);
if ((member = conference_member_get(conference, id)) && (other_member = conference_member_get(conference, oid))) {
@@ -2378,11 +2369,11 @@
}
} else if (!strcasecmp(argv[1], "list")) {
char *d = ";";
-
+
if (argv[2]) {
if (argv[3] && !strcasecmp(argv[2], "delim")) {
d = argv[3];
-
+
if (*d == '"') {
if (++d) {
char *p;
@@ -2412,12 +2403,12 @@
stream->write_function(stream, "Memory Error!\n");
}
- done:
+done:
if (lbuf) {
free(lbuf);
}
-
+
return status;
}
@@ -2482,7 +2473,7 @@
peer_channel = switch_core_session_get_channel(peer_session);
assert(peer_channel != NULL);
-
+
if (caller_channel && switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
switch_channel_answer(caller_channel);
}
@@ -2511,7 +2502,7 @@
goto done;
}
- done:
+done:
return status;
}
@@ -2524,7 +2515,7 @@
for (x = 0; x < leadin; x++) {
switch_frame_t *read_frame;
switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
-
+
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
}
@@ -2558,9 +2549,9 @@
switch_core_session_message_t msg = {0};
uint8_t isbr = 0;
char *dpin = NULL;
-
+
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ assert(channel != NULL);
if (!mydata) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
@@ -2615,7 +2606,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
goto done;
}
-
+
if ((profiles = switch_xml_child(cfg, "profiles"))) {
profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
}
@@ -2623,7 +2614,7 @@
if (isbr) {
char *uuid = switch_core_session_get_uuid(session);
-
+
if (!strcmp(conf_name, "_uuid_")) {
conf_name = uuid;
}
@@ -2661,17 +2652,17 @@
} else {
/* Create the conference object. */
conference = conference_new(conf_name, profile, pool);
-
+
if (!conference) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
goto done;
}
-
+
if (dpin) {
conference->pin = switch_core_strdup(conference->pool, dpin);
}
-
+
/* Set the minimum number of members (once you go above it you cannot go below it) */
conference->min = 1;
@@ -2721,7 +2712,6 @@
}
goto done;
}
-
}
/* Release the config registry handle */
@@ -2730,7 +2720,6 @@
cxml = NULL;
}
-
if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
if (conference_outcall(conference, session, bridgeto, 60, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
goto done;
@@ -2742,12 +2731,10 @@
switch_set_flag(conference, CFLAG_ANSWERED);
}
-
-
/* Save the original read codec. */
read_codec = switch_core_session_get_read_codec(session);
member.native_rate = read_codec->implementation->samples_per_second;
-
+
/* Setup a Signed Linear codec for reading audio. */
if (switch_core_codec_init(&member.read_codec,
"L16",
@@ -2772,14 +2759,14 @@
if (read_codec->implementation->samples_per_second != conference->rate) {
switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ?
&member.read_resampler : &member.mux_resampler;
-
+
switch_resample_create(resampler,
read_codec->implementation->samples_per_second,
read_codec->implementation->samples_per_second * 20,
conference->rate,
conference->rate * 20,
switch_core_session_get_pool(session));
-
+
/* Setup an audio buffer for the resampled audio */
if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
@@ -2806,7 +2793,7 @@
flags = 0;
goto codec_done2;
}
-
+
/* Setup an audio buffer for the incoming audio */
if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
@@ -2818,9 +2805,9 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
goto codec_done1;
}
-
+
/* Prepare MUTEXS */
member.id = next_member_id();
member.pool = pool;
@@ -2856,18 +2843,18 @@
/* Put the original codec back */
switch_core_session_set_read_codec(member.session, read_codec);
-
+
/* Clean Up. codec_done(X): is for error situations after the codecs were setup and done: is for situations before */
- codec_done1:
+codec_done1:
switch_core_codec_destroy(&member.read_codec);
- codec_done2:
+codec_done2:
switch_core_codec_destroy(&member.write_codec);
- done:
+done:
switch_buffer_destroy(&member.resample_buffer);
switch_buffer_destroy(&member.audio_buffer);
switch_buffer_destroy(&member.mux_buffer);
-
+
/* Release the config registry handle */
if (cxml) {
switch_xml_free(cxml);
@@ -2882,7 +2869,7 @@
}
switch_core_session_reset(session);
-
+
}
/* Create a thread for the conference and launch it */
@@ -2890,7 +2877,7 @@
{
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
-
+
switch_set_flag_locked(conference, CFLAG_RUNNING);
switch_threadattr_create(&thd_attr, conference->pool);
switch_threadattr_detach_set(thd_attr, 1);
@@ -2907,7 +2894,7 @@
switch_threadattr_t *thd_attr = NULL;
switch_memory_pool_t *pool;
conference_record_t *rec;
-
+
/* Setup a memory pool to use. */
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
@@ -2918,7 +2905,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
switch_core_destroy_memory_pool(&pool);
}
-
+
rec->conference = conference;
rec->path = switch_core_strdup(pool, path);
rec->pool = pool;
@@ -2947,10 +2934,10 @@
assert(member != NULL);
channel = switch_core_session_get_channel(member->session);
- assert(channel != NULL);
+ assert(channel != NULL);
read_codec = switch_core_session_get_read_codec(member->session);
- assert(read_codec != NULL);
+ assert(read_codec != NULL);
/* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it
and mux it with any audio from other channels. */
@@ -2958,7 +2945,7 @@
while(switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) {
/* Read a frame. */
status = switch_core_session_read_frame(member->session, &read_frame, -1, 0);
-
+
/* end the loop, if appropriate */
if (!SWITCH_READ_ACCEPTABLE(status) || !switch_test_flag(member, MFLAG_RUNNING)) {
break;
@@ -2981,7 +2968,7 @@
energy += abs(data[j]);
j += read_codec->implementation->number_of_channels;
}
-
+
score = energy / samples;
if (score > energy_level) {
@@ -2989,7 +2976,7 @@
if (hangover_hits) {
hangover_hits--;
}
-
+
if (diff >= diff_level || ++hangunder_hits >= hangunder) {
hangover_hits = hangunder_hits = 0;
@@ -3004,7 +2991,6 @@
switch_event_fire(&event);
}
}
-
}
} else {
if (hangunder_hits) {
@@ -3027,13 +3013,13 @@
}
}
}
-
+
/* skip frames that are not actual media or when we are muted or silent */
if ((talking || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK)) {
if (member->read_resampler) {
int16_t *bptr = (int16_t *) read_frame->data;
int len = (int) read_frame->datalen;;
-
+
member->read_resampler->from_len = switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2);
member->read_resampler->to_len = switch_resample_process(member->read_resampler, member->read_resampler->from,
member->read_resampler->from_len, member->read_resampler->to,
@@ -3054,7 +3040,7 @@
switch_mutex_unlock(member->audio_in_mutex);
}
}
-
+
switch_clear_flag_locked(member, MFLAG_ITHREAD);
return NULL;
@@ -3065,7 +3051,7 @@
{
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
-
+
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -3116,6 +3102,10 @@
conference_obj_t *conference = NULL;
switch_stream_handle_t stream = {0};
+ if (!body) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+
if (!(ci = switch_loadable_module_get_chat_interface(proto))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invaid Chat Interface [%s]!\n", proto);
}
@@ -3130,7 +3120,7 @@
ci->chat_send(CONF_CHAT_PROTO, to, from, "", "Sorry, We're Closed", "");
return SWITCH_STATUS_FALSE;
}
-
+
SWITCH_STANDARD_STREAM(stream);
if (strstr(body, "list")) {
@@ -3142,15 +3132,14 @@
ci->chat_send(CONF_CHAT_PROTO, to, from, "", stream.data, "");
switch_safe_free(stream.data);
-
+
return SWITCH_STATUS_SUCCESS;
}
-
static const switch_chat_interface_t conference_chat_interface = {
/*.name */ CONF_CHAT_PROTO,
/*.chat_send */ chat_send,
-
+
};
static switch_loadable_module_interface_t conference_module_interface = {
@@ -3217,7 +3206,7 @@
}
var = buf;
}
-
+
if (!strcasecmp(var, "rate")) {
rate_name = val;
} else if (!strcasecmp(var, "domain")) {
@@ -3280,7 +3269,7 @@
interval = i;
}
}
-
+
/* Timer module to use */
if (switch_strlen_zero(timer_name)) {
timer_name = "soft";
@@ -3304,7 +3293,7 @@
return NULL;
}
}
-
+
/* Create the conference object. */
if (!(conference = switch_core_alloc(pool, sizeof(*conference)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
@@ -3320,7 +3309,7 @@
conference->caller_id_name = switch_core_strdup(conference->pool, caller_id_name);
conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number);
-
+
if (!switch_strlen_zero(enter_sound)) {
conference->enter_sound = switch_core_strdup(conference->pool, enter_sound);
}
@@ -3392,12 +3381,10 @@
return conference;
}
-
/* Called by FreeSWITCH when the module loads */
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
- switch_xml_t cfg, xml, param, ads;
memset(&globals, 0, sizeof(globals));
@@ -3415,29 +3402,6 @@
return SWITCH_STATUS_TERM;
}
- if ((xml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
- if ((ads = switch_xml_child(cfg, "advertise"))) {
- switch_event_t *event;
-
- for (param = switch_xml_child(ads, "room"); param; param = param->next) {
- char *status = (char *) switch_xml_attr_soft(param, "status");
- char *name = (char *) switch_xml_attr_soft(param, "name");
-
- if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", name);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", name);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", status ? status : "Inactive");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
-
- switch_event_fire(&event);
- }
- }
- }
- }
-
-
/* Setup a hash to store conferences by name */
switch_core_hash_init(&globals.conference_hash, globals.conference_pool);
switch_mutex_init(&globals.conference_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
@@ -3448,7 +3412,6 @@
/* indicate that the module should continue to be loaded */
return status;
}
-
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{
Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_dptools/mod_dptools.c Sun Oct 22 16:46:47 2006
@@ -60,6 +60,11 @@
}
}
+static void eval_function(switch_core_session_t *session, char *data)
+{
+ return;
+}
+
static void answer_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
@@ -165,14 +170,89 @@
return SWITCH_STATUS_SUCCESS;
}
+static switch_status_t presence_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+ switch_event_t *event;
+ char *lbuf, *argv[4];
+ int argc = 0;
+ switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
+
+ if ((lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
+ if (!strcasecmp(argv[0], "out")) {
+ type = SWITCH_EVENT_PRESENCE_OUT;
+ } else if (argc != 4) {
+ stream->write_function(stream, "Invalid");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "dp");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", __FILE__);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", argv[1]);
+ if (type == SWITCH_EVENT_PRESENCE_IN) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", argv[2]);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", argv[3]);
+ }
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+ switch_event_fire(&event);
+ }
+ stream->write_function(stream, "Event Sent");
+ switch_safe_free(lbuf);
+ } else {
+ stream->write_function(stream, "Invalid");
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t chat_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+ char *lbuf, *argv[4];
+ int argc = 0;
+
+ if ((lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
+ switch_chat_interface_t *ci;
+
+ if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) {
+ ci->chat_send("dp", argv[1], argv[2], "", argv[3], "");
+ stream->write_function(stream, "Sent");
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invaid Chat Interface [%s]!\n", argv[0]);
+ }
+ } else {
+ stream->write_function(stream, "Invalid");
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_api_interface_t chat_api_interface = {
+ /*.interface_name */ "chat",
+ /*.desc */ "chat",
+ /*.function */ chat_api_function,
+ /*.syntax */ "<proto>|<from>|<to>|<message>",
+ /*.next */ NULL
+};
+
static switch_api_interface_t dptools_api_interface = {
/*.interface_name */ "strftime",
/*.desc */ "strftime",
/*.function */ strftime_api_function,
/*.syntax */ "<format_string>",
- /*.next */ NULL
+ /*.next */ &chat_api_interface
};
+
+static switch_api_interface_t presence_api_interface = {
+ /*.interface_name */ "presence",
+ /*.desc */ "presence",
+ /*.function */ presence_api_function,
+ /*.syntax */ "<user> <rpid> <message>",
+ /*.next */ &dptools_api_interface
+};
+
static const switch_application_interface_t set_application_interface = {
/*.interface_name */ "set",
/*.application_function */ set_function,
@@ -192,13 +272,23 @@
};
+static const switch_application_interface_t eval_application_interface = {
+ /*.interface_name */ "eval",
+ /*.application_function */ eval_function,
+ /* long_desc */ "Do Nothing",
+ /* short_desc */ "Do Nothing",
+ /* syntax */ "",
+ /*.next */ &answer_application_interface
+
+};
+
static const switch_application_interface_t strftime_application_interface = {
/*.interface_name */ "strftime",
/*.application_function */ strftime_function,
/* long_desc */ NULL,
/* short_desc */ NULL,
/* syntax */ NULL,
- /*.next */ &answer_application_interface
+ /*.next */ &eval_application_interface
};
@@ -236,7 +326,7 @@
/*.dialplan_interface = */ NULL,
/*.codec_interface = */ NULL,
/*.application_interface */ &privacy_application_interface,
- /*.api_interface */ &dptools_api_interface
+ /*.api_interface */ &presence_api_interface
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_playback/mod_playback.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_playback/mod_playback.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_playback/mod_playback.c Sun Oct 22 16:46:47 2006
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II <anthmct at yahoo.com>
+ * Neal Horman <neal at wanlink dot com>
*
*
* mod_playback.c -- Raw Audio File Streaming Application Module
@@ -126,6 +127,7 @@
static void record_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
+ switch_status_t status;
channel = switch_core_session_get_channel(session);
switch_status_t status;
assert(channel != NULL);
Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_skel/mod_skel.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_skel/mod_skel.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_skel/mod_skel.c Sun Oct 22 16:46:47 2006
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II <anthmct at yahoo.com>
+ * Neal Horman <neal at wanlink dot com>
*
*
* mod_skel.c -- Framework Demo Module
Modified: freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Sun Oct 22 16:46:47 2006
@@ -465,6 +465,29 @@
return 0;
}
+
+static int sin_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+ struct mdl_profile *profile = (struct mdl_profile *) pArg;
+ switch_event_t *event;
+
+ //char *sub_from = argv[0];
+ char *sub_to = argv[1];
+
+ if (strstr(sub_to, "ext+") || strstr(sub_to, "user+") || strstr(sub_to, "conf+")) {
+ if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", sub_to);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "available");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Online");
+ switch_event_fire(&event);
+ }
+ }
+
+ return 0;
+}
+
static void sign_off(void)
{
struct mdl_profile *profile = NULL;
@@ -505,6 +528,25 @@
}
+static void sign_on(struct mdl_profile *profile)
+{
+ char *sql;
+ switch_core_db_t *db;
+ char *errmsg;
+
+ if ((sql = switch_mprintf("select * from subscriptions where sub_to like 'ext+%%' or sub_to like 'user+%%' or sub_to like 'conf+%%'"))) {
+ if (!(db = switch_core_db_open_file(profile->dbname))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+ return;
+ }
+ switch_mutex_lock(profile->mutex);
+ switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
+ switch_mutex_unlock(profile->mutex);
+ switch_core_db_close(db);
+ switch_safe_free(sql);
+ }
+}
+
static void terminate_session(switch_core_session_t **session, int line, switch_call_cause_t cause)
{
if (*session) {
@@ -1482,7 +1524,7 @@
if (outbound_profile) {
char name[128];
- snprintf(name, sizeof(name), "DingaLing/%s-%04x", outbound_profile->destination_number, rand() & 0xffff);
+ snprintf(name, sizeof(name), "DingaLing/%s", outbound_profile->destination_number);
switch_channel_set_name(channel, name);
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
@@ -1930,6 +1972,72 @@
}
}
+static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
+{
+ char *params = NULL, *real_to, *to_user, *xmlstr = NULL, *to_host = NULL;
+ switch_xml_t domain, xml = NULL, user, vcard;
+
+ if (!strncasecmp(to, "user+", 5)) {
+ real_to = to + 5;
+ } else {
+ real_to = to;
+ }
+
+
+ if ((to_user = strdup(real_to))) {
+ if ((to_host = strchr(to_user, '@'))) {
+ *to_host++ = '\0';
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ goto end;
+ }
+
+ if (!to_host) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Missing Host!\n");
+ goto end;
+ }
+
+ if (!(params = switch_mprintf("to=%s@%s&from=%s&object=vcard",
+ to_user,
+ to_host,
+ from
+ ))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ goto end;
+ }
+
+
+ if (switch_xml_locate("directory", "domain", "name", to_host, &xml, &domain, params) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "can't find domain for [%s@%s]\n", to_user, to_host);
+ goto end;
+ }
+
+ if (!(user = switch_xml_find_child(domain, "user", "id", to_user))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", to_user, to_host);
+ goto end;
+ }
+
+ if (!(vcard = switch_xml_child(user, "vcard"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find <vcard> tag for user [%s@%s]\n", to_user, to_host);
+ goto end;
+ }
+
+ switch_xml_set_attr(vcard, "xmlns", "vcard-tmp");
+
+ if ((xmlstr = switch_xml_toxml(vcard))) {
+ ldl_handle_send_vcard(handle, to, from, id, xmlstr);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ }
+
+ end:
+ if (xml) switch_xml_free(xml);
+ switch_safe_free(to_user);
+ switch_safe_free(params);
+ switch_safe_free(xmlstr);
+}
+
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t signal, char *to, char *from, char *subject, char *msg)
{
struct mdl_profile *profile = NULL;
@@ -1951,6 +2059,9 @@
if (!dlsession) {
if (profile->user_flags & LDL_FLAG_COMPONENT) {
switch(signal) {
+ case LDL_SIGNAL_VCARD:
+ do_vcard(handle, to, from, subject);
+ break;
case LDL_SIGNAL_UNSUBSCRIBE:
if ((sql = switch_mprintf("delete from subscriptions where sub_from='%q' and sub_to='%q';", from, to))) {
@@ -1966,7 +2077,16 @@
execute_sql(profile->dbname, sql, profile->mutex);
switch_core_db_free(sql);
}
-
+ if (strstr(to, "ext+") || strstr(to, "user+") || strstr(to, "conf+") ) {
+ if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Click To Call");
+ switch_event_fire(&event);
+ }
+ }
break;
case LDL_SIGNAL_ROSTER:
if (switch_event_create(&event, SWITCH_EVENT_ROSTER) == SWITCH_STATUS_SUCCESS) {
@@ -1991,6 +2111,16 @@
switch_event_fire(&event);
}
+ if (strstr(to, "ext+") || strstr(to, "user+") || strstr(to, "conf+")) {
+ if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Click To Call");
+ switch_event_fire(&event);
+ }
+ }
break;
case LDL_SIGNAL_PRESENCE_OUT:
@@ -2054,6 +2184,10 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
switch_event_fire(&event);
}
+ if (profile->user_flags & LDL_FLAG_COMPONENT) {
+ sign_on(profile);
+ }
+
break;
case LDL_SIGNAL_LOGIN_FAILURE:
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_FAILURE) == SWITCH_STATUS_SUCCESS) {
@@ -2309,6 +2443,7 @@
if (!(exten = ldl_session_get_value(dlsession, "dnis"))) {
exten = profile->exten;
+ /* if it's _auto_ set the extension to match the username portion of the called address */
if (!strcmp(exten, "_auto_")) {
if ((t = ldl_session_get_callee(dlsession))) {
if ((them = strdup(t))) {
@@ -2318,14 +2453,18 @@
}
if ((a = strchr(them, '+')) && (b = strrchr(them, '+')) && a != b) {
- *b = '@';
+ *b++ = '\0';
+ switch_channel_set_variable(channel, "dl_user", them);
+ switch_channel_set_variable(channel, "dl_host", b);
}
exten = them;
}
}
}
}
-
+
+
+
if (!(context = ldl_session_get_value(dlsession, "context"))) {
context = profile->context;
}
@@ -2337,6 +2476,11 @@
if (!(cid_num = ldl_session_get_value(dlsession, "caller_id_number"))) {
cid_num = tech_pvt->recip;
}
+
+ /* context of "_auto_" means set it to the domain */
+ if (profile->context && !strcmp(profile->context, "_auto_")) {
+ context = profile->name;
+ }
if (!tech_pvt->caller_profile) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating an identity for %s %s <%s> %s\n",
@@ -2355,7 +2499,7 @@
context,
exten)) != 0) {
char name[128];
- snprintf(name, sizeof(name), "DingaLing/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
+ snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
switch_channel_set_name(channel, name);
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
}
Modified: freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Sun Oct 22 16:46:47 2006
@@ -2127,8 +2127,10 @@
const char *subject = "n/a";
char *msg = NULL;
- if (strstr((char*)sip->sip_content_type->c_subtype, "composing")) {
- return;
+ if (sip->sip_content_type) {
+ if (strstr((char*)sip->sip_content_type->c_subtype, "composing")) {
+ return;
+ }
}
if (from) {
@@ -2612,7 +2614,7 @@
sip_expires_t const *expires = sip->sip_expires;
sip_authorization_t const *authorization = sip->sip_authorization;
sip_contact_t const *contact = sip->sip_contact;
- switch_xml_t domain, xml, user, param;
+ switch_xml_t domain, xml, user, param, xparams;
char params[1024] = "";
char *sql;
switch_event_t *s_event;
@@ -2693,9 +2695,16 @@
switch_xml_free(xml);
return 1;
}
+
+ if ((xparams = switch_xml_child(user, "params"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find params for user [%s@%s]\n", from_user, from_host);
+ nua_respond(nh, SIP_401_UNAUTHORIZED, SIPTAG_CONTACT(contact), TAG_END());
+ switch_xml_free(xml);
+ return 1;
+ }
- for (param = switch_xml_child(user, "param"); param; param = param->next) {
+ for (param = switch_xml_child(xparams, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
@@ -2887,10 +2896,15 @@
char *host = argv[1];
char *status = argv[2];
char *rpid = argv[3];
+ char *proto = argv[4];
switch_event_t *event;
+ if (switch_strlen_zero(proto)) {
+ proto = NULL;
+ }
+
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", proto ? proto : SOFIA_CHAT_PROTO);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", user, host);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status);
@@ -3013,6 +3027,7 @@
switch_core_db_t *db;
char *errmsg;
char *sstr;
+ switch_event_t *sevent;
if (from) {
from_user = (char *) from->a_url->url_user;
@@ -3045,6 +3060,26 @@
to_host = (char *) to->a_url->url_host;
}
+
+ if (strstr(to_user, "ext+") || strstr(to_user, "user+") || strstr(to_user, "conf+")) {
+ char proto[80];
+ char *p;
+
+ switch_copy_string(proto, to_user, sizeof(proto));
+ if ((p = strchr(proto, '+'))) {
+ *p = '\0';
+ }
+
+ if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
+ switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
+ switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host);
+ switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "rpid", "unknown");
+ switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "status", "Click To Call");
+ switch_event_fire(&sevent);
+ }
+ }
+
if (strchr(to_user, '+')) {
char *h;
if ((proto = (d_user = strdup(to_user)))) {
@@ -3121,7 +3156,7 @@
}
switch_core_db_close(db);
end:
-
+
if (event) {
su_free(profile->home, event);
}
@@ -3769,22 +3804,27 @@
return;
}
- if (sip->sip_www_authenticate) {
- authenticate = sip->sip_www_authenticate;
- } else if (sip->sip_proxy_authenticate) {
- authenticate = sip->sip_proxy_authenticate;
- }
-
if (status == 200) {
if (sofia_private->oreg) {
oreg->state = REG_STATE_REGISTER;
nua_handle_destroy(nh);
}
- } else if (authenticate) {
+ } else if (status == 401 || status == 407) {
char const *realm = (char const *) *authenticate->au_params;
char const *scheme = (char const *) authenticate->au_scheme;
char authentication[256] = "";
int ss_state;
+
+
+ if (sip->sip_www_authenticate) {
+ authenticate = sip->sip_www_authenticate;
+ } else if (sip->sip_proxy_authenticate) {
+ authenticate = sip->sip_proxy_authenticate;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Missing Authenticate Header!\n");
+ return;
+ }
+
snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, strstr(realm, "=") + 1,
oreg->register_username,
@@ -4623,13 +4663,21 @@
return;
}
- if ((sql = switch_mprintf("select user,host,'Registered','unavailable' from sip_registrations"))) {
+ if ((sql = switch_mprintf("select user,host,'Registered','unknown','' from sip_registrations"))) {
switch_mutex_lock(profile->ireg_mutex);
switch_core_db_exec(db, sql, resub_callback, profile, &errmsg);
switch_mutex_unlock(profile->ireg_mutex);
switch_safe_free(sql);
}
+ if ((sql = switch_mprintf("select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions "
+ "where proto='ext' or proto='user' or proto='conf'"))) {
+ switch_mutex_lock(profile->ireg_mutex);
+ switch_core_db_exec(db, sql, resub_callback, profile, &errmsg);
+ switch_mutex_unlock(profile->ireg_mutex);
+ switch_safe_free(sql);
+ }
+
switch_core_db_close(db);
}
@@ -4747,7 +4795,11 @@
if ((user = strdup(from))) {
if ((host = strchr(user, '@'))) {
+ char *p;
*host++ = '\0';
+ if ((p = strchr(host, '/'))) {
+ *p = '\0';
+ }
} else {
switch_safe_free(user);
return;
Modified: freeswitch/branches/knhor/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Sun Oct 22 16:46:47 2006
@@ -555,7 +555,7 @@
acs.bg = 0;
api_exec(NULL, (void *) &acs);
- snprintf(reply, reply_len, "+OK");
+ //snprintf(reply, reply_len, "+OK");
return SWITCH_STATUS_SUCCESS;
} else if (!strncasecmp(cmd, "bgapi ", 6)) {
Modified: freeswitch/branches/knhor/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c Sun Oct 22 16:46:47 2006
@@ -73,6 +73,8 @@
}
if (mode & SFM_WRITE) {
+ sf_count_t frames = 0 ;
+
context->sfinfo.channels = handle->channels;
context->sfinfo.samplerate = handle->samplerate;
if (handle->samplerate == 8000 || handle->samplerate == 16000) {
@@ -82,6 +84,8 @@
} else if (handle->samplerate == 32000) {
context->sfinfo.format |= SF_FORMAT_PCM_32;
}
+
+ sf_command (context->handle, SFC_FILE_TRUNCATE, &frames, sizeof (frames)) ;
/* Could add more else if() but i am too lazy atm.. */
if (!strcasecmp(ext, "wav")) {
Modified: freeswitch/branches/knhor/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/switch_channel.c (original)
+++ freeswitch/branches/knhor/trunk/src/switch_channel.c Sun Oct 22 16:46:47 2006
@@ -305,6 +305,38 @@
return SWITCH_STATUS_SUCCESS;
}
+SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, char *rpid, char *status)
+{
+ char *id = switch_channel_get_variable(channel, "presence_id");
+ switch_event_t *event;
+ switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
+
+ if (!status) {
+ type = SWITCH_EVENT_PRESENCE_OUT;
+ }
+
+ if (!id) {
+ return;
+ }
+
+ if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", __FILE__);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", __FILE__);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", id);
+ if (type == SWITCH_EVENT_PRESENCE_IN) {
+ if (!rpid) {
+ rpid = "unknown";
+ }
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status);
+ }
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+ switch_event_fire(&event);
+ }
+
+}
+
+
SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, char *varname)
{
char *v;
@@ -589,7 +621,9 @@
if (ok) {
-
+ if (state > CS_RING) {
+ switch_channel_presence(channel, "unknown", (char*)state_names[state]);
+ }
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n",
channel->name,
state_names[last_state],
@@ -928,6 +962,8 @@
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
+
+ switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause));
switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL);
switch_core_session_signal_state_change(channel->session);
Modified: freeswitch/branches/knhor/trunk/src/switch_core.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/switch_core.c (original)
+++ freeswitch/branches/knhor/trunk/src/switch_core.c Sun Oct 22 16:46:47 2006
@@ -2536,6 +2536,16 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", expanded);
switch_event_fire(&event);
}
+
+
+ if (switch_channel_get_variable(session->channel, "presence_id")) {
+ char *arg = switch_mprintf("%s(%s)", extension->current_application->application_name, expanded);
+ if (arg) {
+ switch_channel_presence(session->channel, "unknown", arg);
+ switch_safe_free(arg);
+ }
+ }
+
application_interface->application_function(session, expanded);
if (expanded != extension->current_application->application_data) {
More information about the Freeswitch-branches
mailing list