Commit 41d58ac7 authored by Ghislain MARY's avatar Ghislain MARY

Add C# API for call transfer.

parent 067257a6
......@@ -122,6 +122,12 @@ void Call::EchoLimiterEnabled::set(Platform::Boolean enable)
linphone_call_enable_echo_limiter(this->call, enable);
}
Platform::Boolean Call::HasTransferPending::get()
{
API_LOCK;
return (linphone_call_has_transfer_pending(this->call) == TRUE);
}
Platform::Boolean Call::IsInConference::get()
{
API_LOCK;
......@@ -163,6 +169,12 @@ Reason Call::Reason::get()
return (BelledonneCommunications::Linphone::Native::Reason)linphone_call_get_reason(this->call);
}
Platform::String^ Call::ReferTo::get()
{
API_LOCK;
return Utils::cctops(linphone_call_get_refer_to(this->call));
}
Platform::String^ Call::RemoteContact::get()
{
API_LOCK;
......@@ -188,12 +200,36 @@ Platform::String^ Call::RemoteUserAgent::get()
return Utils::cctops(linphone_call_get_remote_user_agent(this->call));
}
Call^ Call::ReplacedCall::get()
{
API_LOCK;
return (Call^)Utils::GetCall((void *)linphone_call_get_replaced_call(this->call));
}
CallState Call::State::get()
{
API_LOCK;
return (CallState)linphone_call_get_state(this->call);
}
Call^ Call::TransfererCall::get()
{
API_LOCK;
return (Call^)Utils::GetCall((void *)linphone_call_get_transferer_call(this->call));
}
CallState Call::TransferState::get()
{
API_LOCK;
return (CallState)linphone_call_get_transfer_state(this->call);
}
Call^ Call::TransferTargetCall::get()
{
API_LOCK;
return (Call^)Utils::GetCall((void *)linphone_call_get_transfer_target_call(this->call));
}
CallStats^ Call::VideoStats::get()
{
API_LOCK;
......
......@@ -156,6 +156,16 @@ namespace BelledonneCommunications
void set(Platform::Boolean value);
}
/// <summary>
/// Returns true if this calls has received a transfer that has not been executed yet.
/// Pending transfers are executed when this call is being paused or closed, locally or by remote endpoint.
/// If the call is already paused while receiving the transfer request, the transfer immediately occurs.
/// </summary>
property Platform::Boolean HasTransferPending
{
Platform::Boolean get();
}
/// <summary>
/// Tells whether the call is in conference or not.
/// </summary>
......@@ -198,6 +208,14 @@ namespace BelledonneCommunications
BelledonneCommunications::Linphone::Native::Reason get();
}
/// <summary>
/// Gets the refer-to uri (if the call was transfered)
/// </summary>
property Platform::String^ ReferTo
{
Platform::String^ get();
}
/// <summary>
/// Gets the remote Address.
/// </summary>
......@@ -232,6 +250,17 @@ namespace BelledonneCommunications
Platform::String^ get();
}
/// <summary>
/// Returns the call object this call is replacing, if any.
/// Call replacement can occur during call transfers.
/// By default, the core automatically terminates the replaced call and accept the new one.
/// This function allows the application to know whether a new incoming call is a one that replaces another one.
/// </summary>
property Call^ ReplacedCall
{
Call^ get();
}
/// <summary>
/// Gets the CallState of the call (StreamRunning, IncomingReceived, OutgoingProgress, ...).
/// </summary>
......@@ -240,6 +269,31 @@ namespace BelledonneCommunications
CallState get();
}
/// <summary>
/// Gets the transferer if this call was started automatically as a result of an incoming transfer request.
/// The call in which the transfer request was received is returned in this case.
/// </summary>
property Call^ TransfererCall
{
Call^ get();
}
/// <summary>
/// Returns the current transfer state, if a transfer has been initiated from this call.
/// </summary>
property CallState TransferState
{
CallState get();
}
/// <summary>
/// When this call has received a transfer request, returns the new call that was automatically created as a result of the transfer.
/// </summary>
property Call^ TransferTargetCall
{
Call^ get();
}
/// <summary>
/// Gets the video statistics associated with this call.
/// </summary>
......
......@@ -1225,6 +1225,13 @@ void Core::SetUserAgent(Platform::String^ name, Platform::String^ version)
delete(ua);
}
Call^ Core::StartReferedCall(Call^ call, CallParams^ params)
{
API_LOCK;
::LinphoneCall *ccall = linphone_core_start_refered_call(this->lc, call->call, params->params);
return (Call^)Utils::GetCall(ccall);
}
void Core::StopDtmf()
{
API_LOCK;
......@@ -1249,6 +1256,21 @@ void Core::TerminateConference()
linphone_core_terminate_conference(this->lc);
}
int Core::TransferCall(Call^ call, Platform::String^ referTo)
{
API_LOCK;
const char *refer_to = Utils::pstoccs(referTo);
int ret = linphone_core_transfer_call(this->lc, call->call, refer_to);
delete refer_to;
return ret;
}
int Core::TransferCallToAnother(Call^ call, Call^ dest)
{
API_LOCK;
return linphone_core_transfer_call_to_another(this->lc, call->call, dest->call);
}
void Core::UpdateCall(Call^ call, CallParams^ params)
{
API_LOCK;
......@@ -1327,6 +1349,18 @@ void registration_state_changed(::LinphoneCore *lc, ::LinphoneProxyConfig *cfg,
}
}
void transfer_state_changed(::LinphoneCore *lc, ::LinphoneCall *ctransfered, ::LinphoneCallState new_call_state)
{
Core^ lCore = (Core^)Utils::GetCore(lc);
CoreListener^ listener = lCore->CoreListener;
if (listener != nullptr) {
CallState newCallState = (CallState)new_call_state;
RefToPtrProxy<Call^> *proxy = reinterpret_cast< RefToPtrProxy<Call^> *>(linphone_call_get_user_data(ctransfered));
Call^ transfered = (proxy) ? proxy->Ref() : nullptr;
listener->TransferStateChanged(transfered, newCallState);
}
}
void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCallState cstate, const char *msg)
{
Core^ lCore = (Core^)Utils::GetCore(lc);
......@@ -1471,6 +1505,7 @@ void Core::Init()
memset (vtable, 0, sizeof(LinphoneCoreVTable));
vtable->global_state_changed = global_state_changed;
vtable->registration_state_changed = registration_state_changed;
vtable->transfer_state_changed = transfer_state_changed;
vtable->call_state_changed = call_state_changed;
vtable->auth_info_requested = auth_info_requested;
vtable->message_received = message_received;
......
......@@ -1024,6 +1024,15 @@ namespace BelledonneCommunications
/// <param name="version">The user agent version to set</param>
void SetUserAgent(Platform::String^ name, Platform::String^ version);
/// <summary>
/// Start a new call as a consequence of a transfer request received from a call.
/// This function is for advanced usage: the execution of transfers is automatically managed by the LinphoneCore. However if an application
/// wants to have control over the call parameters for the new call, it should call this function immediately during the LinphoneCallRefered notification.
/// </summary>
/// <param name="call">A call that has just been notified about LinphoneCallRefered state event</param>
/// <param name="params">The call parameters to be applied to the new call</param>
Call^ StartReferedCall(Call^ call, CallParams^ params);
/// <summary>
/// Stops the current playing DTMF.
/// </summary>
......@@ -1046,6 +1055,35 @@ namespace BelledonneCommunications
/// </summary>
void TerminateConference();
/// <summary>
/// Performs a simple call transfer to the specified destination.
/// The remote endpoint is expected to issue a new call to the specified destination.
/// The current call remains active and thus can be later paused or terminated.
/// It is possible to follow the progress of the transfer provided that transferee sends notification about it.
/// In this case, the transfer_state_changed callback of the LinphoneCoreVTable is invoked to notify of the state of the new call at the other party.
/// The notified states are LinphoneCallOutgoingInit, LinphoneCallOutgoingProgress, LinphoneCallOutgoingRinging and LinphoneCallConnected.
/// </summary>
/// <param name="call">The call to be transfered</param>
/// <param name="referTo">The destination the call is to be refered to</param>
/// <returns>0 on success, -1 on failure</returns>
int TransferCall(Call^ call, Platform::String^ referTo);
/// <summary>
/// Transfers a call to destination of another running call. This is used for "attended transfer" scenarios.
/// The transfered call is supposed to be in paused state, so that it is able to accept the transfer immediately.
/// The destination call is a call previously established to introduce the transfered person.
/// This method will send a transfer request to the transfered person.The phone of the transfered is then
/// expected to automatically call to the destination of the transfer.The receiver of the transfer will then automatically
/// close the call with us(the 'dest' call).
/// It is possible to follow the progress of the transfer provided that transferee sends notification about it.
/// In this case, the transfer_state_changed callback of the LinphoneCoreVTable is invoked to notify of the state of the new call at the other party.
/// The notified states are LinphoneCallOutgoingInit, LinphoneCallOutgoingProgress, LinphoneCallOutgoingRinging and LinphoneCallConnected.
/// </summary>
/// <param name="call">A running call you want to transfer</param>
/// <param name="dest">A running call whose remote person will receive the transfer</param>
/// <returns>0 on success, -1 on failure</returns>
int TransferCallToAnother(Call^ call, Call^ dest);
/// <summary>
/// Updates the given call with the given params if the remote agrees.
/// </summary>
......
......@@ -120,6 +120,13 @@ namespace BelledonneCommunications
/// <param name="state">The new registration state for the proxy config</param>
/// <param name="message">A message describing the new registration state</param>
void RegistrationStateChanged(ProxyConfig^ config, RegistrationState state, Platform::String^ message);
/// <summary>
/// Callback for notifying progresses of transfers.
/// </summary>
/// <param name="transfered">The call that was transfered</param>
/// <param name="newCallState">The state of the call to transfer target at the far end</param>
void TransferStateChanged(Call^ transfered, CallState newCallState);
};
}
}
......
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