Commit 1519a9f5 authored by Ghislain MARY's avatar Ghislain MARY

Reintroduce the VoipCallCoordinator in the linphone wrapper to register calls...

Reintroduce the VoipCallCoordinator in the linphone wrapper to register calls to the system (needed to be able to activate the speaker).
parent f9063b96
......@@ -71,6 +71,8 @@ set(SOURCE_FILES
VideoPolicy.h
VideoSize.cpp
VideoSize.h
VoipCallController.cpp
VoipCallController.h
)
set(LIBS ${LINPHONE_LIBRARIES})
......
......@@ -207,12 +207,6 @@ void Call::SendVFURequest()
}
#if 0
void Call::CallContext::set(Windows::Phone::Networking::Voip::VoipPhoneCall^ cc)
{
API_LOCK;
this->callContext = cc;
}
Platform::Object^ Call::CallStartTimeFromContext::get()
{
API_LOCK;
......@@ -226,12 +220,18 @@ Platform::Object^ Call::CallStartTimeFromContext::get()
}
return result;
}
#endif
Windows::Phone::Networking::Voip::VoipPhoneCall^ Call::CallContext::get()
Windows::ApplicationModel::Calls::VoipPhoneCall^ Call::CallContext::get()
{
return this->callContext;
}
#endif
void Call::CallContext::set(Windows::ApplicationModel::Calls::VoipPhoneCall^ cc)
{
API_LOCK;
this->callContext = cc;
}
Call::Call(::LinphoneCall *call)
: call(call)
......
......@@ -35,6 +35,7 @@ namespace BelledonneCommunications
/// Object representing a call.
/// Calls are create using Core::Invite or passed to the application by the listener CoreListener::CallState.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public ref class Call sealed
{
public:
......@@ -260,16 +261,16 @@ namespace BelledonneCommunications
{
Platform::Object^ get();
}
#endif
/// <summary>
/// Gets the CallContext object (native VoipPhoneCall)
/// </summary>
property Windows::Phone::Networking::Voip::VoipPhoneCall^ CallContext
property Windows::ApplicationModel::Calls::VoipPhoneCall^ CallContext
{
Windows::Phone::Networking::Voip::VoipPhoneCall^ get();
void set(Windows::Phone::Networking::Voip::VoipPhoneCall^ cc);
Windows::ApplicationModel::Calls::VoipPhoneCall^ get();
void set(Windows::ApplicationModel::Calls::VoipPhoneCall^ cc);
}
#endif
private:
friend class Utils;
......@@ -279,7 +280,7 @@ namespace BelledonneCommunications
Call(::LinphoneCall *call);
~Call();
//Windows::Phone::Networking::Voip::VoipPhoneCall^ callContext;
Windows::ApplicationModel::Calls::VoipPhoneCall^ callContext;
::LinphoneCall *call;
};
}
......
......@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Tunnel.h"
#include "VideoPolicy.h"
#include "VideoSize.h"
#include "VoipCallController.h"
#include <collection.h>
......@@ -40,8 +41,7 @@ using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
//using namespace Windows::Phone::Media::Devices;
//using namespace Windows::Phone::Networking::Voip;
using namespace Windows::ApplicationModel::Calls;
......@@ -938,6 +938,12 @@ void Core::VideoPolicy::set(BelledonneCommunications::Linphone::Native::VideoPol
linphone_core_set_video_policy(this->lc, &lvp);
}
VoipCallController^ Core::VoipCallController::get()
{
API_LOCK;
return this->voipCallController;
}
......@@ -1354,57 +1360,41 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
{
Core^ lCore = (Core^)Utils::GetCore(lc);
CoreListener^ listener = lCore->CoreListener;
if (listener != nullptr) {
Call^ lCall = (Call^)Utils::GetCall(call);
CallState state = (CallState) cstate;
listener->CallStateChanged(lCall, state, Utils::cctops(msg));
}
Call^ lCall = (Call^)Utils::GetCall(call);
CallState state = (CallState)cstate;
#if 0
CallController^ callController = Globals::Instance->CallController;
if (state == CallState::IncomingReceived) {
Platform::String^ name = lCall->RemoteAddress->DisplayName;
if (name == nullptr || name->Length() <= 0)
{
name = lCall->RemoteAddress->UserName;
}
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = callController->OnIncomingCallReceived(lCall, name, lCall->RemoteAddress->AsStringUriOnly(), callController->IncomingCallViewDismissed);
VoipPhoneCall^ platformCall = lCore->VoipCallController->NewIncomingCall(lCall->RemoteAddress->AsStringUriOnly());
lCall->CallContext = platformCall;
}
}
else if (state == CallState::OutgoingProgress) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = callController->NewOutgoingCall(lCall->RemoteAddress->AsStringUriOnly());
VoipPhoneCall^ platformCall = lCore->VoipCallController->NewOutgoingCall(lCall->RemoteAddress->AsStringUriOnly());
lCall->CallContext = platformCall;
}
else if (state == CallState::End || state == CallState::Error) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = (Windows::Phone::Networking::Voip::VoipPhoneCall^) lCall->CallContext;
VoipPhoneCall^ platformCall = lCall->CallContext;
if (platformCall != nullptr)
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 == CallState::Paused || state == CallState::PausedByRemote) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = (Windows::Phone::Networking::Voip::VoipPhoneCall^) lCall->CallContext;
VoipPhoneCall^ platformCall = lCall->CallContext;
if (platformCall != nullptr)
platformCall->NotifyCallHeld();
}
else if (state == CallState::StreamsRunning) {
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = (Windows::Phone::Networking::Voip::VoipPhoneCall^) lCall->CallContext;
if (platformCall == nullptr) {
// If CallContext is null here, it is because we have an incoming call using the custom incoming call view so create the VoipPhoneCall now
platformCall = callController->NewIncomingCallForCustomIncomingCallView(lCall->RemoteAddress->DisplayName);
lCall->CallContext = platformCall;
}
VoipPhoneCall^ platformCall = lCall->CallContext;
if (lCall->CameraEnabled) {
platformCall->CallMedia = VoipCallMedia::Audio | VoipCallMedia::Video;
} else {
platformCall->CallMedia = VoipCallMedia::Audio;
platformCall->CallMedia = VoipPhoneCallMedia::Audio | VoipPhoneCallMedia::Video;
}
else {
platformCall->CallMedia = VoipPhoneCallMedia::Audio;
}
platformCall->NotifyCallActive();
}
#endif
if (listener != nullptr) {
listener->CallStateChanged(lCall, state, Utils::cctops(msg));
}
}
void auth_info_requested(::LinphoneCore *lc, const char *realm, const char *username, const char *domain)
......@@ -1491,13 +1481,15 @@ void log_collection_upload_progress_indication(::LinphoneCore *lc, size_t offset
}
Core::Core(BelledonneCommunications::Linphone::Native::CoreListener^ coreListener)
: lc(nullptr), listener(coreListener), config(ref new LpConfig(nullptr, nullptr)), isIterateEnabled(false)
: lc(nullptr), listener(coreListener), config(ref new LpConfig(nullptr, nullptr)), isIterateEnabled(false),
voipCallController(ref new BelledonneCommunications::Linphone::Native::VoipCallController())
{
Init();
}
Core::Core(BelledonneCommunications::Linphone::Native::CoreListener^ coreListener, BelledonneCommunications::Linphone::Native::LpConfig^ config)
: lc(nullptr), listener(coreListener), config(config), isIterateEnabled(false)
: lc(nullptr), listener(coreListener), config(config), isIterateEnabled(false),
voipCallController(ref new BelledonneCommunications::Linphone::Native::VoipCallController())
{
Init();
}
......
......@@ -51,10 +51,12 @@ namespace BelledonneCommunications
ref class Tunnel;
ref class VideoPolicy;
ref class VideoSize;
ref class VoipCallController;
/// <summary>
/// Main object.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public ref class Core sealed
{
public:
......@@ -694,6 +696,11 @@ namespace BelledonneCommunications
void set(BelledonneCommunications::Linphone::Native::VideoPolicy^ value);
}
property VoipCallController^ VoipCallController
{
BelledonneCommunications::Linphone::Native::VoipCallController^ get();
}
......@@ -931,7 +938,7 @@ namespace BelledonneCommunications
/// </summary>
/// <param name="number">The DTMF digit to be played</param>
/// <param name="duration">The duration of the DTMF digit in ms, -1 for unlimited</param>
/// <seealso cref="SendDTMF(char16)"/>
/// <seealso cref="SendDtmf(char16)"/>
void PlayDtmf(char16 number, int duration);
/// <summary>
......@@ -974,7 +981,7 @@ namespace BelledonneCommunications
/// Playing the DTMF locally is done with PlayDTMF(char16, int).
/// </summary>
/// <param name="number">The DTMF digit to be sent</param>
/// <seealso cref="PlayDTMF(char16, int)"/>
/// <seealso cref="PlayDtmf(char16, int)"/>
void SendDtmf(char16 number);
/// <summary>
......@@ -1066,6 +1073,7 @@ namespace BelledonneCommunications
LpConfig^ config;
Windows::Foundation::IAsyncAction^ IterateWorkItem;
Platform::Boolean isIterateEnabled;
BelledonneCommunications::Linphone::Native::VoipCallController^ voipCallController;
static OutputTraceLevel logLevel;
};
......
......@@ -33,6 +33,7 @@ namespace BelledonneCommunications
/// <summary>
/// Definition of the CoreListener interface.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public interface class CoreListener
{
public:
......
/*
VoipCallController.cpp
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "Call.h"
#include "VoipCallController.h"
using namespace BelledonneCommunications::Linphone::Native;
using namespace Platform;
VoipCallController::VoipCallController() :
callCoordinator(VoipCallCoordinator::GetDefault()),
voipServiceName(ref new String(L"Linphone"))
{
}
VoipCallController::~VoipCallController()
{
}
VoipPhoneCall^ VoipCallController::NewIncomingCall(Platform::String^ contactUri)
{
// Why RequestNewOutgoingCall() instead of RequestNewIncomingCall()?
// Because we are using a custom incoming call view so just register the call to the system.
return this->callCoordinator->RequestNewOutgoingCall(
/*this->callInProgressPageUri + "?sip=" + number*/ "Linphone", // TODO
contactUri,
this->voipServiceName,
VoipPhoneCallMedia::Audio | VoipPhoneCallMedia::Video);
}
VoipPhoneCall^ VoipCallController::NewOutgoingCall(Platform::String^ contactUri)
{
return this->callCoordinator->RequestNewOutgoingCall(
/*this->callInProgressPageUri + "?sip=" + number*/ "Linphone", // TODO
contactUri,
this->voipServiceName,
VoipPhoneCallMedia::Audio | VoipPhoneCallMedia::Video);
}
/*
VoipCallController.h
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#pragma once
using namespace Windows::ApplicationModel::Calls;
namespace BelledonneCommunications
{
namespace Linphone
{
namespace Native
{
ref class Call;
[Windows::Foundation::Metadata::WebHostHidden]
public ref class VoipCallController sealed
{
public:
VoipCallController();
virtual ~VoipCallController();
VoipPhoneCall^ NewIncomingCall(Platform::String^ contactUri);
VoipPhoneCall^ NewOutgoingCall(Platform::String^ contactUri);
private:
//Call^ call;
VoipCallCoordinator^ callCoordinator;
Platform::String^ voipServiceName;
};
}
}
}
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