Commit 85e1231f authored by atraczyk's avatar atraczyk Committed by Nicolas Jager

video: move renderer callbacks to UI thread

- moves renderer callbacks to UI thread

- removes natpmp from dependencies

- adds openssl dlls for restbed/namedirectory features

- reverts 7e326091b01bd818ea57a8e90a61ac05e3d50b4b

Change-Id: I8d6d99bd16e9a2bcaa3bd8db4bee5888e12af821
Tuleap: #1242
parent 0277f208
......@@ -3,10 +3,12 @@ namespace RingClientUWP
/* public enumerations. */
public enum class CallStatus {
NONE,
RINGING,
CONNECTING,
INCOMING_RINGING,
OUTGOING_RINGING,
SEARCHING,
IN_PROGRESS,
PAUSED,
ENDED,
TERMINATING
};
......
......@@ -253,7 +253,7 @@ void RingClientUWP::MainPage::OnstateChange(Platform::String ^callId, RingClient
switch (state) {
/* send the user to the peer's message text page */
case CallStatus::NONE:
case CallStatus::ENDED:
{
if (item)
OnsummonMessageTextPage();
......@@ -375,7 +375,7 @@ MainPage::BeginExtendedExecution()
sessionRevokedToken = (newSession->Revoked += ref new TypedEventHandler<Object^,
ExtendedExecutionRevokedEventArgs^>(this, &MainPage::SessionRevoked));
return create_task(newSession->RequestExtensionAsync())
.then([=](ExtendedExecutionResult result) {
.then([=](ExtendedExecutionResult result){
try {
switch (result)
{
......
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="Savoir-faireLinux.GNURing" Publisher="CN=8121A5F7-3CA1-4CAA-92B2-4F595B011941" Version="1.1.5.0" />
<Identity Name="Savoir-faireLinux.GNURing" Publisher="CN=8121A5F7-3CA1-4CAA-92B2-4F595B011941" Version="1.1.12.0" />
<mp:PhoneIdentity PhoneProductId="2385953f-9019-423d-aa82-d1bbacfa258b" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>GNU Ring</DisplayName>
......
......@@ -28,8 +28,7 @@
#include "account_schema.h"
#include "account_const.h"
#include "string_utils.h" // used to get some const expr like TRUE_STR
#include <gnutls\gnutls.h>
#include "gnutls\gnutls.h"
#include "SmartPanel.xaml.h"
......@@ -116,6 +115,8 @@ RingClientUWP::RingD::reloadAccountList()
}
}
DRing::lookupName("", "", "wagaf");
// load user preferences
Configuration::UserPreferences::instance->load();
}
......@@ -368,7 +369,6 @@ RingClientUWP::RingD::startDaemon()
//eraseCacheFolder();
editModeOn_ = true;
create_task([&]()
{
using SharedCallback = std::shared_ptr<DRing::CallbackWrapperBase>;
......@@ -399,7 +399,7 @@ RingClientUWP::RingD::startDaemon()
CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
{
incomingCall(accountId2, callId2, from2);
stateChange(callId2, CallStatus::RINGING, 0);
stateChange(callId2, CallStatus::INCOMING_RINGING, 0);
auto contact = ContactsViewModel::instance->findContactByName(from2);
auto item = SmartPanelItemsViewModel::instance->findItem(contact);
......@@ -421,7 +421,7 @@ RingClientUWP::RingD::startDaemon()
auto state3 = translateCallStatus(state2);
if (state3 == CallStatus::NONE)
if (state3 == CallStatus::ENDED)
DRing::hangUp(callId); // solve a bug in the daemon API.
......@@ -540,8 +540,6 @@ RingClientUWP::RingD::startDaemon()
exportOnRingEnded(accountId2, pin2);
}));
})
};
registerCallHandlers(callHandlers);
......@@ -573,15 +571,21 @@ RingClientUWP::RingD::startDaemon()
MSG_("<DeviceEvent>");
}),
DRing::exportable_callback<DRing::VideoSignal::DecodingStarted>
([this](const std::string &id, const std::string &shmPath, int width, int height, bool isMixer) {
([&](const std::string &id, const std::string &shmPath, int width, int height, bool isMixer) {
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
Video::VideoManager::instance->rendererManager()->startedDecoding(
Utils::toPlatformString(id),
width,
height);
}));
}),
DRing::exportable_callback<DRing::VideoSignal::DecodingStopped>
([this](const std::string &id, const std::string &shmPath, bool isMixer) {
([&](const std::string &id, const std::string &shmPath, bool isMixer) {
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
Video::VideoManager::instance->rendererManager()->removeRenderer(Utils::toPlatformString(id));
}));
})
};
registerVideoHandlers(incomingVideoHandlers);
......@@ -611,13 +615,16 @@ RingClientUWP::RingD::startDaemon()
}
}),
DRing::exportable_callback<DRing::VideoSignal::SetParameters>
([this](const std::string& device,
([&](const std::string& device,
std::string format,
const int width,
const int height,
const int rate) {
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
VideoManager::instance->captureManager()->activeDevice->SetDeviceProperties(
Utils::toPlatformString(format),width,height,rate);
}));
}),
DRing::exportable_callback<DRing::VideoSignal::StartCapture>
([&](const std::string& device) {
......@@ -642,16 +649,17 @@ RingClientUWP::RingD::startDaemon()
std::map<std::string, SharedCallback> nameRegistrationHandlers =
{
/*}),
DRing::exportable_callback<ConfigurationSignal::NameRegistrationEnded>(
DRing::exportable_callback<DRing::ConfigurationSignal::NameRegistrationEnded>(
[this](const std::string &accountId, int status, const std::string &name) {
MSG_("\n<NameRegistrationEnded>\n");
}),
DRing::exportable_callback<ConfigurationSignal::RegisteredNameFound>(
DRing::exportable_callback<DRing::ConfigurationSignal::RegisteredNameFound>(
[this](const std::string &accountId, int status, const std::string &address, const std::string &name) {
MSG_("\n<RegisteredNameFound>\n");*/
MSG_("<RegisteredNameFound>" + name + " : " + address);
})
};
registerConfHandlers(nameRegistrationHandlers);
gnutls_global_init();
......@@ -682,7 +690,6 @@ RingClientUWP::RingD::startDaemon()
}
}
/* at this point the config.yml is safe. */
Utils::fileExists(ApplicationData::Current->LocalFolder, "creation.token")
.then([this](bool token_exists)
......@@ -703,6 +710,8 @@ RingClientUWP::RingD::startDaemon()
Sleep(5);
}
DRing::fini();
gnutls_global_deinit();
}
});
}
......@@ -853,13 +862,19 @@ RingD::dequeueTasks()
RingClientUWP::CallStatus RingClientUWP::RingD::translateCallStatus(String^ state)
{
if (state == "INCOMING")
return CallStatus::RINGING;
return CallStatus::INCOMING_RINGING;
if (state == "CURRENT")
return CallStatus::IN_PROGRESS;
if (state == "CONNECTING" || state == "RINGING")
return CallStatus::CONNECTING;
if (state == "OVER")
return CallStatus::ENDED;
if (state == "RINGING")
return CallStatus::OUTGOING_RINGING;
if (state == "CONNECTING")
return CallStatus::SEARCHING;
return CallStatus::NONE;
......
......@@ -62,7 +62,7 @@ RingDebug::print(const std::string& message,
void RingClientUWP::RingDebug::WriteLine(String^ str)
{
/* save in file */
FileIO::AppendTextAsync(_videoFile, str + "\n");
//FileIO::AppendTextAsync(_videoFile, str + "\n");
/* screen in visual studio console */
std::wstringstream wStringstream;
......
......@@ -113,6 +113,7 @@ SmartPanel::SmartPanel()
switch (state) {
case CallStatus::NONE:
case CallStatus::ENDED:
{
item->_callId = "";
break;
......@@ -536,7 +537,7 @@ Object ^ RingClientUWP::Views::IncomingVisibility::Convert(Object ^ value, Windo
{
auto state = static_cast<CallStatus>(value);
if (state == CallStatus::RINGING)
if (state == CallStatus::INCOMING_RINGING)
return Windows::UI::Xaml::Visibility::Visible;
else
return Windows::UI::Xaml::Visibility::Collapsed;
......@@ -555,7 +556,7 @@ Object ^ RingClientUWP::Views::OutGoingVisibility::Convert(Object ^ value, Windo
{
auto state = static_cast<CallStatus>(value);
if (state == CallStatus::CONNECTING || state == CallStatus::RINGING)
if (state == CallStatus::SEARCHING || state == CallStatus::OUTGOING_RINGING)
return Windows::UI::Xaml::Visibility::Visible;
else
return Windows::UI::Xaml::Visibility::Collapsed;
......@@ -573,7 +574,7 @@ Object ^ RingClientUWP::Views::HasAnActiveCall::Convert(Object ^ value, Windows:
{
auto state = static_cast<CallStatus>(value);
if (state == CallStatus::NONE)
if (state == CallStatus::NONE || state == CallStatus::ENDED)
return Windows::UI::Xaml::Visibility::Collapsed;
else
return Windows::UI::Xaml::Visibility::Visible;
......
......@@ -51,6 +51,6 @@ SmartPanelItem::NotifyPropertyChanged(String^ propertyName)
void RingClientUWP::Controls::SmartPanelItem::OncallPlaced(Platform::String ^callId)
{
if (_callId == callId) {
_callStatus = CallStatus::CONNECTING;
_callStatus = CallStatus::SEARCHING;
}
}
......@@ -64,9 +64,12 @@ VideoPage::VideoPage()
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
try {
if (!VideoManager::instance->rendererManager()->renderers->Size)
auto renderer_w = VideoManager::instance->rendererManager()->renderer(id);
if (!renderer_w) {
return;
VideoManager::instance->rendererManager()->renderer(id)->isRendering = true;
}
else {
renderer_w->isRendering = true;
create_task(WriteFrameAsSoftwareBitmapAsync(id, buf, width, height))
.then([=](task<void> previousTask) {
try {
......@@ -77,6 +80,7 @@ VideoPage::VideoPage()
}
});
}
}
catch(Platform::COMException^ e) {
RingDebug::instance->WriteLine(e->ToString());
}
......@@ -120,7 +124,7 @@ VideoPage::VideoPage()
RingD::instance->stateChange +=
ref new StateChange([&](String^ callId, CallStatus state, int code)
{
if (state == CallStatus::NONE) {
if (state == CallStatus::ENDED) {
Video::VideoManager::instance->rendererManager()->raiseClearRenderTarget();
}
});
......
......@@ -106,11 +106,14 @@ VideoRendererManager::removeRenderer(String^ id)
{
if(!renderers)
return;
std::unique_lock<std::mutex> lk(renderers->Lookup(id)->render_mutex);
renderers->Lookup(id)->frame_cv.wait(lk, [=] {
return !renderers->Lookup(id)->isRendering;
auto renderer_w = renderer(id);
if (renderer_w) {
std::unique_lock<std::mutex> lk(renderer_w->render_mutex);
renderer_w->frame_cv.wait(lk, [=] {
return !renderer_w->isRendering;
});
renderers->Remove(id);
}
}
VideoRendererWrapper^
......
This diff is collapsed.
......@@ -259,11 +259,9 @@
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
</None>
<None Include="..\restbed\dependency\openssl\out32dll\libeay32.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DeploymentContent>
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="..\restbed\dependency\openssl\out32dll\ssleay32.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DeploymentContent>
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="ring-client-uwp_StoreKey.pfx" />
......
......@@ -230,6 +230,12 @@
<None Include="..\FFmpegInterop\ffmpeg\Build\Windows10\x64\bin\swresample-2.dll">
<Filter>Assets\Dlls</Filter>
</None>
<None Include="..\restbed\dependency\openssl\out32dll\libeay32.dll">
<Filter>Assets\Dlls</Filter>
</None>
<None Include="..\restbed\dependency\openssl\out32dll\ssleay32.dll">
<Filter>Assets\Dlls</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Page Include="MainPage.xaml" />
......
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