提交 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
use strict;
my $FS_BUILD_PATH = "freeswitch\\Win32\\Debug";
my $WORKING_DIR = "FSClient\\bin\Debug";
my $FS_BUILD_PATH = "c:\\software\\freeswitch\\Win32\\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 $VERBOSE = 1;
my $VERBOSE = 0;
my $try_pdb = 1;
my $VERBOSE_SYS_RES = 0;
die "Build directory does not exist: $FS_BUILD_PATH" if (! -e $FS_BUILD_PATH);
......@@ -24,12 +24,17 @@ sub exec_cmd($){
$res =~ s/\n/\n\t/g;
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);
foreach my $module (@modules){
my $rel_path = "mod\\" . $module . ".dll";
my $src_path = $FS_BUILD_PATH . "\\" . $rel_path;
if (-e $src_path == 0){
print "Warning: $src_path does not exist\n";
print STDERR "Warning: $src_path does not exist\n";
next;
}
if ($try_pdb){
......@@ -37,12 +42,10 @@ foreach my $module (@modules){
$pdb_file =~ s/\.dll$/.pdb/si;
my $pdb_dest = "$WORKING_DIR\\$rel_path";
$pdb_dest =~ s/\.dll$/.pdb/si;
if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest) ){
exec_cmd($link_cmd . qq~ "$pdb_file" "$pdb_dest"~);
}
link_file($pdb_file,$pdb_dest) if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest));
}
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){
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
if (-e $src_path == 0){
print "Warning: $src_path does not exist\n";
print STDERR "Warning: $src_path does not exist\n";
next;
}
if ($try_pdb){
......@@ -58,15 +61,13 @@ foreach my $file (@MAIN_FILES){
$pdb_file =~ s/\.dll$/.pdb/si;
my $pdb_dest = "$WORKING_DIR\\$file";
$pdb_dest =~ s/\.dll$/.pdb/si;
if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest) ){
exec_cmd($link_cmd . qq~ "$pdb_file" "$pdb_dest"~);
}
link_file($pdb_file,$pdb_dest) if (-e $pdb_file && (! $USE_LN || ! -e $pdb_dest));
}
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){
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"~);
}
\ No newline at end of file
link_file("conf\\freeswitch.xml","$WORKING_DIR\\conf\\freeswitch.xml");
}
......@@ -10,16 +10,16 @@ namespace JabraHeadset {
//ake sure mic mute actually goes both ways
internal JA.IDevice device;
public string device_path { get { return device.DeviceHandle.ToString(); } }
public string device_path { get; private set; }
private string device_name;
public override string GetName() {
return device.Name;
return device_name;
}
public override string GetManufacturer() {
return "Jabra";
}
public override string GetModel() {
return device.Name;
return device_name;
}
public override string GetUniqueId() {
return "Jabra " + device_path;
......@@ -42,6 +42,8 @@ namespace JabraHeadset {
}
public JabraHeadset(JA.IDevice device) {
this.device = device;
device_path = device.DeviceHandle.ToString();
device_name = device.Name;
}
private IDeviceHost host;
private void HostStatusChanged(object sender, IDeviceHost.StatusEventArgs e) {
......@@ -140,9 +142,14 @@ namespace JabraHeadset {
public class JabraProvider : IHeadsetPlugin {
private void AddNewDevice(JA.IDevice ja_device) {
try{
JabraHeadset device = new JabraHeadset(ja_device);
devices.Add(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) {
AddNewDevice(device);
......
......@@ -106,11 +106,13 @@ namespace FSClient {
}
public static AudioDevice[] get_devices(bool refresh) {
if (refresh || _pub_devices == null)
refresh_devices();
refresh_devices(true);
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)
device.is_alive = false;
Utils.api_exec("pa", "rescan");
......
......@@ -29,7 +29,7 @@ namespace FSClient {
public static Field[] fields = {
/*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.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",""),
......@@ -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.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.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*/
new Field(Field.FIELD_TYPE.String,"Challenge Realm","challenge-realm","challenge-realm","auto_from","Advanced"),
......@@ -106,7 +106,7 @@ namespace FSClient {
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(){
String base_dir = FieldValue.GetByName(values, "tls-cert-dir").value;
......@@ -137,15 +137,23 @@ namespace FSClient {
break;
case RELOAD_CONFIG_MODE.MODULE:
Utils.api_exec("reload", "mod_sofia");
DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 1500);
break;
}
}
private bool master_profile_ok;
private bool sofia_actual_profile_check(bool is_last_try){
String res = Utils.api_exec("sofia", "status profile softphone");
if (res.Trim() == "Invalid Profile!") {
if (is_last_try)
String res = Utils.api_exec("sofia", "xmlstatus profile softphone").ToLower().Trim();
if (res == "invalid command!"){
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;
String tls_port_msg = "";
if (FieldValue.GetByName(values, "tls").value == "true")
......@@ -154,13 +162,19 @@ namespace FSClient {
master_profile_ok = 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;
return true;
}
public void sofia_profile_check_last(){
bool res = sofia_actual_profile_check(true);
Debug.WriteLine("GOT TO Last Check and its result was: " + res);
}
public void sofia_profile_check() {
......
using System;
using System.Configuration;
using System.Reflection;
using System.Timers;
using System.Windows;
using System.Xml;
using FreeSWITCH.Native;
......@@ -13,6 +14,7 @@ namespace FSClient {
public class Utils {
private static BackgroundWorker bgWorker;
private static Timer bg_watcher;
private static Api API;
public delegate void ObjectEventHandler<T>(object sender, T data);
public static string api_exec(String cmd, String args) {
......@@ -25,12 +27,16 @@ namespace FSClient {
public string args;
}
private static Api BGAPI;
private static BGArgs current_exec;
private static Queue pending_bg_queue = new Queue();
public static void bgapi_exec(String cmd, String args) {
if (bgWorker == null) {
bg_watcher = new Timer(30 * 1000);
bg_watcher.Elapsed += new ElapsedEventHandler(bg_watcher_Elapsed);
bgWorker = new BackgroundWorker();
bgWorker.DoWork += bgWorker_DoWork;
bgWorker.RunWorkerCompleted += bgWorker_RunWorkerCompleted;
bg_watcher.Start();
}
BGArgs newBGArgs = new BGArgs { args = args, cmd = cmd };
lock (pending_bg_queue.SyncRoot) {
......@@ -40,6 +46,12 @@ namespace FSClient {
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() {
lock (pending_bg_queue.SyncRoot) {
......@@ -53,10 +65,11 @@ namespace FSClient {
static void bgWorker_DoWork(object sender, DoWorkEventArgs e) {
BGArgs args = (BGArgs)e.Argument;
current_exec = (BGArgs)e.Argument;
if (BGAPI == null)
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) {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论