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

settings: add the ability to modify video device settings

- adds the ability to select device, resolution, and frame rate

- modifies the initialization of the daemon by seperating the
  registration of the callbacks from the init function and places
  the start and run loop in an IAsyncAction worker thread with
  forced high priority

- uses std::ofstream for debug log file instead of Platform functions

Change-Id: I32439088fe58513c46d11297db4898ca237174e7
Tuleap: #790
parent 09300ddf
<!-- **********************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas<nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas<andreas.traczyk@savoirfairelinux.com> *
* *
* 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 *
......@@ -23,8 +24,4 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
NavigationCacheMode="Enabled"
mc:Ignorable="d">
<Grid>
<TextBlock Text="loading page"/>
</Grid>
</Page>
......@@ -120,6 +120,10 @@
<Frame x:Name="_videoFrame_"
Grid.Row="0"
Visibility="Visible"/>
<Frame x:Name="_previewFrame_"
Grid.Row="1"
Canvas.ZIndex="99"
Visibility="Collapsed"/>
</Grid>
</SplitView.Content>
</SplitView>
......
......@@ -22,8 +22,11 @@
#include "SmartPanel.xaml.h"
#include "RingConsolePanel.xaml.h"
#include "VideoPage.xaml.h"
#include "PreviewPage.xaml.h"
#include "WelcomePage.xaml.h"
#include "gnutls\gnutls.h"
#include "MainPage.xaml.h"
using namespace RingClientUWP;
......@@ -60,6 +63,7 @@ MainPage::MainPage()
_smartPanel_->Navigate(TypeName(RingClientUWP::Views::SmartPanel::typeid));
_consolePanel_->Navigate(TypeName(RingClientUWP::Views::RingConsolePanel::typeid));
_videoFrame_->Navigate(TypeName(RingClientUWP::Views::VideoPage::typeid));
_previewFrame_->Navigate(TypeName(RingClientUWP::Views::PreviewPage::typeid));
_messageTextFrame_->Navigate(TypeName(RingClientUWP::Views::MessageTextPage::typeid));
/* connect to delegates */
......@@ -67,6 +71,8 @@ MainPage::MainPage()
auto smartPanel = dynamic_cast<SmartPanel^>(_smartPanel_->Content);
smartPanel->summonMessageTextPage += ref new RingClientUWP::SummonMessageTextPage(this, &RingClientUWP::MainPage::OnsummonMessageTextPage);
smartPanel->summonWelcomePage += ref new RingClientUWP::SummonWelcomePage(this, &RingClientUWP::MainPage::OnsummonWelcomePage);
smartPanel->summonPreviewPage += ref new RingClientUWP::SummonPreviewPage(this, &RingClientUWP::MainPage::OnsummonPreviewPage);
smartPanel->hidePreviewPage += ref new RingClientUWP::HidePreviewPage(this, &RingClientUWP::MainPage::OnhidePreviewPage);
smartPanel->summonVideoPage += ref new RingClientUWP::SummonVideoPage(this, &RingClientUWP::MainPage::OnsummonVideoPage);
auto videoPage = dynamic_cast<VideoPage^>(_videoFrame_->Content);
videoPage->pressHangUpCall += ref new RingClientUWP::PressHangUpCall(this, &RingClientUWP::MainPage::OnpressHangUpCall);
......@@ -127,7 +133,10 @@ RingClientUWP::MainPage::showFrame(Windows::UI::Xaml::Controls::Frame^ frame)
void
RingClientUWP::MainPage::OnNavigatedTo(NavigationEventArgs ^ e)
{
RingD::instance->startDaemon();
gnutls_global_init();
RingD::instance->registerCallbacks();
RingD::instance->initDaemon( DRing::DRING_FLAG_CONSOLE_LOG | DRing::DRING_FLAG_DEBUG );
Video::VideoManager::instance->captureManager()->EnumerateWebcamsAsync();
showLoadingOverlay(true, false);
}
......@@ -231,6 +240,17 @@ void RingClientUWP::MainPage::OnsummonWelcomePage()
showFrame(_welcomeFrame_);
}
void RingClientUWP::MainPage::OnsummonPreviewPage()
{
WriteLine("Show Settings Preview");
_previewFrame_->Visibility = VIS::Visible;
}
void RingClientUWP::MainPage::OnhidePreviewPage()
{
WriteLine("Hide Settings Preview");
_previewFrame_->Visibility = VIS::Collapsed;
}
void RingClientUWP::MainPage::OnsummonVideoPage()
{
......@@ -245,8 +265,6 @@ void RingClientUWP::MainPage::OnpressHangUpCall()
OnsummonMessageTextPage();
}
void RingClientUWP::MainPage::OnstateChange(Platform::String ^callId, RingClientUWP::CallStatus state, int code)
{
auto item = SmartPanelItemsViewModel::instance->_selectedItem;
......@@ -264,8 +282,7 @@ void RingClientUWP::MainPage::OnstateChange(Platform::String ^callId, RingClient
}
}
#include <dring.h>
#include "callmanager_interface.h"
void
MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e)
{
......@@ -299,9 +316,9 @@ MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingE
void
MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventArgs^ e)
{
auto vcm = Video::VideoManager::instance->captureManager();
if (e->Visible) {
RingDebug::instance->WriteLine("->Visible");
auto isPreviewing = Video::VideoManager::instance->captureManager()->isPreviewing;
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
......@@ -312,13 +329,23 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
if (isInCall) {
/*if (RingD::instance->currentCallId)
RingD::instance->unPauseCall(RingD::instance->currentCallId);*/
Video::VideoManager::instance->captureManager()->InitializeCameraAsync();
Video::VideoManager::instance->captureManager()->videoFrameCopyInvoker->Start();
vcm->InitializeCameraAsync(false);
vcm->videoFrameCopyInvoker->Start();
}
else if (vcm->isSettingsPreviewing) {
vcm->CleanupCameraAsync()
.then([=](task<void> cleanupTask){
cleanupTask.get();
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
{
vcm->InitializeCameraAsync(true);
}));
});
}
}
else {
RingDebug::instance->WriteLine("->Invisible");
auto isPreviewing = Video::VideoManager::instance->captureManager()->isPreviewing;
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
......@@ -328,17 +355,21 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
}
}
if (isInCall) {
// TODO
/*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();
if (vcm->isPreviewing) {
vcm->StopPreviewAsync();
if (vcm->captureTaskTokenSource)
vcm->captureTaskTokenSource->cancel();
vcm->videoFrameCopyInvoker->Stop();
}
}
else if (vcm->isSettingsPreviewing) {
vcm->StopPreviewAsync();
}
}
}
......@@ -383,11 +414,10 @@ MainPage::BeginExtendedExecution()
session = newSession;
RingDebug::instance->WriteLine("Request Extended Execution Allowed");
RingDebug::instance->WriteLine("Clean up camera...");
Video::VideoManager::instance->captureManager()->CleanupCameraAsync()
.then([]() {
RingDebug::instance->WriteLine("Hang up calls...");
DRing::fini();
});
Video::VideoManager::instance->captureManager()->CleanupCameraAsync();
RingDebug::instance->WriteLine("Hang up calls...");
DRing::fini();
gnutls_global_init();
break;
default:
......
......@@ -71,6 +71,8 @@ private:
void showFrame(Windows::UI::Xaml::Controls::Frame^ frame);
void OnsummonMessageTextPage();
void OnsummonWelcomePage();
void OnsummonPreviewPage();
void OnhidePreviewPage();
void OnsummonVideoPage();
void OnpressHangUpCall();
void OnstateChange(Platform::String ^callId, CallStatus state, int code);
......
<Page
<!-- **********************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas<nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas<andreas.traczyk@savoirfairelinux.com> *
* *
* 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 3 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, see <http://www.gnu.org/licenses/> . *
*********************************************************************** -->
<Page
x:Class="RingClientUWP.Views.MessageTextPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
......
<?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.6.0" />
<Identity Name="Savoir-faireLinux.GNURing" Publisher="CN=8121A5F7-3CA1-4CAA-92B2-4F595B011941" Version="1.1.10.0" />
<mp:PhoneIdentity PhoneProductId="2385953f-9019-423d-aa82-d1bbacfa258b" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>GNU Ring</DisplayName>
......
<!-- **********************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas<nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas<andreas.traczyk@savoirfairelinux.com> *
* *
* 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 3 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, see <http://www.gnu.org/licenses/> . *
*********************************************************************** -->
<Page x:Class="RingClientUWP.Views.PreviewPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RingClientUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
NavigationCacheMode="Enabled"
mc:Ignorable="d">
<Grid x:Name="_previewPage_"
Background="Black">
<!--camera preview-->
<CaptureElement Name="SettingsPreviewImage"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Stretch="Uniform"/>
</Grid>
</Page>
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jger Nicolas <nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
* *
* 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 3 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, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "pch.h"
#include "PreviewPage.xaml.h"
using namespace RingClientUWP;
using namespace RingClientUWP::Views;
using namespace Video;
PreviewPage::PreviewPage()
{
InitializeComponent();
VideoManager::instance->captureManager()->getSettingsPreviewSink +=
ref new GetSettingsPreviewSink([this]()
{
return SettingsPreviewImage;
});
};
\ No newline at end of file
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
* *
* 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 3 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, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include "PreviewPage.g.h"
namespace RingClientUWP
{
namespace Views
{
public ref class PreviewPage sealed
{
public:
PreviewPage();
protected:
};
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include <dring.h>
using namespace concurrency;
......@@ -37,7 +38,10 @@ delegate void ExportOnRingEnded(String^ accountId, String^ pin);
delegate void SummonWizard();
delegate void AccountUpdated(Account^ account);
delegate void IncomingVideoMuted(String^ callId, bool state);
delegate void FinishCaptureDeviceEnumeration();
using SharedCallback = std::shared_ptr<DRing::CallbackWrapperBase>;
using namespace std::placeholders;
public ref class RingD sealed
{
......@@ -77,6 +81,8 @@ internal: // why this property has to be internal and not public ?
internal:
/* functions */
void registerCallbacks();
void initDaemon(int flags);
void startDaemon();
void reloadAccountList();
void sendAccountTextMessage(String^ message);
......@@ -119,6 +125,7 @@ internal:
event SummonWizard^ summonWizard;
event AccountUpdated^ accountUpdated;
event IncomingVideoMuted^ incomingVideoMuted;
event FinishCaptureDeviceEnumeration^ finishCaptureDeviceEnumeration;
private:
/* sub classes */
......@@ -181,11 +188,20 @@ private:
// CallStatus translateCallStatus(String^ state);
/* members */
Windows::UI::Core::CoreDispatcher^ dispatcher;
std::string localFolder_;
bool daemonRunning_ = false;
std::queue<Task^> tasksList_;
StartingStatus startingStatus_ = StartingStatus::NORMAL;
bool editModeOn_ = false;
bool debugModeOn_ = true;
std::map<std::string, SharedCallback> callHandlers;
std::map<std::string, SharedCallback> getAppPathHandler;
std::map<std::string, SharedCallback> getAppUserNameHandler;
std::map<std::string, SharedCallback> incomingVideoHandlers;
std::map<std::string, SharedCallback> outgoingVideoHandlers;
std::map<std::string, SharedCallback> nameRegistrationHandlers;
};
}
\ No newline at end of file
......@@ -20,6 +20,8 @@
/* client */
#include "pch.h"
#include "fileutils.h"
using namespace RingClientUWP;
using namespace Platform;
......@@ -56,14 +58,15 @@ RingDebug::print(const std::string& message,
/* fire the event. */
auto line = ref new String(wString.c_str(), wString.length());
messageToScreen(line);
FileIO::AppendTextAsync(_logFile, line + "\n");
std::ofstream ofs;
ofs.open ("debug.log", std::ofstream::out | std::ofstream::app);
ofs << Utils::toString(line) << "\n";
ofs.close();
}
void RingClientUWP::RingDebug::WriteLine(String^ str)
{
/* save in file */
//FileIO::AppendTextAsync(_videoFile, str + "\n");
/* screen in visual studio console */
std::wstringstream wStringstream;
wStringstream << str->Data() << "\n";
......@@ -72,19 +75,4 @@ void RingClientUWP::RingDebug::WriteLine(String^ str)
RingClientUWP::RingDebug::RingDebug()
{
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
StorageFile^ logFile;
task<StorageFile^>(storageFolder->CreateFileAsync("debug.log", CreationCollisionOption::ReplaceExisting)).then([this](StorageFile^ file)
{
this->_logFile = file;
});
task<StorageFile^>(storageFolder->CreateFileAsync("video.log", CreationCollisionOption::ReplaceExisting)).then([this](StorageFile^ file)
{
this->_videoFile = file;
});
}
}
\ No newline at end of file
......@@ -42,9 +42,6 @@ public:
}
}
property StorageFile^ _logFile;
property StorageFile^ _videoFile;
/* properties */
/* functions */
......
......@@ -880,7 +880,30 @@
<Grid x:Name="_settings_"
Grid.Row="0"
Visibility="Collapsed">
<TextBlock>some settings</TextBlock>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="_videoSettings_"
Grid.Row="0">
<StackPanel Margin="10">
<TextBlock Text="Video Device"
Margin="10"/>
<ComboBox x:Name="_videoDeviceComboBox_"
Margin="10"
SelectionChanged="_videoDeviceComboBox__SelectionChanged">
</ComboBox>
<TextBlock Text="Video Resolution" Margin="10"/>
<ComboBox x:Name="_videoResolutionComboBox_"
Margin="10"
SelectionChanged="_videoResolutionComboBox__SelectionChanged">
</ComboBox>
<TextBlock Text="Video Rate" Margin="10"/>
<ComboBox x:Name="_videoRateComboBox_"
Margin="10"
SelectionChanged="_videoRateComboBox__SelectionChanged">
</ComboBox>
</StackPanel>
</Grid>
</Grid>
</Grid>
</Grid>
......
......@@ -29,6 +29,7 @@ using namespace RingClientUWP::Controls;
using namespace RingClientUWP::Views;
using namespace RingClientUWP::ViewModel;
using namespace Windows::Media::Capture;
using namespace Windows::Media::MediaProperties;
using namespace Windows::UI::Xaml;
using namespace Windows::Storage;
using namespace Windows::UI::Xaml::Media::Imaging;
......@@ -41,8 +42,6 @@ using namespace Windows::Foundation;
using namespace Concurrency;
using namespace Platform::Collections;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::Storage;
using namespace Windows::UI::Core;
......@@ -141,7 +140,9 @@ SmartPanel::SmartPanel()
RingD::instance->exportOnRingEnded += ref new RingClientUWP::ExportOnRingEnded(this, &RingClientUWP::Views::SmartPanel::OnexportOnRingEnded);
RingD::instance->accountUpdated += ref new RingClientUWP::AccountUpdated(this, &RingClientUWP::Views::SmartPanel::OnaccountUpdated);
RingD::instance->finishCaptureDeviceEnumeration += ref new RingClientUWP::FinishCaptureDeviceEnumeration([this]() {
populateVideoDeviceSettingsComboBox();
});
}
void
......@@ -200,12 +201,30 @@ void RingClientUWP::Views::SmartPanel::_settings__Checked(Object^ sender, Routed
{
_smartGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_settings_->Visibility = Windows::UI::Xaml::Visibility::Visible;
auto vcm = Video::VideoManager::instance->captureManager();
if (!vcm->isInitialized)
vcm->InitializeCameraAsync(true);
else
vcm->StartPreviewAsync(true);
summonPreviewPage();
}
void RingClientUWP::Views::SmartPanel::_settings__Unchecked(Object^ sender, RoutedEventArgs^ e)
{
_settings_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_smartGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
Video::VideoManager::instance->captureManager()->StopPreviewAsync()
.then([](task<void> stopPreviewTask)
{
try {
stopPreviewTask.get();
Video::VideoManager::instance->captureManager()->isSettingsPreviewing = false;
}
catch (Exception^ e) {
WriteException(e);
}
});
hidePreviewPage();
}
void RingClientUWP::Views::SmartPanel::setMode(RingClientUWP::Views::SmartPanel::Mode mode)
......@@ -888,11 +907,10 @@ void RingClientUWP::Views::SmartPanel::_selectedAccountAvatarContainer__PointerR
.then([this](StorageFile^ photoFile)
{
if (photoFile != nullptr) {
// maybe it would be possible to move some logics to the style sheet
auto brush = ref new ImageBrush();
auto circle = ref new Ellipse();
circle->Height = 80; // TODO : use some global constant when ready
circle->Height = 80;
circle->Width = 80;
auto path = photoFile->Path;
auto uri = ref new Windows::Foundation::Uri(path);
......@@ -950,3 +968,147 @@ void RingClientUWP::Views::SmartPanel::Grid_PointerMoved(Platform::Object^ sende
item->_hovered = Windows::UI::Xaml::Visibility::Visible;
}
// VIDEO
void
SmartPanel::_videoDeviceComboBox__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^)
{
if (_videoDeviceComboBox_->Items->Size) {
Video::VideoCaptureManager^ vcm = Video::VideoManager::instance->captureManager();
auto selectedItem = static_cast<ComboBoxItem^>(static_cast<ComboBox^>(sender)->SelectedItem);
auto deviceId = static_cast<String^>(selectedItem->Tag);
std::vector<int>::size_type index;
for(index = 0; index != vcm->deviceList->Size; index++) {
auto dev = vcm->deviceList->GetAt(index);
if (dev->id() == deviceId) {
break;
}
}
vcm->activeDevice = vcm->deviceList->GetAt(index);
populateVideoResolutionSettingsComboBox();
}
}
void
SmartPanel::_videoResolutionComboBox__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^)
{
if (_videoResolutionComboBox_->Items->Size) {
Video::VideoCaptureManager^ vcm = Video::VideoManager::instance->captureManager();
auto device = vcm->activeDevice;
auto selectedItem = static_cast<ComboBoxItem^>(static_cast<ComboBox^>(sender)->SelectedItem);
auto selectedResolution = static_cast<String^>(selectedItem->Tag);
std::vector<int>::size_type index;
for(index = 0; index != device->resolutionList()->Size; index++) {
auto res = device->resolutionList()->GetAt(index);
if (res->getFriendlyName() == selectedResolution) {
break;
}
}
vcm->activeDevice->setCurrentResolution( device->resolutionList()->GetAt(index) );
populateVideoRateSettingsComboBox();
}
}
void
SmartPanel::_videoRateComboBox__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^)
{
if (_videoRateComboBox_->Items->Size) {
Video::VideoCaptureManager^ vcm = Video::VideoManager::instance->captureManager();
auto resolution = vcm->activeDevice->currentResolution();
auto selectedItem = static_cast<ComboBoxItem^>(static_cast<ComboBox^>(sender)->SelectedItem);
unsigned int frame_rate = static_cast<unsigned int>(selectedItem->Tag);
std::vector<int>::size_type index;
for(index = 0; index != resolution->rateList()->Size; index++) {
auto rate = resolution->rateList()->GetAt(index);
if (rate->value() == frame_rate)
break;
}
vcm->activeDevice->currentResolution()->setActiveRate( resolution->rateList()->GetAt(index) );
if (vcm->isPreviewing) {
vcm->CleanupCameraAsync()
.then([=](task<void> cleanupCameraTask) {
try {
cleanupCameraTask.get();
vcm->InitializeCameraAsync(true);
}
catch (Exception^ e) {
WriteException(e);
}
});
}
}
}
void
SmartPanel::populateVideoDeviceSettingsComboBox()
{
_videoDeviceComboBox_->Items->Clear();
auto devices = Video::VideoManager::instance->captureManager()->deviceList;
int index = 0;
bool deviceSelected = false;
for (auto device : devices) {
ComboBoxItem^ comboBoxItem = ref new ComboBoxItem();
comboBoxItem->Content = device->name();
comboBoxItem->Tag = device->id();
_videoDeviceComboBox_->Items->Append(comboBoxItem);
if (device->isActive() && !deviceSelected) {
_videoDeviceComboBox_->SelectedIndex = index;
deviceSelected = true;
}
++index;
}
if (!deviceSelected && devices->Size > 0)
_videoDeviceComboBox_->SelectedIndex = 0;
}
void
SmartPanel::populateVideoResolutionSettingsComboBox()
{
_videoResolutionComboBox_->Items->Clear();
Video::Device^ device = Video::VideoManager::instance->captureManager()->activeDevice;
std::map<std::string, std::string> settings = DRing::getSettings(Utils::toString(device->name()));
std::string preferredResolution = settings[Video::Device::PreferenceNames::SIZE];
auto resolutions = device->resolutionList();
int index = 0;
bool resolutionSelected = false;
for (auto resolution : resolutions) {
ComboBoxItem^ comboBoxItem = ref new ComboBoxItem();
comboBoxItem->Content = resolution->getFriendlyName();
comboBoxItem->Tag = resolution->getFriendlyName();
_videoResolutionComboBox_->Items->Append(comboBoxItem);
if (!preferredResolution.compare(Utils::toString(resolution->getFriendlyName())) && !resolutionSelected) {
_videoResolutionComboBox_->SelectedIndex = index;
resolutionSelected = true;
}
++index;
}
if (!resolutionSelected && resolutions->Size > 0)
_videoResolutionComboBox_->SelectedIndex = 0;
}
void
SmartPanel::populateVideoRateSettingsComboBox()
{
_videoRateComboBox_->Items->Clear();
Video::Device^ device = Video::VideoManager::instance->captureManager()->activeDevice;
std::map<std::string, std::string> settings = DRing::getSettings(Utils::toString(device->name()));
std::string preferredRate = settings[Video::Device::PreferenceNames::RATE];
auto resolution = device->currentResolution();
int index = 0;
bool rateSelected = false;
for (auto rate : resolution->rateList()) {
ComboBoxItem^ comboBoxItem = ref new ComboBoxItem();
comboBoxItem->Content = rate->name();
comboBoxItem->Tag = rate->value();
_videoRateComboBox_->Items->Append(comboBoxItem);
if (std::stoi(preferredRate) == rate->value() && !rateSelected) {
_videoRateComboBox_->SelectedIndex = index;
rateSelected = true;
}
++index;
}
if (!rateSelected && resolution->rateList()->Size > 0)
_videoRateComboBox_->SelectedIndex = 0;
}
\ No newline at end of file
......@@ -25,6 +25,8 @@ delegate void ToggleSmartPan();
delegate void SummonMessageTextPage();
delegate void SummonVideoPage();
delegate void SummonWelcomePage();
delegate void SummonPreviewPage();
delegate void HidePreviewPage();
namespace Views
{
......@@ -91,6 +93,8 @@ internal:
event SummonMessageTextPage^ summonMessageTextPage;
event SummonVideoPage^ summonVideoPage;
event SummonWelcomePage^ summonWelcomePage;
event SummonPreviewPage^ summonPreviewPage;
event HidePreviewPage^ hidePreviewPage;
void setMode(RingClientUWP::Views::SmartPanel::Mode mode);
private:
......@@ -116,6 +120,12 @@ private:
void Grid_PointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void _contactItem__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void generateQRcode();
void _videoDeviceComboBox__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^);
void _videoResolutionComboBox__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^);