Finish the standalone mode freeswitch work and add config examples

viewer-2-initial-appearance
Melanie 2010-11-21 23:24:39 +00:00
parent a7174cecdd
commit 2105842513
3 changed files with 69 additions and 76 deletions

View File

@ -37,6 +37,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using Nwc.XmlRpc; using Nwc.XmlRpc;
@ -50,6 +51,9 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps; using Caps = OpenSim.Framework.Capabilities.Caps;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OSDMap = OpenMetaverse.StructuredData.OSDMap;
namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
{ {
@ -58,8 +62,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool UseProxy = false;
// Capability string prefixes // Capability string prefixes
private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; private static readonly string m_parcelVoiceInfoRequestPath = "0007/";
private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
@ -70,8 +72,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
// FreeSwitch server is going to contact us and ask us all // FreeSwitch server is going to contact us and ask us all
// sorts of things. // sorts of things.
private static string m_freeSwitchServerUser;
private static string m_freeSwitchServerPass;
// SLVoice client will do a GET on this prefix // SLVoice client will do a GET on this prefix
private static string m_freeSwitchAPIPrefix; private static string m_freeSwitchAPIPrefix;
@ -85,73 +85,69 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
private static string m_freeSwitchRealm; private static string m_freeSwitchRealm;
private static string m_freeSwitchSIPProxy; private static string m_freeSwitchSIPProxy;
private static bool m_freeSwitchAttemptUseSTUN; private static bool m_freeSwitchAttemptUseSTUN;
// private static string m_freeSwitchSTUNServer;
private static string m_freeSwitchEchoServer; private static string m_freeSwitchEchoServer;
private static int m_freeSwitchEchoPort; private static int m_freeSwitchEchoPort;
private static string m_freeSwitchDefaultWellKnownIP; private static string m_freeSwitchDefaultWellKnownIP;
private static int m_freeSwitchDefaultTimeout; private static int m_freeSwitchDefaultTimeout;
// private static int m_freeSwitchSubscribeRetry;
private static string m_freeSwitchUrlResetPassword; private static string m_freeSwitchUrlResetPassword;
// private static IPEndPoint m_FreeSwitchServiceIP; private uint m_freeSwitchServicePort;
private int m_freeSwitchServicePort;
private string m_openSimWellKnownHTTPAddress; private string m_openSimWellKnownHTTPAddress;
private string m_freeSwitchContext; private string m_freeSwitchContext;
private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>();
private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>();
private Scene m_scene; private Scene m_Scene;
private IConfig m_Config;
private IConfig m_config; private IFreeswitchService m_FreeswitchService;
public void Initialise(IConfigSource config) public void Initialise(IConfigSource config)
{ {
m_config = config.Configs["FreeSwitchVoice"]; m_Config = config.Configs["FreeSwitchVoice"];
if (null == m_config) if (m_Config == null)
{ {
m_log.Info("[FreeSwitchVoice] no config found, plugin disabled"); m_log.Info("[FreeSwitchVoice] no config found, plugin disabled");
return; return;
} }
if (!m_config.GetBoolean("enabled", false)) if (!m_Config.GetBoolean("Enabled", false))
{ {
m_log.Info("[FreeSwitchVoice] plugin disabled by configuration"); m_log.Info("[FreeSwitchVoice] plugin disabled by configuration");
return; return;
} }
m_Enabled = true;
try try
{ {
m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); string serviceDll = m_Config.GetString("LocalServiceModule",
m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); String.Empty);
m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty);
// XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) if (serviceDll == String.Empty)
{
m_log.Error("[FreeSwitchVoice]: No LocalServiceModule named in section FreeSwitchVoice");
return;
}
string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); Object[] args = new Object[] { config };
int servicePort = m_config.GetInt("freeswitch_service_port", 80); m_FreeswitchService = ServerUtils.LoadPlugin<IFreeswitchService>(serviceDll, args);
IPAddress serviceIPAddress = IPAddress.Parse(serviceIP);
// m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort);
m_freeSwitchServicePort = servicePort;
m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty);
m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm);
m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true);
// m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm);
m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm);
m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505);
m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm);
m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString());
m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000);
// m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120);
m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty);
m_freeSwitchContext = m_config.GetString("freeswitch_context", "default");
if (String.IsNullOrEmpty(m_freeSwitchServerUser) || string jsonConfig = m_FreeswitchService.GetJsonConfig();
String.IsNullOrEmpty(m_freeSwitchServerPass) || OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig);
String.IsNullOrEmpty(m_freeSwitchRealm) ||
m_freeSwitchAPIPrefix = map["APIPrefix"].AsString();
m_freeSwitchRealm = map["Realm"].AsString();
m_freeSwitchSIPProxy = map["SIPProxy"].AsString();
m_freeSwitchAttemptUseSTUN = map["AttemptUseSTUN"].AsBoolean();
m_freeSwitchEchoServer = map["EchoServer"].AsString();
m_freeSwitchEchoPort = map["EchoPort"].AsInteger();
m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString();
m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger();
m_freeSwitchUrlResetPassword = String.Empty;
m_freeSwitchContext = map["Context"].AsString();
if (String.IsNullOrEmpty(m_freeSwitchRealm) ||
String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) String.IsNullOrEmpty(m_freeSwitchAPIPrefix))
{ {
m_log.Error("[FreeSwitchVoice] plugin mis-configured"); m_log.Error("[FreeSwitchVoice] plugin mis-configured");
@ -211,6 +207,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
} }
catch (Exception) catch (Exception)
{ {
// COmmented multiline spam log message
//m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions.");
} }
} }
@ -218,7 +215,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
m_scene = scene; m_Scene = scene;
// We generate these like this: The region's external host name
// as defined in Regions.ini is a good address to use. It's a
// dotted quad (or should be!) and it can reach this host from
// a client. The port is grabbed from the region's HTTP server.
m_openSimWellKnownHTTPAddress = m_Scene.RegionInfo.ExternalHostName;
m_freeSwitchServicePort = MainServer.Instance.Port;
if (m_Enabled) if (m_Enabled)
{ {

View File

@ -580,44 +580,33 @@
[FreeSwitchVoice] [FreeSwitchVoice]
;; In order for this to work you need a functioning FreeSWITCH PBX set up. ;; In order for this to work you need a functioning FreeSWITCH PBX set up.
;; Configuration details at http://opensimulator.org/wiki/Freeswitch_Module ;; Configuration details at http://opensimulator.org/wiki/Freeswitch_Module
; enabled = false ; Enabled = false
;; FreeSWITCH server is going to contact us and ask us all sorts of things ;; You need to load a local service for a standalone, and a remote service
; freeswitch_server_user = freeswitch ;; for a grid region. Use one of the lines below, as appropriate
; freeswitch_server_pass = password ; LocalServiceModule = OpenSim.Services.FreeswitchService.dll:FreeswitchService
; freeswitch_api_prefix = /api ; LocalServiceModule = OpenSim.Services.Connectors.dll:RemoteFreeswitchConnector
;; external IP address of your OpenSim voice enabled region ;; If using a remote module, specify the server URL
;; note: all regions running on same OpenSim.exe will be enabled ; FreeswitchServiceURL = http://my.grid.server:8003/fsapi
; freeswitch_service_server = ip.address.of.your.sim
;; this should be the same port the region listens on [FreeswitchService]
; freeswitch_service_port = 9000 ;; !!!!!!!!!!!!!!!!!!!!!!!!!!!
; freeswitch_realm = ip.address.of.freeswitch.server ;; !!!!!!STANDALONE ONLY!!!!!!
; freeswitch_sip_proxy = ip.address.of.freeswitch.server:5060 ;; !!!!!!!!!!!!!!!!!!!!!!!!!!!
;; IP of your FS server
;ServerAddress = 85.25.142.92
;; STUN = Simple Traversal of UDP through NATs ;; All other options are - well - optional
;; See http://wiki.freeswitch.org/wiki/NAT_Traversal ; Realm = "127.0.0.1"
;; stun.freeswitch.org is not guaranteed to be running so use it in ; SIPProxy = "127.0.0.1:5060"
;; production at your own risk ; EchoServer = "127.0.0.1"
; freeswitch_attempt_stun = false ; EchoPort = 50505
; freeswitch_stun_server = ip.address.of.stun.server ; AttemptSTUN = "false"
; freeswitch_echo_server = ip.address.of.freeswitch.server ; DefaultTimeout = 5000
; freeswitch_echo_port = 50505 ; Context = "default"
; freeswitch_well_known_ip = ip.address.of.freeswitch.server ; UserName = "freeswitch"
; Password = "password"
;; Type the address of your http server here, hostname is allowed.
;; This is provided so you can specify a hostname
;; This is used by client for account verification. By default, it's the
;; same as the freeswitch service server.
; opensim_well_known_http_address = Address_Of_Your_SIM_HTTP_Server
;; Timeouts
; freeswitch_default_timeout = 5000
; freeswitch_subscribe_retry = 120
;; Misc
; freeswitch_password_reset_url =
[Groups] [Groups]
;# {Enabled} {} {Enable groups?} {true false} false ;# {Enabled} {} {Enable groups?} {true false} false

View File

@ -73,8 +73,8 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
; ServerAddress = 127.0.0.1 ; ServerAddress = 127.0.0.1
;; All other options are - well - optional ;; All other options are - well - optional
; Realm = 1"27.0.0.1" ; Realm = "127.0.0.1"
; SIPProxy = 1"27.0.0.1:5060" ; SIPProxy = "127.0.0.1:5060"
; EchoServer = "127.0.0.1" ; EchoServer = "127.0.0.1"
; EchoPort = 50505 ; EchoPort = 50505
; AttemptSTUN = "false" ; AttemptSTUN = "false"