aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs29
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs48
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs8
3 files changed, 51 insertions, 34 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs
index c05d598..b1f93e9 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs
@@ -26,7 +26,9 @@
26 */ 26 */
27 27
28using log4net; 28using log4net;
29using System;
29using System.Reflection; 30using System.Reflection;
31using System.Text;
30using System.Collections; 32using System.Collections;
31 33
32namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice 34namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
@@ -37,7 +39,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
37 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38 40
39 41
40 public Hashtable HandleDialplanRequest(Hashtable request) 42 public Hashtable HandleDialplanRequest(string Context, string Realm, Hashtable request)
41 { 43 {
42 m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString()); 44 m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString());
43 45
@@ -48,33 +50,39 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
48 m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); 50 m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value);
49 } 51 }
50 52
53 string requestcontext = (string) request["Hunt-Context"];
51 response["content_type"] = "text/xml"; 54 response["content_type"] = "text/xml";
52 response["keepalive"] = false; 55 response["keepalive"] = false;
53 response["int_response_code"] = 200; 56 response["int_response_code"] = 200;
54 response["str_response_string"] = @"<?xml version=""1.0"" encoding=""utf-8""?> 57 if ( Context != String.Empty && Context != requestcontext)
58 {
59 m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context");
60 response["str_response_string"] = "";
61 } else {
62 response["str_response_string"] = String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
55 <document type=""freeswitch/xml""> 63 <document type=""freeswitch/xml"">
56 <section name=""dialplan""> 64 <section name=""dialplan"">
57 <context name=""default""> 65 <context name=""{0}"">" +
58 66
59 <!-- dial via SIP uri --> 67/* <!-- dial via SIP uri -->
60 <extension name=""sip_uri""> 68 <extension name=""sip_uri"">
61 <condition field=""destination_number"" expression=""^sip:(.*)$""> 69 <condition field=""destination_number"" expression=""^sip:(.*)$"">
62 <action application=""bridge"" data=""sofia/${use_profile}/$1""/> 70 <action application=""bridge"" data=""sofia/${use_profile}/$1""/>
63 <!--<action application=""bridge"" data=""$1""/>--> 71 <!--<action application=""bridge"" data=""$1""/>-->
64 </condition> 72 </condition>
65 </extension> 73 </extension>*/
66 74
67 <extension name=""opensim_conferences""> 75 @"<extension name=""opensim_conferences"">
68 <condition field=""destination_number"" expression=""^confctl-(.*)$""> 76 <condition field=""destination_number"" expression=""^confctl-(.*)$"">
69 <action application=""answer""/> 77 <action application=""answer""/>
70 <action application=""conference"" data=""$1-${domain_name}@default""/> 78 <action application=""conference"" data=""$1-{1}@{0}""/>
71 </condition> 79 </condition>
72 </extension> 80 </extension>
73 81
74 <extension name=""opensim_conf""> 82 <extension name=""opensim_conf"">
75 <condition field=""destination_number"" expression=""^conf-(.*)$""> 83 <condition field=""destination_number"" expression=""^conf-(.*)$"">
76 <action application=""answer""/> 84 <action application=""answer""/>
77 <action application=""conference"" data=""$1-${domain_name}@default""/> 85 <action application=""conference"" data=""$1-{1}@{0}""/>
78 </condition> 86 </condition>
79 </extension> 87 </extension>
80 88
@@ -86,7 +94,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
86 94
87 </context> 95 </context>
88 </section> 96 </section>
89 </document>"; 97 </document>", Context, Realm);
98 }
90 99
91 return response; 100 return response;
92 } 101 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs
index 0a9f69d..8afaeea 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs
@@ -38,12 +38,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
38 private static readonly ILog m_log = 38 private static readonly ILog m_log =
39 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 40
41 public Hashtable HandleDirectoryRequest(Hashtable request) 41 public Hashtable HandleDirectoryRequest(string Context, string Realm, Hashtable request)
42 { 42 {
43 Hashtable response = new Hashtable();
44 string domain = (string) request["domain"];
45 if ( domain != Realm) {
46 response["content_type"] = "text/xml";
47 response["keepalive"] = false;
48 response["int_response_code"] = 200;
49 response["str_response_string"] = "";
50 } else {
43 m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); 51 m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString());
44 52
45 Hashtable response = new Hashtable();
46
47 // information in the request we might be interested in 53 // information in the request we might be interested in
48 54
49 // Request 1 sip_auth for users account 55 // Request 1 sip_auth for users account
@@ -85,11 +91,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
85 91
86 if (sipAuthMethod == "REGISTER") 92 if (sipAuthMethod == "REGISTER")
87 { 93 {
88 response = HandleRegister(request); 94 response = HandleRegister(Context, Realm, request);
89 } 95 }
90 else if (sipAuthMethod == "INVITE") 96 else if (sipAuthMethod == "INVITE")
91 { 97 {
92 response = HandleInvite(request); 98 response = HandleInvite(Context, Realm, request);
93 } 99 }
94 else 100 else
95 { 101 {
@@ -101,19 +107,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
101 } 107 }
102 else if (eventCallingFunction == "switch_xml_locate_user") 108 else if (eventCallingFunction == "switch_xml_locate_user")
103 { 109 {
104 response = HandleLocateUser(request); 110 response = HandleLocateUser(Realm, request);
105 } 111 }
106 else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made 112 else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made
107 { 113 {
108 response = HandleLocateUser(request); 114 response = HandleLocateUser(Realm, request);
109 } 115 }
110 else if (eventCallingFunction == "user_outgoing_channel") 116 else if (eventCallingFunction == "user_outgoing_channel")
111 { 117 {
112 response = HandleRegister(request); 118 response = HandleRegister(Context, Realm, request);
113 } 119 }
114 else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup 120 else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup
115 { 121 {
116 response = HandleConfigSofia(request); 122 response = HandleConfigSofia(Context, Realm, request);
117 } 123 }
118 else if (eventCallingFunction == "switch_load_network_lists") 124 else if (eventCallingFunction == "switch_load_network_lists")
119 { 125 {
@@ -131,10 +137,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
131 response["content_type"] = "text/xml"; 137 response["content_type"] = "text/xml";
132 response["str_response_string"] = ""; 138 response["str_response_string"] = "";
133 } 139 }
140 }
134 return response; 141 return response;
135 } 142 }
136 143
137 private Hashtable HandleRegister(Hashtable request) 144 private Hashtable HandleRegister(string Context, string Realm, Hashtable request)
138 { 145 {
139 m_log.Info("[FreeSwitchDirectory] HandleRegister called"); 146 m_log.Info("[FreeSwitchDirectory] HandleRegister called");
140 147
@@ -159,19 +166,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
159 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${{dialed_user}}@${{dialed_domain}}}}${{sofia_contact(${{dialed_user}}@${{dialed_domain}})}}\"/>\r\n" + 166 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${{dialed_user}}@${{dialed_domain}}}}${{sofia_contact(${{dialed_user}}@${{dialed_domain}})}}\"/>\r\n" +
160 "</params>\r\n" + 167 "</params>\r\n" +
161 "<variables>\r\n" + 168 "<variables>\r\n" +
162 "<variable name=\"user_context\" value=\"default\" />\r\n" + 169 "<variable name=\"user_context\" value=\"{3}\" />\r\n" +
163 "<variable name=\"presence_id\" value=\"{1}@{0}\"/>"+ 170 "<variable name=\"presence_id\" value=\"{1}@{0}\"/>"+
164 "</variables>\r\n" + 171 "</variables>\r\n" +
165 "</user>\r\n" + 172 "</user>\r\n" +
166 "</domain>\r\n" + 173 "</domain>\r\n" +
167 "</section>\r\n" + 174 "</section>\r\n" +
168 "</document>\r\n", 175 "</document>\r\n",
169 domain , user, password); 176 domain , user, password, Context);
170 177
171 return response; 178 return response;
172 } 179 }
173 180
174 private Hashtable HandleInvite(Hashtable request) 181 private Hashtable HandleInvite(string Context, string Realm, Hashtable request)
175 { 182 {
176 m_log.Info("[FreeSwitchDirectory] HandleInvite called"); 183 m_log.Info("[FreeSwitchDirectory] HandleInvite called");
177 184
@@ -196,7 +203,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
196 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${1}@${{dialed_domain}}}}${{sofia_contact(${1}@${{dialed_domain}})}}\"/>\r\n" + 203 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${1}@${{dialed_domain}}}}${{sofia_contact(${1}@${{dialed_domain}})}}\"/>\r\n" +
197 "</params>\r\n" + 204 "</params>\r\n" +
198 "<variables>\r\n" + 205 "<variables>\r\n" +
199 "<variable name=\"user_context\" value=\"default\" />\r\n" + 206 "<variable name=\"user_context\" value=\"{4}\" />\r\n" +
200 "<variable name=\"presence_id\" value=\"{1}@$${{domain}}\"/>"+ 207 "<variable name=\"presence_id\" value=\"{1}@$${{domain}}\"/>"+
201 "</variables>\r\n" + 208 "</variables>\r\n" +
202 "</user>\r\n" + 209 "</user>\r\n" +
@@ -206,20 +213,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
206 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${3}@${{dialed_domain}}}}${{sofia_contact(${3}@${{dialed_domain}})}}\"/>\r\n" + 213 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${3}@${{dialed_domain}}}}${{sofia_contact(${3}@${{dialed_domain}})}}\"/>\r\n" +
207 "</params>\r\n" + 214 "</params>\r\n" +
208 "<variables>\r\n" + 215 "<variables>\r\n" +
209 "<variable name=\"user_context\" value=\"default\" />\r\n" + 216 "<variable name=\"user_context\" value=\"{4}\" />\r\n" +
210 "<variable name=\"presence_id\" value=\"{3}@$${{domain}}\"/>"+ 217 "<variable name=\"presence_id\" value=\"{3}@$${{domain}}\"/>"+
211 "</variables>\r\n" + 218 "</variables>\r\n" +
212 "</user>\r\n" + 219 "</user>\r\n" +
213 "</domain>\r\n" + 220 "</domain>\r\n" +
214 "</section>\r\n" + 221 "</section>\r\n" +
215 "</document>\r\n", 222 "</document>\r\n",
216 domain , user, password,sipRequestUser); 223 domain , user, password,sipRequestUser, Context);
217 224
218 return response; 225 return response;
219 } 226 }
220 227
221 228 private Hashtable HandleLocateUser(String Realm, Hashtable request)
222 private Hashtable HandleLocateUser(Hashtable request)
223 { 229 {
224 m_log.Info("[FreeSwitchDirectory] HandleLocateUser called"); 230 m_log.Info("[FreeSwitchDirectory] HandleLocateUser called");
225 231
@@ -253,7 +259,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
253 return response; 259 return response;
254 } 260 }
255 261
256 private Hashtable HandleConfigSofia(Hashtable request) 262 private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request)
257 { 263 {
258 m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called"); 264 m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called");
259 265
@@ -286,7 +292,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
286 "<param name=\"retry-seconds\" value=\"30\"/>\r\n"+ 292 "<param name=\"retry-seconds\" value=\"30\"/>\r\n"+
287 "<param name=\"extension\" value=\"$${{default_provider_contact}}\"/>\r\n"+ 293 "<param name=\"extension\" value=\"$${{default_provider_contact}}\"/>\r\n"+
288 "<param name=\"contact-params\" value=\"domain_name=$${{domain}}\"/>\r\n"+ 294 "<param name=\"contact-params\" value=\"domain_name=$${{domain}}\"/>\r\n"+
289 "<param name=\"context\" value=\"public\"/>\r\n"+ 295 "<param name=\"context\" value=\"{1}\"/>\r\n"+
290 "</gateway>\r\n"+ 296 "</gateway>\r\n"+
291 "</gateways>\r\n"+ 297 "</gateways>\r\n"+
292 "<params>\r\n"+ 298 "<params>\r\n"+
@@ -301,7 +307,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
301 "</domain>\r\n" + 307 "</domain>\r\n" +
302 "</section>\r\n" + 308 "</section>\r\n" +
303 "</document>\r\n", 309 "</document>\r\n",
304 domain); 310 domain, Context);
305 311
306 return response; 312 return response;
307 } 313 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index f9cb1c4..faa0157 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -95,6 +95,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
95 // private static IPEndPoint m_FreeSwitchServiceIP; 95 // private static IPEndPoint m_FreeSwitchServiceIP;
96 private int m_freeSwitchServicePort; 96 private int m_freeSwitchServicePort;
97 private string m_openSimWellKnownHTTPAddress; 97 private string m_openSimWellKnownHTTPAddress;
98 private string m_freeSwitchContext;
98 99
99 private FreeSwitchDirectory m_FreeSwitchDirectory; 100 private FreeSwitchDirectory m_FreeSwitchDirectory;
100 private FreeSwitchDialplan m_FreeSwitchDialplan; 101 private FreeSwitchDialplan m_FreeSwitchDialplan;
@@ -151,6 +152,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
151 m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); 152 m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000);
152 // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); 153 // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120);
153 m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); 154 m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty);
155 m_freeSwitchContext = m_config.GetString("freeswitch_context", "default");
154 156
155 if (String.IsNullOrEmpty(m_freeSwitchServerUser) || 157 if (String.IsNullOrEmpty(m_freeSwitchServerUser) ||
156 String.IsNullOrEmpty(m_freeSwitchServerPass) || 158 String.IsNullOrEmpty(m_freeSwitchServerPass) ||
@@ -572,7 +574,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
572 "<App.NoBottomLogo>false</App.NoBottomLogo>\r\n"+ 574 "<App.NoBottomLogo>false</App.NoBottomLogo>\r\n"+
573 "</VCConfiguration>", 575 "</VCConfiguration>",
574 m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, 576 m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN,
575 m_freeSwitchSTUNServer, m_freeSwitchEchoServer, m_freeSwitchEchoPort, 577 m_freeSwitchEchoServer, m_freeSwitchEchoPort,
576 m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, 578 m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout,
577 m_freeSwitchUrlResetPassword, ""); 579 m_freeSwitchUrlResetPassword, "");
578 580
@@ -728,9 +730,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
728 string section = (string) requestBody["section"]; 730 string section = (string) requestBody["section"];
729 731
730 if (section == "directory") 732 if (section == "directory")
731 response = m_FreeSwitchDirectory.HandleDirectoryRequest(requestBody); 733 response = m_FreeSwitchDirectory.HandleDirectoryRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody);
732 else if (section == "dialplan") 734 else if (section == "dialplan")
733 response = m_FreeSwitchDialplan.HandleDialplanRequest(requestBody); 735 response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody);
734 else 736 else
735 m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); 737 m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section);
736 738