提交 e09dd07c authored 作者: Mitch Capper's avatar Mitch Capper

improved link.pl linking and added a few modules

fixed some of the sofia checking
updated config for sofia trunk changes
background improvements
JabraDevice caching of settings to avoid some crashes
上级 a6647df6
#!/usr/bin/perl #!/usr/bin/perl
use strict; use strict;
my $FS_BUILD_PATH = "freeswitch\\Win32\\Debug"; my $FS_BUILD_PATH = "c:\\software\\freeswitch\\Win32\\Debug";
my $WORKING_DIR = "FSClient\\bin\Debug"; my $WORKING_DIR = "..\\bin\\Debug";
my $USE_LN = 0; #THIS SHOULD BE SET TO 0 (unless you have an ln equiv for windows) my $USE_LN =0; #THIS SHOULD BE SET TO 0 (unless you have an ln equiv for windows)
my $COPY_CONF = 1; my $COPY_CONF = 1;
my $VERBOSE = 1; my $VERBOSE = 0;
my $try_pdb = 1; my $try_pdb = 1;
my $VERBOSE_SYS_RES = 0; my $VERBOSE_SYS_RES = 0;
die "Build directory does not exist: $FS_BUILD_PATH" if (! -e $FS_BUILD_PATH); die "Build directory does not exist: $FS_BUILD_PATH" if (! -e $FS_BUILD_PATH);
...@@ -24,12 +24,17 @@ sub exec_cmd($){ ...@@ -24,12 +24,17 @@ sub exec_cmd($){
$res =~ s/\n/\n\t/g; $res =~ s/\n/\n\t/g;
print $res . "\n" if ($VERBOSE_SYS_RES); print $res . "\n" if ($VERBOSE_SYS_RES);
} }
sub link_file($$){
my ($src,$dst) = @_;
exec_cmd(qq~$link_cmd "$src" "$dst"~);
print STDERR "Warning after copying/linking file: \"$dst\" did not exist src: $src\n" if (! -e $dst);
}
exec_cmd("mkdir " . $WORKING_DIR . "\\mod") if (-e $WORKING_DIR . "\\mod" == 0); exec_cmd("mkdir " . $WORKING_DIR . "\\mod") if (-e $WORKING_DIR . "\\mod" == 0);
foreach my $module (@modules){ foreach my $module (@modules){
my $rel_path = "mod\\" . $module . ".dll"; my $rel_path = "mod\\" . $module . ".dll";
my $src_path = $FS_BUILD_PATH . "\\" . $rel_path; my $src_path = $FS_BUILD_PATH . "\\" . $rel_path;
if (-e $src_path == 0){ if (-e $src_path == 0){
print "Warning: $src_path does not exist\n"; print STDERR "Warning: $src_path does not exist\n";
next; next;
} }
if ($try_pdb){ if ($try_pdb){
...@@ -37,12 +42,10 @@ foreach my $module (@modules){ ...@@ -37,12 +42,10 @@ foreach my $module (@modules){
$pdb_file =~ s/\.dll$/.pdb/si; $pdb_file =~ s/\.dll$/.pdb/si;
my $pdb_dest = "$WORKING_DIR\\$rel_path"; my $pdb_dest = "$WORKING_DIR\\$rel_path";
$pdb_dest =~ s/\.dll$/.pdb/si; $pdb_dest =~ s/\.dll$/.pdb/si;
if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest) ){ link_file($pdb_file,$pdb_dest) if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest));
exec_cmd($link_cmd . qq~ "$pdb_file" "$pdb_dest"~);
}
} }
next if (-e "$WORKING_DIR\\" . $rel_path && $USE_LN); next if (-e "$WORKING_DIR\\" . $rel_path && $USE_LN);
exec_cmd($link_cmd . qq~ "$src_path" "$WORKING_DIR\\$rel_path"~); link_file($src_path, "$WORKING_DIR\\$rel_path");
} }
...@@ -50,7 +53,7 @@ foreach my $file (@MAIN_FILES){ ...@@ -50,7 +53,7 @@ foreach my $file (@MAIN_FILES){
my $src_path = $FS_BUILD_PATH . "\\" . $file; my $src_path = $FS_BUILD_PATH . "\\" . $file;
$src_path = $FS_BUILD_PATH . "\\mod\\" . $file if (-e $FS_BUILD_PATH . "\\mod\\" . $file); #mainly for putting mod_managed.dll into the root $src_path = $FS_BUILD_PATH . "\\mod\\" . $file if (-e $FS_BUILD_PATH . "\\mod\\" . $file); #mainly for putting mod_managed.dll into the root
if (-e $src_path == 0){ if (-e $src_path == 0){
print "Warning: $src_path does not exist\n"; print STDERR "Warning: $src_path does not exist\n";
next; next;
} }
if ($try_pdb){ if ($try_pdb){
...@@ -58,15 +61,13 @@ foreach my $file (@MAIN_FILES){ ...@@ -58,15 +61,13 @@ foreach my $file (@MAIN_FILES){
$pdb_file =~ s/\.dll$/.pdb/si; $pdb_file =~ s/\.dll$/.pdb/si;
my $pdb_dest = "$WORKING_DIR\\$file"; my $pdb_dest = "$WORKING_DIR\\$file";
$pdb_dest =~ s/\.dll$/.pdb/si; $pdb_dest =~ s/\.dll$/.pdb/si;
if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest) ){ link_file($pdb_file,$pdb_dest) if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest));
exec_cmd($link_cmd . qq~ "$pdb_file" "$pdb_dest"~);
}
} }
next if (-e "$WORKING_DIR\\" . $file && $USE_LN); next if (-e "$WORKING_DIR\\" . $file && $USE_LN);
exec_cmd($link_cmd . qq~ "$src_path" "$WORKING_DIR\\$file"~); link_file($src_path, "$WORKING_DIR\\$file");
} }
if ($COPY_CONF){ if ($COPY_CONF){
exec_cmd("mkdir " . $WORKING_DIR . "\\conf") if (-e $WORKING_DIR . "\\conf" == 0); exec_cmd("mkdir " . $WORKING_DIR . "\\conf") if (-e $WORKING_DIR . "\\conf" == 0);
exec_cmd($link_cmd . qq~ "conf\\freeswitch.xml" "$WORKING_DIR\\conf\\freeswitch.xml"~); link_file("conf\\freeswitch.xml","$WORKING_DIR\\conf\\freeswitch.xml");
} }
...@@ -10,16 +10,16 @@ namespace JabraHeadset { ...@@ -10,16 +10,16 @@ namespace JabraHeadset {
//ake sure mic mute actually goes both ways //ake sure mic mute actually goes both ways
internal JA.IDevice device; internal JA.IDevice device;
public string device_path { get; private set; }
public string device_path { get { return device.DeviceHandle.ToString(); } } private string device_name;
public override string GetName() { public override string GetName() {
return device.Name; return device_name;
} }
public override string GetManufacturer() { public override string GetManufacturer() {
return "Jabra"; return "Jabra";
} }
public override string GetModel() { public override string GetModel() {
return device.Name; return device_name;
} }
public override string GetUniqueId() { public override string GetUniqueId() {
return "Jabra " + device_path; return "Jabra " + device_path;
...@@ -42,6 +42,8 @@ namespace JabraHeadset { ...@@ -42,6 +42,8 @@ namespace JabraHeadset {
} }
public JabraHeadset(JA.IDevice device) { public JabraHeadset(JA.IDevice device) {
this.device = device; this.device = device;
device_path = device.DeviceHandle.ToString();
device_name = device.Name;
} }
private IDeviceHost host; private IDeviceHost host;
private void HostStatusChanged(object sender, IDeviceHost.StatusEventArgs e) { private void HostStatusChanged(object sender, IDeviceHost.StatusEventArgs e) {
...@@ -140,9 +142,14 @@ namespace JabraHeadset { ...@@ -140,9 +142,14 @@ namespace JabraHeadset {
public class JabraProvider : IHeadsetPlugin { public class JabraProvider : IHeadsetPlugin {
private void AddNewDevice(JA.IDevice ja_device) { private void AddNewDevice(JA.IDevice ja_device) {
try{
JabraHeadset device = new JabraHeadset(ja_device); JabraHeadset device = new JabraHeadset(ja_device);
devices.Add(device); devices.Add(device);
DeviceAdded(this, new DeviceEventArgs(device)); DeviceAdded(this, new DeviceEventArgs(device));
}
catch (System.IO.FileNotFoundException) {
Utils.PluginLog("Jabra Provider", "Unable to add new device");
}
} }
private void OnDeviceAttached(JA.IDevice device) { private void OnDeviceAttached(JA.IDevice device) {
AddNewDevice(device); AddNewDevice(device);
......
...@@ -106,11 +106,13 @@ namespace FSClient { ...@@ -106,11 +106,13 @@ namespace FSClient {
} }
public static AudioDevice[] get_devices(bool refresh) { public static AudioDevice[] get_devices(bool refresh) {
if (refresh || _pub_devices == null) if (refresh || _pub_devices == null)
refresh_devices(); refresh_devices(true);
return _pub_devices; return _pub_devices;
} }
public static void refresh_devices() { public static void refresh_devices(bool force=false) {
if (! force && !Broker.get_instance().fully_loaded)
return;
foreach (InternalAudioDevice device in _devices) foreach (InternalAudioDevice device in _devices)
device.is_alive = false; device.is_alive = false;
Utils.api_exec("pa", "rescan"); Utils.api_exec("pa", "rescan");
......
...@@ -29,7 +29,7 @@ namespace FSClient { ...@@ -29,7 +29,7 @@ namespace FSClient {
public static Field[] fields = { public static Field[] fields = {
/*Default*/ /*Default*/
new Field(Field.FIELD_TYPE.MultiItem,"Codec Preferences","codec-prefs","codec-prefs","CELT@48000h@10i,PCMU,PCMA,GSM","","CELT@32000h","CELT@48000h@10i","PCMA","PCMU","GSM","G722","G7221@16000h","G7221@32000h","AAL2-G726-16","AAL2-G726-24","AAL2-G726-32","AAL2-G726-40","BV16","BV32","DVI4@16000h@40i","DVI4@8000h@20i","G726-16","G726-24","G726-32","G726-40","L16","LPC","iLBC@30i","speex@16000h@20i","speex@32000h@20i","speex@8000h@20i"), new Field(Field.FIELD_TYPE.MultiItem,"Codec Preferences","codec-prefs","codec-prefs","CELT@48000h@10i,PCMU,PCMA,GSM","","CELT@32000h","CELT@48000h@10i","PCMA","PCMU","GSM","G722","G7221@16000h","G7221@32000h","AAL2-G726-16","AAL2-G726-24","AAL2-G726-32","AAL2-G726-40","BV16","BV32","DVI4@16000h@40i","DVI4@8000h@20i","G726-16","G726-24","G726-32","G726-40","L16","LPC","iLBC@30i","speex@16000h@20i","speex@32000h@20i","speex@8000h@20i","G729"),
new Field(Field.FIELD_TYPE.Combo,"Inbound Codec Negotiation","inbound-codec-negotiation","inbound-codec-negotiation","generous","","generous","greedy","scrooge"), new Field(Field.FIELD_TYPE.Combo,"Inbound Codec Negotiation","inbound-codec-negotiation","inbound-codec-negotiation","generous","","generous","greedy","scrooge"),
new Field(Field.FIELD_TYPE.String,"External RTP IP","ext-rtp-ip","ext-rtp-ip","auto-nat",""), new Field(Field.FIELD_TYPE.String,"External RTP IP","ext-rtp-ip","ext-rtp-ip","auto-nat",""),
new Field(Field.FIELD_TYPE.String,"External SIP IP","ext-sip-ip","ext-sip-ip","auto-nat",""), new Field(Field.FIELD_TYPE.String,"External SIP IP","ext-sip-ip","ext-sip-ip","auto-nat",""),
...@@ -54,7 +54,7 @@ namespace FSClient { ...@@ -54,7 +54,7 @@ namespace FSClient {
new Field(Field.FIELD_TYPE.Int,"TLS SIP Port","tls-sip-port","tls-sip-port","12347","Security"), new Field(Field.FIELD_TYPE.Int,"TLS SIP Port","tls-sip-port","tls-sip-port","12347","Security"),
new Field(Field.FIELD_TYPE.String,"TLS Certificate Directory","tls-cert-dir","tls-cert-dir","conf/ssl","Security"), new Field(Field.FIELD_TYPE.String,"TLS Certificate Directory","tls-cert-dir","tls-cert-dir","conf/ssl","Security"),
new Field(Field.FIELD_TYPE.Int,"TLS Max Verify Depth","tls-verify-depth","tls-verify-depth","2","Security"), new Field(Field.FIELD_TYPE.Int,"TLS Max Verify Depth","tls-verify-depth","tls-verify-depth","2","Security"),
new Field(Field.FIELD_TYPE.Bool,"TLS No Certificate Date Validation","tls-no-verify-date","tls-no-verify-date","false","Security"), new Field(Field.FIELD_TYPE.Bool,"TLS Verify Date","tls-verify-date","tls-verify-date","true","Security"),
/*Advanced*/ /*Advanced*/
new Field(Field.FIELD_TYPE.String,"Challenge Realm","challenge-realm","challenge-realm","auto_from","Advanced"), new Field(Field.FIELD_TYPE.String,"Challenge Realm","challenge-realm","challenge-realm","auto_from","Advanced"),
...@@ -106,7 +106,7 @@ namespace FSClient { ...@@ -106,7 +106,7 @@ namespace FSClient {
Utils.add_xml_param(settings, value.field.xml_name, param_value); Utils.add_xml_param(settings, value.field.xml_name, param_value);
} }
DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 1200); DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 1000);
} }
private bool tls_cert_exist_check(){ private bool tls_cert_exist_check(){
String base_dir = FieldValue.GetByName(values, "tls-cert-dir").value; String base_dir = FieldValue.GetByName(values, "tls-cert-dir").value;
...@@ -137,15 +137,23 @@ namespace FSClient { ...@@ -137,15 +137,23 @@ namespace FSClient {
break; break;
case RELOAD_CONFIG_MODE.MODULE: case RELOAD_CONFIG_MODE.MODULE:
Utils.api_exec("reload", "mod_sofia"); Utils.api_exec("reload", "mod_sofia");
DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 1500);
break; break;
} }
} }
private bool master_profile_ok; private bool master_profile_ok;
private bool sofia_actual_profile_check(bool is_last_try){ private bool sofia_actual_profile_check(bool is_last_try){
String res = Utils.api_exec("sofia", "status profile softphone"); String res = Utils.api_exec("sofia", "xmlstatus profile softphone").ToLower().Trim();
if (res.Trim() == "Invalid Profile!") { if (res == "invalid command!"){
if (is_last_try) if (! is_last_try)
return false;
MessageBox.Show("Warning mod_sofia module does not seem to be loaded please make sure it exists");
master_profile_ok = false;
return false;
}
if (res == "invalid profile!") {
if (! is_last_try)
return false; return false;
String tls_port_msg = ""; String tls_port_msg = "";
if (FieldValue.GetByName(values, "tls").value == "true") if (FieldValue.GetByName(values, "tls").value == "true")
...@@ -154,13 +162,19 @@ namespace FSClient { ...@@ -154,13 +162,19 @@ namespace FSClient {
master_profile_ok = false; master_profile_ok = false;
return false; return false;
} }
if (res.Contains("<context>public</context>") == false){
if (!is_last_try)
return false;
master_profile_ok = false;
MessageBox.Show("I believe there may be a problem with sofia, but I do not know what");
return false;
}
master_profile_ok = true; master_profile_ok = true;
return true; return true;
} }
public void sofia_profile_check_last(){ public void sofia_profile_check_last(){
bool res = sofia_actual_profile_check(true); bool res = sofia_actual_profile_check(true);
Debug.WriteLine("GOT TO Last Check and its result was: " + res);
} }
public void sofia_profile_check() { public void sofia_profile_check() {
......
using System; using System;
using System.Configuration; using System.Configuration;
using System.Reflection; using System.Reflection;
using System.Timers;
using System.Windows; using System.Windows;
using System.Xml; using System.Xml;
using FreeSWITCH.Native; using FreeSWITCH.Native;
...@@ -13,6 +14,7 @@ namespace FSClient { ...@@ -13,6 +14,7 @@ namespace FSClient {
public class Utils { public class Utils {
private static BackgroundWorker bgWorker; private static BackgroundWorker bgWorker;
private static Timer bg_watcher;
private static Api API; private static Api API;
public delegate void ObjectEventHandler<T>(object sender, T data); public delegate void ObjectEventHandler<T>(object sender, T data);
public static string api_exec(String cmd, String args) { public static string api_exec(String cmd, String args) {
...@@ -25,12 +27,16 @@ namespace FSClient { ...@@ -25,12 +27,16 @@ namespace FSClient {
public string args; public string args;
} }
private static Api BGAPI; private static Api BGAPI;
private static BGArgs current_exec;
private static Queue pending_bg_queue = new Queue(); private static Queue pending_bg_queue = new Queue();
public static void bgapi_exec(String cmd, String args) { public static void bgapi_exec(String cmd, String args) {
if (bgWorker == null) { if (bgWorker == null) {
bg_watcher = new Timer(30 * 1000);
bg_watcher.Elapsed += new ElapsedEventHandler(bg_watcher_Elapsed);
bgWorker = new BackgroundWorker(); bgWorker = new BackgroundWorker();
bgWorker.DoWork += bgWorker_DoWork; bgWorker.DoWork += bgWorker_DoWork;
bgWorker.RunWorkerCompleted += bgWorker_RunWorkerCompleted; bgWorker.RunWorkerCompleted += bgWorker_RunWorkerCompleted;
bg_watcher.Start();
} }
BGArgs newBGArgs = new BGArgs { args = args, cmd = cmd }; BGArgs newBGArgs = new BGArgs { args = args, cmd = cmd };
lock (pending_bg_queue.SyncRoot) { lock (pending_bg_queue.SyncRoot) {
...@@ -40,6 +46,12 @@ namespace FSClient { ...@@ -40,6 +46,12 @@ namespace FSClient {
bgWorker.RunWorkerAsync(newBGArgs); bgWorker.RunWorkerAsync(newBGArgs);
} }
} }
private static BGArgs last_exec_check;
static void bg_watcher_Elapsed(object sender, ElapsedEventArgs e) {
if (current_exec != null && current_exec == last_exec_check)
MessageBox.Show("Warning freeswitch is most likely deadlocked, something has been pending in the bg queue for > 30 seconds, currently executing: " + current_exec.cmd + " " + current_exec.args);
last_exec_check = current_exec;
}
private static void bgapi_dequeue() { private static void bgapi_dequeue() {
lock (pending_bg_queue.SyncRoot) { lock (pending_bg_queue.SyncRoot) {
...@@ -53,10 +65,11 @@ namespace FSClient { ...@@ -53,10 +65,11 @@ namespace FSClient {
static void bgWorker_DoWork(object sender, DoWorkEventArgs e) { static void bgWorker_DoWork(object sender, DoWorkEventArgs e) {
BGArgs args = (BGArgs)e.Argument; current_exec = (BGArgs)e.Argument;
if (BGAPI == null) if (BGAPI == null)
BGAPI = new Api(); BGAPI = new Api();
e.Result = BGAPI.Execute(args.cmd, args.args); e.Result = BGAPI.Execute(current_exec.cmd, current_exec.args);
current_exec = null;
} }
public static void add_xml_param(XmlNode node, String name, String value) { public static void add_xml_param(XmlNode node, String name, String value) {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论