Commit c8f949a1 authored by atraczyk's avatar atraczyk Committed by Andreas Traczyk

internal: manage reinitialisation of video on visibility change

- adds stopping video capture stream when application goes "invisible"

- adds reinitialisation of video capture stream when application
  becomes "visible"

- adds functions for pausing the call (Not yet implemented)

Change-Id: I58a24718b47d9edcc9b39ff707e0fbb695dc48f6
Tuleap: #1212
parent 38dd4429
namespace RingClientUWP namespace RingClientUWP
{ {
/* public enumerations. */ /* public enumerations. */
public enum class CallStatus { NONE, INCOMING_RINGING, OUTGOING_RINGING, SEARCHING, IN_PROGRESS, ENDED, TERMINATING }; public enum class CallStatus {
NONE,
INCOMING_RINGING,
OUTGOING_RINGING,
SEARCHING,
IN_PROGRESS,
PAUSED,
ENDED,
TERMINATING
};
} }
\ No newline at end of file
...@@ -295,11 +295,44 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr ...@@ -295,11 +295,44 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
{ {
if (e->Visible) { if (e->Visible) {
WriteLine("->Visible"); WriteLine("->Visible");
//Video::VideoManager::instance-> auto isPreviewing = Video::VideoManager::instance->captureManager()->isPreviewing;
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
isInCall = true;
break;
}
}
if (isInCall) {
/*if (RingD::instance->currentCallId)
RingD::instance->unPauseCall(RingD::instance->currentCallId);*/
Video::VideoManager::instance->captureManager()->InitializeCameraAsync();
Video::VideoManager::instance->captureManager()->videoFrameCopyInvoker->Start();
}
} }
else { else {
WriteLine("->Invisible"); WriteLine("->Invisible");
//Video::VideoManager::instance->captureManager()->CleanupCameraAsync(); auto isPreviewing = Video::VideoManager::instance->captureManager()->isPreviewing;
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
isInCall = true;
RingD::instance->currentCallId = item->_callId;
break;
}
}
if (isInCall) {
/*if (RingD::instance->currentCallId) {
WriteLine("Pausing call: " + RingD::instance->currentCallId);
RingD::instance->pauseCall(RingD::instance->currentCallId);
}*/
if (isPreviewing) {
Video::VideoManager::instance->captureManager()->StopPreviewAsync();
if (Video::VideoManager::instance->captureManager()->captureTaskTokenSource)
Video::VideoManager::instance->captureManager()->captureTaskTokenSource->cancel();
Video::VideoManager::instance->captureManager()->videoFrameCopyInvoker->Stop();
}
}
} }
} }
...@@ -347,11 +380,7 @@ MainPage::BeginExtendedExecution() ...@@ -347,11 +380,7 @@ MainPage::BeginExtendedExecution()
Video::VideoManager::instance->captureManager()->CleanupCameraAsync() Video::VideoManager::instance->captureManager()->CleanupCameraAsync()
.then([](){ .then([](){
WriteLine("Hang up calls..."); WriteLine("Hang up calls...");
for (auto item : SmartPanelItemsViewModel::instance->itemsList) { DRing::fini();
if (item->_callId && item->_callStatus != CallStatus::NONE) {
DRing::hangUp(Utils::toString(item->_callId));
}
}
}); });
break; break;
......
...@@ -204,6 +204,18 @@ void RingClientUWP::RingD::hangUpCall2(String ^ callId) ...@@ -204,6 +204,18 @@ void RingClientUWP::RingD::hangUpCall2(String ^ callId)
tasksList_.push(ref new RingD::Task(Request::HangUpCall, callId)); tasksList_.push(ref new RingD::Task(Request::HangUpCall, callId));
} }
void RingClientUWP::RingD::pauseCall(String ^ callId)
{
MSG_("$1 pauseCall : " + Utils::toString(callId));
tasksList_.push(ref new RingD::Task(Request::PauseCall, callId));
}
void RingClientUWP::RingD::unPauseCall(String ^ callId)
{
MSG_("$1 unPauseCall : " + Utils::toString(callId));
tasksList_.push(ref new RingD::Task(Request::UnPauseCall, callId));
}
void RingClientUWP::RingD::askToRefreshKnownDevices(String^ accountId) void RingClientUWP::RingD::askToRefreshKnownDevices(String^ accountId)
{ {
auto task = ref new RingD::Task(Request::GetKnownDevices); auto task = ref new RingD::Task(Request::GetKnownDevices);
...@@ -422,10 +434,6 @@ RingClientUWP::RingD::startDaemon() ...@@ -422,10 +434,6 @@ RingClientUWP::RingD::startDaemon()
([this](const std::string &id, const std::string &shmPath, bool isMixer) { ([this](const std::string &id, const std::string &shmPath, bool isMixer) {
MSG_("<DecodingStopped>"); MSG_("<DecodingStopped>");
MSG_("Removing renderer id:" + id); MSG_("Removing renderer id:" + id);
/*auto Id = Utils::toPlatformString(id);
auto renderer = Video::VideoManager::instance->rendererManager()->renderer(Id);
if (renderer)
renderer->isRendering = false;*/
Video::VideoManager::instance->rendererManager()->removeRenderer(Utils::toPlatformString(id)); Video::VideoManager::instance->rendererManager()->removeRenderer(Utils::toPlatformString(id));
}) })
}; };
...@@ -534,6 +542,7 @@ RingD::RingD() ...@@ -534,6 +542,7 @@ RingD::RingD()
{ {
localFolder_ = Utils::toString(ApplicationData::Current->LocalFolder->Path); localFolder_ = Utils::toString(ApplicationData::Current->LocalFolder->Path);
callIdsList_ = ref new Vector<String^>(); callIdsList_ = ref new Vector<String^>();
currentCallId = nullptr;
} }
void void
...@@ -583,6 +592,16 @@ RingD::dequeueTasks() ...@@ -583,6 +592,16 @@ RingD::dequeueTasks()
DRing::hangUp(Utils::toString(callId)); DRing::hangUp(Utils::toString(callId));
} }
break; break;
case Request::PauseCall:
{
DRing::hold(Utils::toString(task->_callId));
}
break;
case Request::UnPauseCall:
{
DRing::unhold(Utils::toString(task->_callId));
}
break;
case Request::RegisterDevice: case Request::RegisterDevice:
{ {
auto pin = Utils::toString(_pin); auto pin = Utils::toString(_pin);
......
...@@ -90,12 +90,15 @@ internal: ...@@ -90,12 +90,15 @@ internal:
Vector<String^>^ translateKnownRingDevices(const std::map<std::string, std::string> devices); Vector<String^>^ translateKnownRingDevices(const std::map<std::string, std::string> devices);
void hangUpCall2(String^ callId); void hangUpCall2(String^ callId);
void pauseCall(String ^ callId);
void unPauseCall(String ^ callId);
void askToRefreshKnownDevices(String^ accountId); void askToRefreshKnownDevices(String^ accountId);
void askToExportOnRing(String^ accountId, String^ password); void askToExportOnRing(String^ accountId, String^ password);
/* TODO : move members */ /* TODO : move members */
///bool hasConfig; // replaced by startingStatus ///bool hasConfig; // replaced by startingStatus
std::string accountName; std::string accountName;
String ^ currentCallId; // to save ongoing call id during visibility change
/* events */ /* events */
event IncomingCall^ incomingCall; event IncomingCall^ incomingCall;
...@@ -116,6 +119,8 @@ private: ...@@ -116,6 +119,8 @@ private:
AcceptIncommingCall, AcceptIncommingCall,
CancelOutGoingCall, CancelOutGoingCall,
HangUpCall, HangUpCall,
PauseCall,
UnPauseCall,
RegisterDevice, RegisterDevice,
GetKnownDevices, GetKnownDevices,
ExportOnRing ExportOnRing
......
...@@ -208,6 +208,12 @@ void RingClientUWP::Views::VideoPage::_btnHangUp__Tapped(Platform::Object^ sende ...@@ -208,6 +208,12 @@ void RingClientUWP::Views::VideoPage::_btnHangUp__Tapped(Platform::Object^ sende
void RingClientUWP::Views::VideoPage::_btnPause__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e) void RingClientUWP::Views::VideoPage::_btnPause__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
{ {
/*auto item = SmartPanelItemsViewModel::instance->_selectedItem;
if (item->_callStatus == CallStatus::IN_PROGRESS)
RingD::instance->pauseCall(item->_callId);
else if (item->_callStatus == CallStatus::PAUSED)
RingD::instance->unPauseCall(item->_callId);*/
pauseCall(); pauseCall();
} }
......
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