Commit f06b21bf authored by Sylvain Berfini's avatar Sylvain Berfini

Fixed echo calibration crash + use keep alive task to refresh register every 6 hours

parent 66b4fb15
......@@ -89,6 +89,7 @@
<Compile Include="LinphoneForegroundLifeTimeAgent.cs" />
<Compile Include="LinphoneScheduledAgent.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PushManager.cs" />
<Compile Include="RegistrationHelper.cs" />
<Compile Include="TileManager.cs" />
<Compile Include="$(ProjectDir)..\submodules\mswp8vid\VideoRenderer.cs" />
......
using Linphone.Core;
using Linphone.Core.OutOfProcess;
using Microsoft.Phone.Net.NetworkInformation;
using Microsoft.Phone.Networking.Voip;
using Microsoft.Phone.Scheduler;
using System;
using System.Diagnostics;
using Windows.Storage;
namespace Linphone.Agents
{
public class LinphoneScheduledAgent : ScheduledTaskAgent
public class LinphoneScheduledAgent : ScheduledTaskAgent, LinphoneCoreListener
{
// Indicates if this agent instance is handling an incoming call or not
private bool isIncomingCallAgent;
......@@ -36,7 +38,32 @@ namespace Linphone.Agents
if (keepAliveTask != null)
{
this.isIncomingCallAgent = false;
Debug.WriteLine("[KeepAliveAgent] Keep Alive");
Debug.WriteLine("[KeepAliveAgent] Keep Alive task");
if (DeviceNetworkInformation.IsNetworkAvailable)
{
var server = BackgroundManager.Instance.OopServer;
LpConfig config = server.LinphoneCoreFactory.CreateLpConfig(ApplicationData.Current.LocalFolder.Path + "\\linphonerc", "Assets/linphonerc-factory");
server.LinphoneCoreFactory.CreateLinphoneCore(this, config);
server.LinphoneCore.SetRootCA("Assets/rootca.pem");
server.LinphoneCore.SetNetworkReachable(true);
Debug.WriteLine("[KeepAliveAgent] Linphone Core created");
PushManager pushManager = new PushManager();
if (server.LinphoneCore.GetDefaultProxyConfig() != null && pushManager.PushChannelUri != null)
{
string host, token;
host = pushManager.PushChannelUri.Host;
token = pushManager.PushChannelUri.AbsolutePath;
server.LinphoneCore.GetDefaultProxyConfig().SetContactParameters("app-id=" + host + ";pn-type=wp;pn-tok=" + token + ";pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-call-snd=ring.caf;pn-msg-snd=msg.caf");
Debug.WriteLine("[KeepAliveAgent] Added push parameters to contact");
}
}
else
{
Debug.WriteLine("[KeepAliveAgent] Not connected, can't refresh register");
base.NotifyComplete();
}
}
else
{
......@@ -59,5 +86,79 @@ namespace Linphone.Agents
base.NotifyComplete();
}
#region LinphoneCoreListener Callbacks
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void AuthInfoRequested(string realm, string username)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void GlobalState(GlobalState state, string message)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void CallState(LinphoneCall call, LinphoneCallState state)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
{
if (config == null)
return;
Debug.WriteLine("[KeepAliveAgent] Registration state changed: " + state.ToString() + ", message=" + message + " for identity " + config.GetIdentity());
if (state == Linphone.Core.RegistrationState.RegistrationOk)
{
Debug.WriteLine("[KeepAliveAgent] Notify complete");
base.NotifyComplete();
}
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void DTMFReceived(LinphoneCall call, Char dtmf)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void EcCalibrationStatus(EcCalibratorStatus status, int delayMs)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void CallEncryptionChanged(LinphoneCall call, bool encrypted, string authenticationToken)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void CallStatsUpdated(LinphoneCall call, LinphoneCallStats stats)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void MessageReceived(LinphoneChatMessage message)
{
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linphone.Agents
{
public class PushManager
{
public PushManager()
{
_settings = IsolatedStorageSettings.ApplicationSettings;
}
IsolatedStorageSettings _settings;
#region Constants settings names
private const string PushUriKeyName = "PushUri";
#endregion
#region methods
private bool AddOrUpdate(string key, object value)
{
bool valueChanged = false;
if (_settings.Contains(key))
{
if (!_settings[key].Equals(value))
{
_settings[key] = value;
valueChanged = true;
}
}
else
{
_settings.Add(key, value);
valueChanged = true;
}
return valueChanged;
}
private Uri GetValue(string key)
{
Uri value = null;
if (_settings.Contains(key))
value = (Uri)_settings[key];
return value;
}
private void Save()
{
_settings.Save();
}
#endregion
#region Accessors
/// <summary>
/// DTMFs using RFC2833 setting (bool).
/// </summary>
public Uri PushChannelUri
{
get
{
return GetValue(PushUriKeyName);
}
set
{
if (AddOrUpdate(PushUriKeyName, value))
{
Save();
}
}
}
#endregion
}
}
......@@ -672,8 +672,7 @@ static void EchoCalibrationAudioUninit(void *data)
Linphone::Core::EchoCalibrationData *ecData = static_cast<Linphone::Core::EchoCalibrationData *>(data);
if (ecData != nullptr) {
ecData->call->NotifyCallEnded();
ecData->call = nullptr;
AudioRoutingManager::GetDefault()->SetAudioEndpoint(ecData->endpoint);
AudioRoutingManager::GetDefault()->SetAudioEndpoint(AudioRoutingEndpoint::Default);
}
}
......
......@@ -12,6 +12,8 @@ using System.Windows;
using System.Windows.Markup;
using System.Windows.Navigation;
using System.Data.Linq;
using Microsoft.Phone.Reactive;
using Linphone.Agents;
namespace Linphone
{
......@@ -178,6 +180,8 @@ namespace Linphone
// Store the push channel URI
this.PushChannelUri = e.ChannelUri;
PushManager pushManager = new PushManager();
pushManager.PushChannelUri = e.ChannelUri;
// Let listeners know that we have a push channel URI
if (this.PushChannelUriChanged != null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment