From f11cbec87de131d62a76ea126a540297745064ee Mon Sep 17 00:00:00 2001
From: Nicolas Jager <nicolas.jager@savoirfairelinux.com>
Date: Wed, 7 Dec 2016 13:20:07 -0500
Subject: [PATCH] video : add icon for muted video

Change-Id: Iba4f3c03c0fb833d4e4caf19fc5d1218f9937a78
Tuleap: #790
---
 RingD.cpp          | 15 +++++++++++++++
 RingD.h            |  2 ++
 VideoPage.xaml     | 20 +++++++++++++++++---
 VideoPage.xaml.cpp |  8 ++++++++
 VideoPage.xaml.h   |  1 +
 5 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/RingD.cpp b/RingD.cpp
index 9f6c6ac..07a5988 100644
--- a/RingD.cpp
+++ b/RingD.cpp
@@ -434,6 +434,21 @@ RingD::registerCallbacks()
                 audioMuted(callId, state);
             }));
         }),
+        DRing::exportable_callback<DRing::CallSignal::VideoMuted>([this](
+                    const std::string& callId,
+                    bool state)
+        {
+            // why this cllaback exist ? why are we not using stateChange ?
+            MSG_("<VideoMuted>");
+            MSG_("callId = " + callId);
+            MSG_("state = " + Utils::toString(state.ToString()));
+
+            CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
+                CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
+            {
+                videoMuted(callId, state);
+            }));
+        }),
         DRing::exportable_callback<DRing::CallSignal::StateChange>([this](
                     const std::string& callId,
                     const std::string& state,
diff --git a/RingD.h b/RingD.h
index 05f8935..c7c727d 100644
--- a/RingD.h
+++ b/RingD.h
@@ -45,6 +45,7 @@ delegate void RegistrationStateRegistered();
 delegate void SetLoadingStatusText(String^ statusText, String^ color);
 delegate void CallsListRecieved(const std::vector<std::string>& callsList);
 delegate void AudioMuted(const std::string& callId, bool state);
+delegate void VideoMuted(const std::string& callId, bool state);
 delegate void NameRegistred(bool status);
 delegate void VolatileDetailsChanged(const std::string& accountId, const std::map<std::string, std::string>& details);
 
@@ -162,6 +163,7 @@ internal:
     event SetLoadingStatusText^ setLoadingStatusText;
     event CallsListRecieved^ callsListRecieved; // est implemente a la base pour regler le probleme du boutton d'appel qui est present lorsqu'un appel est en cours, mais il n'est pas utilise. Voir si ca peut servir a autre chose
     event AudioMuted^ audioMuted;
+    event VideoMuted^ videoMuted;
     event NameRegistred^ nameRegistred;
     event VolatileDetailsChanged^ volatileDetailsChanged;
 
diff --git a/VideoPage.xaml b/VideoPage.xaml
index 7f0df4f..5a13ca7 100644
--- a/VideoPage.xaml
+++ b/VideoPage.xaml
@@ -341,12 +341,26 @@
                                 </TextBlock>
                             </Grid>
                         </Button>
+                        <!--Tapped="_btnVideo__Tapped"-->
                         <Button x:Name="_btnVideo_"
                             PointerEntered="btnAny_entered"
                             PointerExited="btnAny_exited"
-                            Click="_btnVideo__Click"
-                            Tapped="_btnVideo__Tapped">
-                            <SymbolIcon Symbol="Video"/>
+                            Click="_btnVideo__Click">
+                            <Grid>
+                                <SymbolIcon Symbol="Video"/>
+                                <TextBlock x:Name="_txbkVideoMuted_"
+                                           Text="&#xE25B;"
+                                           FontSize="16"
+                                           IsHitTestVisible="True"
+                                           Visibility="Collapsed"
+                                           Foreground="Red"
+                                           FontWeight="Bold"
+                                           FontFamily="Segoe MDL2 Assets">
+                                    <TextBlock.RenderTransform>
+                                        <TranslateTransform X="1" Y="2"/>
+                                    </TextBlock.RenderTransform>
+                                </TextBlock>
+                            </Grid>
                         </Button>
                         <Button x:Name="_btnMemo_"
                             PointerEntered="btnAny_entered"
diff --git a/VideoPage.xaml.cpp b/VideoPage.xaml.cpp
index 5fbd6a2..c212990 100644
--- a/VideoPage.xaml.cpp
+++ b/VideoPage.xaml.cpp
@@ -151,6 +151,7 @@ VideoPage::VideoPage()
     VideoManager::instance->captureManager()->startPreviewing += ref new RingClientUWP::StartPreviewing(this, &RingClientUWP::Views::VideoPage::OnstartPreviewing);
     VideoManager::instance->captureManager()->stopPreviewing += ref new RingClientUWP::StopPreviewing(this, &RingClientUWP::Views::VideoPage::OnstopPreviewing);
     RingD::instance->audioMuted += ref new RingClientUWP::AudioMuted(this, &RingClientUWP::Views::VideoPage::OnaudioMuted);
+    RingD::instance->videoMuted += ref new RingClientUWP::VideoMuted(this, &RingClientUWP::Views::VideoPage::OnvideoMuted);
 }
 
 void
@@ -458,3 +459,10 @@ void RingClientUWP::Views::VideoPage::OnaudioMuted(const std::string &callId, bo
     _txbkMicrophoneMuted_->Visibility = (state) ? Windows::UI::Xaml::Visibility::Visible
                                         : Windows::UI::Xaml::Visibility::Collapsed;
 }
+
+
+void RingClientUWP::Views::VideoPage::OnvideoMuted(const std::string &callId, bool state)
+{
+    _txbkVideoMuted_->Visibility = (state) ? Windows::UI::Xaml::Visibility::Visible
+                                   : Windows::UI::Xaml::Visibility::Collapsed;
+}
diff --git a/VideoPage.xaml.h b/VideoPage.xaml.h
index 7b306d1..ffd567a 100644
--- a/VideoPage.xaml.h
+++ b/VideoPage.xaml.h
@@ -124,6 +124,7 @@ private:
     void OnstopPreviewing();
     void _btnMicrophone__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
     void OnaudioMuted(const std::string &callId, bool state);
+    void OnvideoMuted(const std::string &callId, bool state);
 };
 }
 }
\ No newline at end of file
-- 
GitLab