Commit 15f7ae36 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

More methods documented + prevent the PN process to be alive forever

parent 2b774350
......@@ -38,8 +38,22 @@ namespace Linphone.Agents
}
}
// A proxy to the server object in the background agent host process
public Server OopServer;
private Server oopServer;
/// <summary>
/// A proxy to the server object in the background agent host process
/// </summary>
public Server OopServer
{
get {
if (oopServer == null)
oopServer = (Server)WindowsRuntimeMarshal.GetActivationFactory(typeof(Server)).ActivateInstance();
return oopServer;
}
set {
oopServer = value;
}
}
/// <summary>
/// Creates a new LinphoneCore (if not created yet) using a LinphoneCoreFactory.
......@@ -47,12 +61,8 @@ namespace Linphone.Agents
public void InitLinphoneCore()
{
// Initiate incoming call processing by creating the Linphone Core
if (OopServer == null)
OopServer = (Server)WindowsRuntimeMarshal.GetActivationFactory(typeof(Server)).ActivateInstance();
LpConfig config = OopServer.LinphoneCoreFactory.CreateLpConfig(ApplicationData.Current.LocalFolder.Path + "\\linphonerc", "Assets/linphonerc-factory");
OopServer.LinphoneCoreFactory.CreateLinphoneCore(null, config);
OopServer.LinphoneCoreFactory.CreateLinphoneCore(null, config);
//Globals.Instance.BackgroundModeLogger.Configure(true, OutputTraceDest.TCPRemote, "192.168.0.217:38954");
//Globals.Instance.LinphoneCoreFactory.OutputTraceListener = Globals.Instance.BackgroundModeLogger;
......
......@@ -29,8 +29,8 @@ namespace Linphone.Agents
this.isIncomingCallAgent = true;
Debug.WriteLine("[IncomingCallAgent] Received VoIP Incoming Call task");
BackgroundManager.Instance.InitLinphoneCore();
BackgroundManager.Instance.OopServer.CallController.IncomingCallViewDismissed = OnIncomingCallDialogDismissed;
BackgroundManager.Instance.InitLinphoneCore();
}
else
{
......@@ -39,6 +39,8 @@ namespace Linphone.Agents
{
this.isIncomingCallAgent = false;
Debug.WriteLine("[KeepAliveAgent] Keep Alive");
BackgroundManager.Instance.InitLinphoneCore();
}
else
{
......@@ -47,7 +49,7 @@ namespace Linphone.Agents
}
}
// This method is called when the incoming call processing is complete
// This method is called when the incoming call processing is complete to kill the background process if needed
private void OnIncomingCallDialogDismissed()
{
Debug.WriteLine("[IncomingCallAgent] Incoming call processing is now complete.");
......
......@@ -19,7 +19,8 @@ VoipPhoneCall^ CallController::OnIncomingCallReceived(Linphone::Core::LinphoneCa
TimeSpan ringingTimeout;
ringingTimeout.Duration = 90 * 10 * 1000 * 1000; // in 100ns units
this->onIncomingCallViewDismissed = incomingCallViewDismissedCallback;
if (incomingCallViewDismissedCallback != nullptr)
this->onIncomingCallViewDismissed = incomingCallViewDismissedCallback;
// Ask the Phone Service to start a new incoming call
this->callCoordinator->RequestNewIncomingCall(
......@@ -51,12 +52,12 @@ void CallController::OnAcceptCallRequested(VoipPhoneCall^ incomingCall, CallAnsw
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
incomingCall->NotifyCallActive();
if (this->call != nullptr)
Globals::Instance->LinphoneCore->AcceptCall(this->call);
if (this->onIncomingCallViewDismissed != nullptr)
this->onIncomingCallViewDismissed();
if (this->call != nullptr)
Globals::Instance->LinphoneCore->AcceptCall(this->call);
}
void CallController::OnRejectCallRequested(VoipPhoneCall^ incomingCall, CallRejectEventArgs^ args)
......@@ -65,11 +66,11 @@ void CallController::OnRejectCallRequested(VoipPhoneCall^ incomingCall, CallReje
incomingCall->NotifyCallEnded();
if (this->call != nullptr)
Globals::Instance->LinphoneCore->TerminateCall(this->call);
if (this->onIncomingCallViewDismissed != nullptr)
this->onIncomingCallViewDismissed();
if (this->call != nullptr)
Globals::Instance->LinphoneCore->TerminateCall(this->call);
}
void CallController::EndCall(VoipPhoneCall^ call)
......
......@@ -10,6 +10,9 @@ namespace Linphone
ref class Globals;
ref class LinphoneCall;
/// <summary>
/// Callback to be called when the PushNotification Agent has to be dismissed, i.e. after a call has been accepted, denied or stopped by the caller.
/// </summary>
public delegate void IncomingCallViewDismissedCallback();
/// <summary>
......@@ -18,12 +21,24 @@ namespace Linphone
public ref class CallController sealed
{
public:
/// <summary>
/// Starts the system incoming call view.
/// </summary>
Windows::Phone::Networking::Voip::VoipPhoneCall^ OnIncomingCallReceived(LinphoneCall^ call, Platform::String^ contactName, Platform::String^ contactNumber, IncomingCallViewDismissedCallback^ incomingCallViewDismissedCallback);
/// <summary>
/// Terminate the native VoipPhoneCall.
/// </summary>
void EndCall(Windows::Phone::Networking::Voip::VoipPhoneCall^ call);
/// <summary>
/// Starts an outgoing call using native VoipPhoneCall.
/// </summary>
Windows::Phone::Networking::Voip::VoipPhoneCall^ NewOutgoingCall(Platform::String^ number, Platform::String^ name);
/// <summary>
/// Callback to be called when the PushNotification Agent has to be dismissed, i.e. after a call has been accepted, denied or stopped by the caller.
/// </summary>
property IncomingCallViewDismissedCallback^ IncomingCallViewDismissed
{
IncomingCallViewDismissedCallback^ get();
......
......@@ -23,32 +23,50 @@ namespace Linphone
/// </summary>
void StartServer(const Platform::Array<Platform::String^>^ outOfProcServerClassNames);
/// <summary>
///Returns the id of the background process (HeadlessHost)
/// </summary>
static unsigned int GetCurrentProcessId();
static Platform::String^ GetUiDisconnectedEventName(unsigned int backgroundProcessId);
static Platform::String^ GetBackgroundProcessReadyEventName(unsigned int backgroundProcessId);
/// <summary>
/// Gets the instance of the Globals class, used to directly access any C++/CX objects from C#
/// </summary>
static property Globals^ Instance
{
Globals^ get();
}
/// <summary>
/// Gets the current instance of LinphoneCoreFactory
/// </summary>
property LinphoneCoreFactory^ LinphoneCoreFactory
{
Linphone::Core::LinphoneCoreFactory^ get();
}
/// <summary>
/// Gets the current instance of LinphoneCore from LinphoneCoreFactory
/// </summary>
property LinphoneCore^ LinphoneCore
{
Linphone::Core::LinphoneCore^ get();
}
/// <summary>
/// Gets the current instance of the logger
/// </summary>
property BackgroundModeLogger^ BackgroundModeLogger
{
Linphone::Core::BackgroundModeLogger^ get();
}
/// <summary>
/// Gets the current instance of the native call controller
/// </summary>
property CallController^ CallController
{
Linphone::Core::CallController^ get();
......
......@@ -20,10 +20,29 @@ namespace Linphone
public ref class LinphoneCall sealed
{
public:
/// <summary>
/// Gets the LinphoneCallState of the call (StreamRunning, IncomingReceived, OutgoingProgress, ...).
/// </summary>
LinphoneCallState GetState();
/// <summary>
/// Gets the remote LinphoneAddress.
/// </summary>
LinphoneAddress^ GetRemoteAddress();
/// <summary>
/// Returns the CallDirection (Outgoing or incoming).
/// </summary>
CallDirection GetDirection();
/// <summary>
/// Gets the LinphoneCallLog associated with this call.
/// </summary>
LinphoneCallLog^ GetCallLog();
/// <summary>
/// Gets the audio stats associated with this call.
/// </summary>
LinphoneCallStats^ GetAudioStats();
/// <summary>
......
......@@ -16,9 +16,24 @@ namespace Linphone
public ref class LinphoneCallLog sealed
{
public:
/// <summary>
/// Gets the LinphoneAddress of the caller.
/// </summary>
LinphoneAddress^ GetFrom();
/// <summary>
/// Gets the LinphoneAddress of the callee.
/// </summary>
LinphoneAddress^ GetTo();
/// <summary>
/// Gets the CallDirection of the call (Incoming or Outgoing).
/// </summary>
CallDirection GetDirection();
/// <summary>
/// Gets the LinphoneCallStatus of the call (Success, Aborted, Missed or Declined).
/// </summary>
LinphoneCallStatus GetStatus();
/// <summary>
......
......@@ -20,8 +20,20 @@ namespace Linphone
/// </summary>
/// <param name="value">0 to disable limitation</param>
void SetAudioBandwidth(int value);
/// <summary>
/// Returns the MediaEncryption of the call (None, SRTP or ZRTP).
/// </summary>
MediaEncryption GetMediaEncryption();
/// <summary>
/// Sets the MediaEncryption (None, SRTP or ZRTP).
/// </summary>
void SetMediaEncryption(MediaEncryption menc);
/// <summary>
/// Returns the PayloadType currently in use for the audio stream.
/// </summary>
PayloadType^ GetUsedAudioCodec();
/// <summary>
......@@ -31,6 +43,11 @@ namespace Linphone
/// Video is automatically disabled.
/// </summary>
void EnableLowBandwidth(Platform::Boolean enable);
/// <summary>
/// Gets if the low bandwidth mode is enabled.
/// See EnableLowBandwidth(boolean enable).
/// </summary>
Platform::Boolean IsLowBandwidthEnabled();
};
}
......
......@@ -812,7 +812,7 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
Linphone::Core::CallController^ callController = Linphone::Core::Globals::Instance->CallController;
if (state == Linphone::Core::LinphoneCallState::IncomingReceived) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = callController->OnIncomingCallReceived(lCall, lCall->GetRemoteContact(), lCall->GetRemoteAddress()->AsStringUriOnly(), nullptr);
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = callController->OnIncomingCallReceived(lCall, lCall->GetRemoteContact(), lCall->GetRemoteAddress()->AsStringUriOnly(), callController->IncomingCallViewDismissed);
lCall->CallContext = platformCall;
}
else if (state == Linphone::Core::LinphoneCallState::OutgoingProgress) {
......@@ -822,6 +822,11 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
else if (state == Linphone::Core::LinphoneCallState::CallEnd || state == Linphone::Core::LinphoneCallState::Error) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = (Windows::Phone::Networking::Voip::VoipPhoneCall^) lCall->CallContext;
platformCall->NotifyCallEnded();
if (callController->IncomingCallViewDismissed != nullptr) {
// When we receive a call with PN, call the callback to kill the agent process in case the caller stops the call before user accepts/denies it
callController->IncomingCallViewDismissed();
}
}
else if (state == Linphone::Core::LinphoneCallState::Paused || state == Linphone::Core::LinphoneCallState::PausedByRemote) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = (Windows::Phone::Networking::Voip::VoipPhoneCall^) lCall->CallContext;
......
......@@ -62,6 +62,10 @@ namespace Linphone
static void SetLogLevel(OutputTraceLevel logLevel);
void SetContext(Platform::Object^ object);
/// <summary>
/// Removes all the proxy configs from LinphoneCore.
/// </summary>
void ClearProxyConfigs();
/// <summary>
......@@ -90,8 +94,14 @@ namespace Linphone
/// </summary>
LinphoneProxyConfig^ CreateEmptyProxyConfig();
/// <summary>
/// Gets the list of the current proxy configs.
/// </summary>
Windows::Foundation::Collections::IVector<Platform::Object^>^ GetProxyConfigList();
/// <summary>
/// Removes all the auth infos from LinphoneCore.
/// </summary>
void ClearAuthInfos();
/// <summary>
......@@ -132,7 +142,15 @@ namespace Linphone
/// The LinphoneAddress can be constructed directly using LinphoneCoreFactory::CreateLinphoneAddress or InterpretURL.
/// </summary>
LinphoneCall^ InviteAddress(LinphoneAddress^ to);
/// <summary>
///
/// </summary>
LinphoneCall^ InviteAddressWithParams(LinphoneAddress^ destination, LinphoneCallParams^ params);
/// <summary>
/// Terminates the given call if running.
/// </summary>
void TerminateCall(LinphoneCall^ call);
/// <returns>
......@@ -144,7 +162,15 @@ namespace Linphone
/// nullptr if no call engaged yet.
/// </returns>
LinphoneAddress^ GetRemoteAddress();
/// <summary>
/// Returns true if at least a call is running, else returns false.
/// </summary>
Platform::Boolean IsInCall();
/// <summary>
/// Returns true if there is an incoming call invite pending, else returns false.
/// </summary>
Platform::Boolean IsIncomingInvitePending();
/// <summary>
......@@ -170,7 +196,15 @@ namespace Linphone
/// Prevent LinphoneCore from performing an automatic answer.
/// </summary>
void DeferCallUpdate(LinphoneCall^ call);
/// <summary>
/// Updates the given call with the given params if the remote agrees.
/// </summary>
void UpdateCall(LinphoneCall^ call, LinphoneCallParams^ params);
/// <summary>
/// Returns a default set of LinphoneCallParams.
/// </summary>
LinphoneCallParams^ CreateDefaultCallParameters();
/// <summary>
......@@ -178,7 +212,15 @@ namespace Linphone
/// Returns a IList&lt;Object&gt; where each object is a LinphoneCallLog.
/// </summary>
Windows::Foundation::Collections::IVector<Platform::Object^>^ GetCallLogs();
/// <summary>
/// Removes all call logs from the LinphoneCore.
/// </summary>
void ClearCallLogs();
/// <summary>
/// Removes a specific log from the LinphoneCore.
/// </summary>
void RemoveCallLog(LinphoneCallLog^ log);
/// <summary>
......@@ -187,6 +229,10 @@ namespace Linphone
/// This method disables the automatic registration mode. It means you must call this method after each network state changes.
/// </summary>
void SetNetworkReachable(Platform::Boolean isReachable);
/// <summary>
/// Returns true if the network has been set as reachable, else returns false.
/// </summary>
Platform::Boolean IsNetworkReachable();
/// <summary>
......@@ -217,6 +263,10 @@ namespace Linphone
/// Mutes or unmutes the local microphone.
/// </summary>
void MuteMic(Platform::Boolean isMuted);
/// <summary>
/// Returns true if the microphone is muted, else returns false.
/// </summary>
Platform::Boolean IsMicMuted();
/// <summary>
......@@ -236,7 +286,14 @@ namespace Linphone
/// </summary>
void StopDTMF();
/// <summary>
/// Tries to return the PayloadType matching the given mime, clockrate and channels.
/// </summary>
PayloadType^ FindPayloadType(Platform::String^ mime, int clockRate, int channels);
/// <summary>
/// Tries to return the PayloadType matching the given mime and clockrate.
/// </summary>
PayloadType^ FindPayloadType(Platform::String^ mime, int clockRate);
/// <summary>
......@@ -281,19 +338,35 @@ namespace Linphone
/// </summary>
/// <param name="stun">STUN server address and port, such as stun.linphone.org or stun.linphone.org:3478</param>
void SetStunServer(Platform::String^ stun);
/// <summary>
/// Returs the address of the configured STUN server if any.
/// </summary>
Platform::String^ GetStunServer();
/// <summary>
/// Sets policy regarding workarounding NATs.
/// </summary>
void SetFirewallPolicy(FirewallPolicy policy);
/// <summary>
/// Gets the policy regarding workarounding NATs.
/// </summary>
FirewallPolicy GetFirewallPolicy();
/// <summary>
/// Sets the file or folder containing trusted root CAs
/// </summary>
void SetRootCA(Platform::String^ path);
/// <summary>
/// Sets the upload bandwidth.
/// </summary>
void SetUploadBandwidth(int bw);
/// <summary>
/// Sets the download bandwidth.
/// </summary>
void SetDownloadBandwidth(int bw);
/// <summary>
......@@ -310,6 +383,10 @@ namespace Linphone
/// Enables signaling keep alive. Small UDP packet sent periodically to keep UDP NAT association.
/// </summary>
void EnableKeepAlive(Platform::Boolean enable);
/// <summary>
/// Returns true if the signaling keep alive is enabled, else returns false.
/// </summary>
Platform::Boolean IsKeepAliveEnabled();
void SetPlayFile(Platform::String^ path);
......@@ -359,7 +436,15 @@ namespace Linphone
void SetUserAgent(Platform::String^ name, Platform::String^ version);
void SetCPUCount(int count);
/// <summary>
/// Gets the number of missed calls since last reset.
/// </summary>
int GetMissedCallsCount();
/// <summary>
/// Reset the count of missed calls.
/// </summary>
void ResetMissedCallsCount();
/// <summary>
......
......@@ -30,7 +30,14 @@ namespace Linphone
/// </summary>
void Done();
/// <summary>
/// Sets the identity for this proxy config.
/// </summary>
void SetIdentity(Platform::String^ displayname, Platform::String^ username, Platform::String^ domain);
/// <summary>
/// Gets the identity associated with this proxy config.
/// </summary>
Platform::String^ GetIdentity();
/// <summary>
......@@ -60,6 +67,10 @@ namespace Linphone
/// Register message is issued after call to Done.
/// </summary>
void EnableRegister(Platform::Boolean enable);
/// <summary>
/// Returns true if the register is enabled for this proxy config, else returns false.
/// </summary>
Platform::Boolean IsRegisterEnabled();
/// <summary>
......@@ -79,8 +90,20 @@ namespace Linphone
/// Sets whether Linphone should replace "+" by "00" in dialed numbers passed to LinphoneCore::Invite.
/// </summary>
void SetDialEscapePlus(Platform::Boolean value);
/// <summary>
/// Gets the address.
/// </summary>
Platform::String^ GetAddr();
/// <summary>
/// Gets the domain of the address.
/// </summary>
Platform::String^ GetDomain();
/// <summary>
/// Returns true if this proxy config is currently registered, else returns false.
/// </summary>
Platform::Boolean IsRegistered();
/// <summary>
......@@ -88,19 +111,35 @@ namespace Linphone
/// When a route is set, all outgoing calls will go the the route's destination if this proxy is the default one (see LinphoneCore::GetDefaultProxyConfig).
/// </summary>
void SetRoute(Platform::String^ routeUri);
/// <summary>
/// Returns the SIP route is any.
/// </summary>
Platform::String^ GetRoute();
/// <summary>
/// Indicates either or not PUBLISH must be issued for this LinphoneProxyConfig.
/// </summary>
void EnablePublish(Platform::Boolean enable);
/// <summary>
/// Returns true if PUBLISH must be issued, else returns false.
/// </summary>
Platform::Boolean IsPublishEnabled();
/// <summary>
/// Returns the current RegistrationState for this proxy config.
/// </summary>
RegistrationState GetState();
/// <summary>
/// Sets the registration expiration time in seconds.
/// </summary>
void SetExpires(int delay);
/// <summary>
/// Sets the contact params to be sent along with the REGISTERs.
/// </summary>
void SetContactParameters(Platform::String^ params);
/// <summary>
......
......@@ -10,8 +10,16 @@ namespace Linphone
class Utils
{
public:
/// <summary>
/// Converts a Platform::String into a C char*.
/// Required to send strings from C# to C.
/// </summary>
static const char* pstoccs(Platform::String^ ps);
/// <summary>
/// Converts a C char* to a Platform::String.
/// Required to send strings from C to C#.
/// </summary>
static Platform::String^ Linphone::Core::Utils::cctops(const char*);
/// <summary>
......@@ -28,20 +36,44 @@ namespace Linphone
/// </summary>
static void LinphoneCoreSetLogLevel(int loglevel);
static Platform::Object^ CreateLpConfig(void *config);
static Platform::Object^ CreateLpConfig(Platform::String^ configPath, Platform::String^ factoryConfigPath);
/// <summary>
/// Creates a C++/CX LpConfig object using pointer to C structure.
/// </summary>
static Platform::Object^ CreateLpConfig(void *config);
/// <summary>
/// Creates a C++/CX LpConfig object using the path to linphonerc files.
/// </summary>
static Platform::Object^ CreateLpConfig(Platform::String^ configPath, Platform::String^ factoryConfigPath);
/// <summary>
/// Creates a C++/CX PayloadType object using pointer to C structure.
/// </summary>
static Platform::Object^ CreatePayloadType(void *pt);
/// <summary>
/// Creates a C++/CX LinphoneCall object using pointer to C structure.
/// </summary>
static Platform::Object^ CreateLinphoneCall(void* call);
/// <summary>
/// Creates a C++/CX LinphoneAddress object using pointer to C structure.
/// </summary>
static Platform::Object^ CreateLinphoneAddress(void* addr);
/// <summary>
/// Creates a C++/CX LinphoneAddress object using an URI.
/// </summary>
static Platform::Object^ CreateLinphoneAddressFromUri(const char *uri);
/// <summary>
/// Creates a C++/CX LinphoneAuthInfo object using pointer to C structure.
/// </summary>
static Platform::Object^ CreateLinphoneAuthInfo(void *auth_info);
/// <summary>
/// Creates a C++/CX LinphoneCallLog object using pointer to C structure.
/// </summary>
static Platform::Object^ CreateLinphoneCallLog(void* calllog);
private:
......
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