Commit aa17a1b2 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Outgoing calls, step one

parent cb5165c9
......@@ -43,7 +43,6 @@ namespace Linphone.Agents
callerNumber = incomingCallPN.First().ToString();
Debug.WriteLine("[{0}] Incoming call from caller {1}, number {2}", "KeepAliveAgent", callerName, callerNumber);
LinphoneCall call = new LinphoneCall(callerName, callerNumber);
Debug.WriteLine("[KeepAliveAgent] Incoming call added to LinphoneCore, notifyComplete");
base.NotifyComplete();
......
......@@ -49,5 +49,5 @@ Linphone::Core::LinphoneAuthInfo::LinphoneAuthInfo(Platform::String^ username, P
Linphone::Core::LinphoneAuthInfo::~LinphoneAuthInfo()
{
delete(this->auth_info);
}
\ No newline at end of file
......@@ -17,8 +17,7 @@ Linphone::Core::LinphoneCallState Linphone::Core::LinphoneCall::GetState()
Linphone::Core::LinphoneAddress^ Linphone::Core::LinphoneCall::GetRemoteAddress()
{
Linphone::Core::LinphoneCoreFactory^ lcf = Globals::Instance->LinphoneCoreFactory;
return lcf->CreateLinphoneAddress(this->number);
return nullptr;
}
Linphone::Core::CallDirection Linphone::Core::LinphoneCall::GetDirection()
......@@ -113,7 +112,7 @@ Platform::String^ Linphone::Core::LinphoneCall::GetRemoteUserAgent()
Platform::String^ Linphone::Core::LinphoneCall::GetRemoteContact()
{
return this->contact;
return nullptr;
}
void Linphone::Core::LinphoneCall::CallContext::set(Platform::Object^ cc)
......@@ -126,8 +125,13 @@ Platform::Object^ Linphone::Core::LinphoneCall::CallContext::get()
return this->callContext;
}
Linphone::Core::LinphoneCall::LinphoneCall(Platform::String^ contact, Platform::String^ number) :
contact(contact),
number(number)
Linphone::Core::LinphoneCall::LinphoneCall(::LinphoneCall *call) :
call(call)
{
linphone_call_set_user_pointer(this->call, Linphone::Core::Utils::GetRawPointer(this));
}
Linphone::Core::LinphoneCall::~LinphoneCall()
{
}
\ No newline at end of file
#pragma once
#include "Enums.h"
#include "LinphoneCore.h"
namespace Linphone
{
......@@ -94,15 +95,15 @@ namespace Linphone
void set(Platform::Object^ cc);
}
LinphoneCall(Platform::String^ contact, Platform::String^ number);
private:
friend class Linphone::Core::Utils;
friend ref class Linphone::Core::LinphoneCore;
Platform::Object^ callContext;
LinphoneCall(::LinphoneCall *call);
~LinphoneCall();
Platform::String^ contact;
Platform::String^ number;
Platform::Object^ callContext;
::LinphoneCall *call;
};
}
}
\ No newline at end of file
......@@ -132,7 +132,14 @@ Linphone::Core::LinphoneAddress^ Linphone::Core::LinphoneCore::InterpretURL(Plat
Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::Invite(Platform::String^ destination)
{
return nullptr;
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
const char *cc = Linphone::Core::Utils::pstoccs(destination);
::LinphoneCall *call = linphone_core_invite(this->lc, cc);
delete(cc);
Linphone::Core::LinphoneCall^ lCall = reinterpret_cast<Linphone::Core::LinphoneCall^>(linphone_call_get_user_pointer(call));
return lCall;
}
Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::InviteAddress(Linphone::Core::LinphoneAddress^ to)
......@@ -147,12 +154,14 @@ Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::InviteAddressWithPar
void Linphone::Core::LinphoneCore::TerminateCall(Linphone::Core::LinphoneCall^ call)
{
linphone_core_terminate_call(this->lc, call->call);
}
Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::GetCurrentCall()
{
return nullptr;
::LinphoneCall *call = linphone_core_get_current_call(this->lc);
Linphone::Core::LinphoneCall^ lCall = reinterpret_cast<Linphone::Core::LinphoneCall^>(linphone_call_get_user_pointer(call));
return lCall;
}
Linphone::Core::LinphoneAddress^ Linphone::Core::LinphoneCore::GetRemoteAddress()
......@@ -486,7 +495,7 @@ IVector<Linphone::Core::LinphoneCall^>^ Linphone::Core::LinphoneCore::GetCalls()
int Linphone::Core::LinphoneCore::GetCallsNb()
{
return 0;
return linphone_core_get_calls_nb(this->lc);
}
Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::FindCallFromUri(Platform::String^ uri)
......@@ -651,11 +660,17 @@ Linphone::Core::LinphoneCoreListener^ Linphone::Core::LinphoneCore::CoreListener
void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCallState cstate, const char *msg)
{
/*Linphone::Core::LinphoneCoreListener^ listener = Linphone::Core::Globals::Instance->LinphoneCore->CoreListener;
Linphone::Core::LinphoneCoreListener^ listener = Linphone::Core::Globals::Instance->LinphoneCore->CoreListener;
if (listener != nullptr)
{
listener->CallState(call, cstate);
}*/
Linphone::Core::LinphoneCallState state = (Linphone::Core::LinphoneCallState) cstate;
Linphone::Core::LinphoneCall^ lCall = reinterpret_cast<Linphone::Core::LinphoneCall^>(linphone_call_get_user_pointer(call));
if (lCall == nullptr)
{
lCall = (Linphone::Core::LinphoneCall^)Linphone::Core::Utils::CreateLinphoneCall(call);
}
listener->CallState(lCall, state);
}
}
void registration_state_changed(::LinphoneCore *lc, ::LinphoneProxyConfig *cfg, ::LinphoneRegistrationState cstate, const char *msg)
......
......@@ -7,7 +7,7 @@
using namespace Linphone::Core;
using namespace Platform;
#define MAX_TRACE_SIZE 512
#define MAX_TRACE_SIZE 1024
#define MAX_SUITE_NAME_SIZE 128
static OutputTraceListener^ sTraceListener;
......
#include "Utils.h"
#include "LinphoneCall.h"
std::string Linphone::Core::Utils::wstos(std::wstring ws)
{
......@@ -39,3 +40,8 @@ void* Linphone::Core::Utils::GetRawPointer(Platform::Object^ object)
{
return reinterpret_cast<IInspectable*>(object);
}
Platform::Object^ Linphone::Core::Utils::CreateLinphoneCall(void* call)
{
return ref new Linphone::Core::LinphoneCall((::LinphoneCall*)call);
}
\ No newline at end of file
......@@ -16,6 +16,8 @@ namespace Linphone
static void* GetRawPointer(Platform::Object^ object);
static Platform::Object^ CreateLinphoneCall(void* call);
private:
static std::string wstos(std::wstring ws);
......
No preview for this file type
......@@ -335,11 +335,11 @@ namespace Linphone.Model
/// <param name="sipAddress">SIP address to call</param>
public void NewOutgoingCall(String sipAddress)
{
VoipPhoneCall call;
CallController.RequestNewOutgoingCall("/Linphone;component/Views/InCall.xaml?sip=" + sipAddress, sipAddress, "Linphone", VoipCallMedia.Audio, out call);
call.NotifyCallActive();
//VoipPhoneCall call;
//CallController.RequestNewOutgoingCall("/Linphone;component/Views/InCall.xaml?sip=" + sipAddress, sipAddress, "Linphone", VoipCallMedia.Audio, out call);
//call.NotifyCallActive();
LinphoneCall LCall = LinphoneCore.Invite(sipAddress);
LCall.CallContext = call;
//LCall.CallContext = call;
}
/// <summary>
......@@ -400,49 +400,54 @@ namespace Linphone.Model
/// </summary>
public void CallState(LinphoneCall call, LinphoneCallState state)
{
Debug.WriteLine("[LinphoneManager] Call state changed: " + call.GetRemoteAddress().AsStringUriOnly() + " => " + state.ToString());
if (state == LinphoneCallState.IncomingReceived)
Debug.WriteLine("[LinphoneManager] Call state changed: " + /*call.GetRemoteAddress().AsStringUriOnly() + " => " +*/ state.ToString());
if (state == LinphoneCallState.OutgoingProgress)
{
String contact = call.GetRemoteContact();
String number = call.GetRemoteAddress().AsStringUriOnly();
Debug.WriteLine("[LinphoneManager] Incoming received: " + contact + " (" + number + ")");
BaseModel.UIDispatcher.BeginInvoke(() =>
{
VoipPhoneCall vcall = null;
Uri contactUri = new Uri(server.Path + "\\Assets\\unknown.png", UriKind.Absolute);
Uri iconUri = new Uri(server.Path + "\\Assets\\pnicon.png", UriKind.Absolute);
Uri ringtoneUri = new Uri(server.Path + "\\Assets\\Sounds\\Ringtone.wma", UriKind.Absolute);
CallController.RequestNewIncomingCall("/Linphone;component/Views/InCall.xaml?sip=" + number, contact, number, contactUri, "Linphone", iconUri, "", ringtoneUri, VoipCallMedia.Audio, fifteenSecs, out vcall);
vcall.AnswerRequested += ((c, eventargs) =>
{
Debug.WriteLine("[LinphoneManager] Call accepted");
vcall.NotifyCallActive();
LinphoneCore.AcceptCall(call);
});
vcall.RejectRequested += ((c, eventargs) =>
{
Debug.WriteLine("[LinphoneManager] Call rejected");
LinphoneCore.TerminateCall(call);
});
call.CallContext = vcall;
});
}
else if (state == LinphoneCallState.StreamsRunning)
{
Debug.WriteLine("[LinphoneManager] Call accepted and running");
if (CallListener != null)
CallListener.NewCallStarted(call.GetRemoteAddress().AsStringUriOnly());
}
CallListener.NewCallStarted("");
}
//if (state == LinphoneCallState.IncomingReceived)
//{
// String contact = call.GetRemoteContact();
// String number = call.GetRemoteAddress().AsStringUriOnly();
// Debug.WriteLine("[LinphoneManager] Incoming received: " + contact + " (" + number + ")");
// BaseModel.UIDispatcher.BeginInvoke(() =>
// {
// VoipPhoneCall vcall = null;
// Uri contactUri = new Uri(server.Path + "\\Assets\\unknown.png", UriKind.Absolute);
// Uri iconUri = new Uri(server.Path + "\\Assets\\pnicon.png", UriKind.Absolute);
// Uri ringtoneUri = new Uri(server.Path + "\\Assets\\Sounds\\Ringtone.wma", UriKind.Absolute);
// CallController.RequestNewIncomingCall("/Linphone;component/Views/InCall.xaml?sip=" + number, contact, number, contactUri, "Linphone", iconUri, "", ringtoneUri, VoipCallMedia.Audio, fifteenSecs, out vcall);
// vcall.AnswerRequested += ((c, eventargs) =>
// {
// Debug.WriteLine("[LinphoneManager] Call accepted");
// vcall.NotifyCallActive();
// LinphoneCore.AcceptCall(call);
// });
// vcall.RejectRequested += ((c, eventargs) =>
// {
// Debug.WriteLine("[LinphoneManager] Call rejected");
// LinphoneCore.TerminateCall(call);
// });
// call.CallContext = vcall;
// });
//}
//else if (state == LinphoneCallState.StreamsRunning)
//{
// Debug.WriteLine("[LinphoneManager] Call accepted and running");
// if (CallListener != null)
// CallListener.NewCallStarted(call.GetRemoteAddress().AsStringUriOnly());
//}
else if (state == LinphoneCallState.CallEnd || state == LinphoneCallState.Error)
{
Debug.WriteLine("[LinphoneManager] Call ended");
((VoipPhoneCall)call.CallContext).NotifyCallEnded();
//((VoipPhoneCall)call.CallContext).NotifyCallEnded();
if (CallListener != null)
CallListener.CallEnded();
......
......@@ -81,7 +81,6 @@
<Interface Name="Linphone.Core.OutOfProcess.__IServerPublicNonVirtuals" InterfaceId="{46DDE636-87D1-3A06-9D4A-D0753804368A}" />
<Interface Name="Linphone.Core.__ILinphoneAuthInfoPublicNonVirtuals" InterfaceId="{C7039DF8-D910-3633-A2E1-FB0B176790C0}" />
<Interface Name="Linphone.Core.__ILinphoneCallPublicNonVirtuals" InterfaceId="{0985A9C4-838F-3350-AA92-3D22BCBA35D9}" />
<Interface Name="Linphone.Core.__ILinphoneCallFactory" InterfaceId="{95F1BD28-F1E2-379F-B44C-1553EEA60023}" />
<Interface Name="Linphone.Core.__ILinphoneCallStatsPublicNonVirtuals" InterfaceId="{87BCE67E-109C-3429-9255-76FC496C3382}" />
<Interface Name="Linphone.Core.__ILinphoneCallLogPublicNonVirtuals" InterfaceId="{F3C079C9-0A9C-3B02-A1CC-C61991D09E18}" />
<Interface Name="Linphone.Core.__ILinphoneCallParamsPublicNonVirtuals" InterfaceId="{26EFBF2D-6F46-35DE-9CFA-1A784C3C5A35}" />
......
......@@ -58,7 +58,7 @@ namespace Linphone
{
if (address != null && address.Length > 0)
{
NavigationService.Navigate(new Uri("/Views/InCall.xaml?sip=" + address, UriKind.RelativeOrAbsolute));
//NavigationService.Navigate(new Uri("/Views/InCall.xaml?sip=" + address, UriKind.RelativeOrAbsolute));
LinphoneManager.Instance.NewOutgoingCall(addressBox.Text);
}
}
......
linphone @ 4ee33b24
Subproject commit 02b05eede44d91ea46d04cb78814c85144aaf675
Subproject commit 4ee33b2459883210b6ea53aded805483ec3c50a8
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