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