diff --git a/MessageTextPage.xaml b/MessageTextPage.xaml index dfe3606b8d2b46fb10c9e449fc7fd2a2796407cb..7c5562cbff67755b43c3792bf5eff778d6d4938d 100644 --- a/MessageTextPage.xaml +++ b/MessageTextPage.xaml @@ -128,28 +128,44 @@ Padding="10,10"> <Image Source="ms-appx:///contact-avatar-test.png" /> <StackPanel> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="auto" /> + <ColumnDefinition Width="auto" /> + </Grid.ColumnDefinitions> <TextBlock x:Name="_title_" + Grid.Column="0" Text="[TEXT MISSING]" TextWrapping="NoWrap" VerticalAlignment="Center" FontSize="20" Margin="20,0" /> + <Button x:Name="_audioCall_" + Grid.Column="1" + Click="_audioCall__Click" + Content="audio call"/> + <Button x:Name="_videoCall_" + Click="_videoCall__Click" + Grid.Column="2" + Content="video call"/> + </Grid> <StackPanel Orientation="Horizontal"> - <ComboBox x:Name="_associableAccountsList_"> - <ComboBox.ItemTemplate> - <DataTemplate x:DataType="local:Account"> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="{x:Bind name_, Mode=OneWay}" /> - </StackPanel> - </DataTemplate> - </ComboBox.ItemTemplate> - </ComboBox> - <Button x:Name="_deleteContact_" - Content="delete" - Click="_deleteContact__Click"/> + <ComboBox x:Name="_associableAccountsList_"> + <ComboBox.ItemTemplate> + <DataTemplate x:DataType="local:Account"> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="{x:Bind name_, Mode=OneWay}" /> + </StackPanel> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + <Button x:Name="_deleteContact_" + Content="delete" + Click="_deleteContact__Click"/> <Button x:Name="_clearConversation_" - Content="clear conversation" - Click="_clearConversation__Click"/> + Content="clear conversation" + Click="_clearConversation__Click"/> </StackPanel> </StackPanel> diff --git a/MessageTextPage.xaml.cpp b/MessageTextPage.xaml.cpp index 76f57f1dec476e74087cfb5754af7ae4613a66c0..b3f2ebf0a46cbed67b7cd8b6659c6f1ac2730422 100644 --- a/MessageTextPage.xaml.cpp +++ b/MessageTextPage.xaml.cpp @@ -199,3 +199,31 @@ void RingClientUWP::Views::MessageTextPage::_clearConversation__Click(Platform:: contact->_conversation->_messages->Clear(); contact->saveConversationToFile(); } + + +void RingClientUWP::Views::MessageTextPage::_audioCall__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + auto button = dynamic_cast<Button^>(e->OriginalSource); + if (button) { + auto item = SmartPanelItemsViewModel::instance->_selectedItem; + if (item) { + auto contact = item->_contact; + if (contact) + RingD::instance->placeCall(contact); + } + } +} + + +void RingClientUWP::Views::MessageTextPage::_videoCall__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + auto button = dynamic_cast<Button^>(e->OriginalSource); + if (button) { + auto item = SmartPanelItemsViewModel::instance->_selectedItem; + if (item) { + auto contact = item->_contact; + if (contact) + RingD::instance->placeCall(contact); + } + } +} diff --git a/MessageTextPage.xaml.h b/MessageTextPage.xaml.h index e8fbf9209aa1c0713a8c4bc290522d0baa34bdd8..8dd8d7d61b0332e10691a777b31aaa4cc57c021f 100644 --- a/MessageTextPage.xaml.h +++ b/MessageTextPage.xaml.h @@ -59,6 +59,8 @@ private: void _deleteContact__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _clearConversation__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void _audioCall__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void _videoCall__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); }; } } diff --git a/RingD.cpp b/RingD.cpp index 788e6ca9bd25e4e70a02cbc93be1e76fdfd25b9d..8495a12cf6a72db80745464fd55e01be30272669 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -29,6 +29,7 @@ #include "account_const.h" #include "string_utils.h" // used to get some const expr like TRUE_STR #include "gnutls\gnutls.h" +#include "media_const.h" // used to get some const expr like MEDIA_TYPE_VIDEO #include "SmartPanel.xaml.h" @@ -582,6 +583,8 @@ RingClientUWP::RingD::startDaemon() Utils::toPlatformString(id), width, height); + auto callId2 = Utils::toPlatformString(id); + incomingVideoMuted(callId2, false); })); }), DRing::exportable_callback<DRing::VideoSignal::DecodingStopped> @@ -589,6 +592,8 @@ RingClientUWP::RingD::startDaemon() dispatcher->RunAsync(CoreDispatcherPriority::High, ref new DispatchedHandler([=]() { Video::VideoManager::instance->rendererManager()->removeRenderer(Utils::toPlatformString(id)); + auto callId2 = Utils::toPlatformString(id); + incomingVideoMuted(callId2, true); })); }) }; @@ -879,6 +884,12 @@ RingD::dequeueTasks() debugModeOn_ = !debugModeOn_; break; } + case Request::MuteVideo: + { + auto callId = Utils::toString(task->_callId); + bool muted = task->_muted; + DRing::muteLocalMedia(callId, DRing::Media::Details::MEDIA_TYPE_VIDEO, muted); + } default: break; } @@ -922,6 +933,16 @@ void RingClientUWP::RingD::switchDebug() tasksList_.push(task); } +void RingClientUWP::RingD::muteVideo(String ^ callId, bool muted) +{ + auto task = ref new RingD::Task(Request::MuteVideo); + + task->_callId = callId; + task->_muted = muted; + + tasksList_.push(task); +} + RingClientUWP::CallStatus RingClientUWP::RingD::translateCallStatus(String^ state) { if (state == "INCOMING") diff --git a/RingD.h b/RingD.h index d46fcbc0f1ce6e5f00f4d0ad4077661b4292d65a..f3f52acc20de9ee2b8f890979addcb7830cb3ea2 100644 --- a/RingD.h +++ b/RingD.h @@ -36,6 +36,7 @@ delegate void DevicesListRefreshed(Vector<String^>^ devicesList); delegate void ExportOnRingEnded(String^ accountId, String^ pin); delegate void SummonWizard(); delegate void AccountUpdated(Account^ account); +delegate void IncomingVideoMuted(String^ callId, bool state); public ref class RingD sealed @@ -102,6 +103,7 @@ internal: void getCallsList(); void killCall(String^ callId); void switchDebug(); + void muteVideo(String^ callId, bool muted); /* TODO : move members */ String ^ currentCallId; // to save ongoing call id during visibility change @@ -116,6 +118,7 @@ internal: event ExportOnRingEnded^ exportOnRingEnded; event SummonWizard^ summonWizard; event AccountUpdated^ accountUpdated; + event IncomingVideoMuted^ incomingVideoMuted; private: /* sub classes */ @@ -137,6 +140,7 @@ private: GetCallsList, KillCall, switchDebug, + MuteVideo }; @@ -168,6 +172,7 @@ private: property String^ _sipPassword; property String^ _sipHostname; property String^ _sipUsername; + property bool _muted; }; /* functions */ diff --git a/SmartPanelItem.cpp b/SmartPanelItem.cpp index ebf3eee9dac14f19d3ffe19270ee0b9bb6ac57ff..be4254ba73a743632b904019bbec57206fdc2697 100644 --- a/SmartPanelItem.cpp +++ b/SmartPanelItem.cpp @@ -32,10 +32,17 @@ using namespace ViewModel; SmartPanelItem::SmartPanelItem() { _callId = ""; + videoMuted_ = false; RingD::instance->callPlaced += ref new RingClientUWP::CallPlaced(this, &RingClientUWP::Controls::SmartPanelItem::OncallPlaced); } +void RingClientUWP::Controls::SmartPanelItem::muteVideo(bool state) +{ + videoMuted_ = state; + RingD::instance->muteVideo(_callId, state); +} + void SmartPanelItem::NotifyPropertyChanged(String^ propertyName) { diff --git a/SmartPanelItem.h b/SmartPanelItem.h index ded98eaa6002f15499ef4b061478e39e090bd46d..a952378b0b03775b19bd610a092f7bc3c42fba43 100644 --- a/SmartPanelItem.h +++ b/SmartPanelItem.h @@ -29,6 +29,7 @@ public ref class SmartPanelItem sealed : public INotifyPropertyChanged { public: SmartPanelItem(); + void muteVideo(bool state); virtual event PropertyChangedEventHandler^ PropertyChanged; property Contact^ _contact; @@ -74,6 +75,13 @@ public: NotifyPropertyChanged("_callStatus"); } } + property bool _videoMuted + { + bool get() + { + return videoMuted_; + } + } protected: void NotifyPropertyChanged(String^ propertyName); @@ -82,6 +90,7 @@ private: Visibility hovered_ = Visibility::Collapsed; CallStatus callStatus_; String^ callId_; + bool videoMuted_; void OncallPlaced(Platform::String ^callId); }; diff --git a/VideoPage.xaml b/VideoPage.xaml index ce28b48a1b932ab415dcb71a6b31a8aa3278020c..79fdecc0ce74692172e1467986fd38132c8d6206 100644 --- a/VideoPage.xaml +++ b/VideoPage.xaml @@ -155,6 +155,16 @@ <Image Name="IncomingVideoImage" Grid.Column="0" Canvas.ZIndex="-1"/> + <TextBlock Name="_MutedVideoIcon_" + Grid.Column="0" + Text="" + Foreground="White" + FontSize="200" + VerticalAlignment="Center" + HorizontalAlignment="Center" + FontFamily="Segoe MDL2 Assets" + Visibility="Collapsed" + Canvas.ZIndex="-1"/> <!--camera preview--> <CaptureElement Name="PreviewImage" @@ -300,7 +310,8 @@ <Button x:Name="_btnVideo_" PointerEntered="btnAny_entered" PointerExited="btnAny_exited" - Tapped="_btnVideo__Tapped" Visibility="Collapsed"> + Click="_btnVideo__Click" + Tapped="_btnVideo__Tapped"> <SymbolIcon Symbol="Video"/> </Button> <Button x:Name="_btnMemo_" diff --git a/VideoPage.xaml.cpp b/VideoPage.xaml.cpp index ab004b831c4cc3a38759c7008b75aab2c01636ce..d4be80c6b5a7ccb23efe89dd8d98b8a5a1c5dc02 100644 --- a/VideoPage.xaml.cpp +++ b/VideoPage.xaml.cpp @@ -41,6 +41,7 @@ using namespace Windows::UI::Xaml::Navigation; using namespace Windows::Media::Capture; using namespace Windows::ApplicationModel::Core; using namespace Windows::UI::Core; +using namespace Windows::UI; using namespace Windows::Graphics::Display; using namespace Windows::Graphics::Imaging; @@ -130,6 +131,7 @@ VideoPage::VideoPage() }); RingD::instance->incomingMessage += ref new RingClientUWP::IncomingMessage(this, &RingClientUWP::Views::VideoPage::OnincomingMessage); + RingD::instance->incomingVideoMuted += ref new RingClientUWP::IncomingVideoMuted(this, &RingClientUWP::Views::VideoPage::OnincomingVideoMuted); } void @@ -346,3 +348,23 @@ void RingClientUWP::Views::VideoPage::OnincomingMessage(Platform::String ^callId { scrollDown(); } + + +void RingClientUWP::Views::VideoPage::_btnVideo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + auto item = SmartPanelItemsViewModel::instance->_selectedItem; + + item->muteVideo(!item->_videoMuted); +} + + +void RingClientUWP::Views::VideoPage::OnincomingVideoMuted(Platform::String ^callId, bool state) +{ + /*_MutedVideoIcon_->Visibility = (state) + ? Windows::UI::Xaml::Visibility::Visible + : Windows::UI::Xaml::Visibility::Collapsed;*/ + + IncomingVideoImage->Visibility = (state) + ? Windows::UI::Xaml::Visibility::Collapsed + : Windows::UI::Xaml::Visibility::Visible; +} diff --git a/VideoPage.xaml.h b/VideoPage.xaml.h index e92e97aa1b9adc145e2a590181ee92f97ad45e00..48c82d71ea01079ada3d167b6a556cba547edab0 100644 --- a/VideoPage.xaml.h +++ b/VideoPage.xaml.h @@ -116,6 +116,8 @@ private: void btnAny_entered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); void btnAny_exited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); void OnincomingMessage(Platform::String ^callId, Platform::String ^payload); + void _btnVideo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void OnincomingVideoMuted(Platform::String ^callId, bool state); }; } } \ No newline at end of file