diff --git a/RingD.cpp b/RingD.cpp index 45c27806d27286892fd4a6ef63f402702f698c38..b0ce153ffbe84d9b9ac86d25a663cbc77290c89a 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -419,6 +419,21 @@ RingD::registerCallbacks() stateChange(Utils::toPlatformString(callId), CallStatus::IN_PROGRESS, 0); })); }), + DRing::exportable_callback<DRing::CallSignal::AudioMuted>([this]( + const std::string& callId, + bool state) + { + // why this cllaback exist ? why are we not using stateChange ? + MSG_("<AudioMuted>"); + MSG_("callId = " + callId); + MSG_("state = " + Utils::toString(state.ToString())); + + CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync( + CoreDispatcherPriority::High, ref new DispatchedHandler([=]() + { + audioMuted(callId, state); + })); + }), DRing::exportable_callback<DRing::CallSignal::StateChange>([this]( const std::string& callId, const std::string& state, @@ -1045,6 +1060,12 @@ RingD::dequeueTasks() bool muted = task->_muted; DRing::muteLocalMedia(callId, DRing::Media::Details::MEDIA_TYPE_VIDEO, muted); } + case Request::MuteAudio: + { + DRing::muteLocalMedia(task->_callid_new + , DRing::Media::Details::MEDIA_TYPE_AUDIO + , task->_audioMuted_new); + } case Request::LookUpName: { auto alias = task->_alias; @@ -1129,6 +1150,16 @@ void RingClientUWP::RingD::muteVideo(String ^ callId, bool muted) tasksList_.push(task); } +void RingClientUWP::RingD::muteAudio(const std::string& callId, bool muted) +{ + auto task = ref new RingD::Task(Request::MuteAudio); + + task->_callid_new = callId; + task->_audioMuted_new = muted; + + tasksList_.push(task); +} + void RingClientUWP::RingD::lookUpName(String ^ name) { auto task = ref new RingD::Task(Request::LookUpName); diff --git a/RingD.h b/RingD.h index 39bed58f718610810c9a5d1eb89e045205f7dc98..e5a2e3b5d08d874a96ae52b403e502ce567f37ce 100644 --- a/RingD.h +++ b/RingD.h @@ -43,6 +43,7 @@ delegate void FinishCaptureDeviceEnumeration(); delegate void RegistrationStateErrorGeneric(const std::string& accountId); delegate void RegistrationStateRegistered(); delegate void CallsListRecieved(const std::vector<std::string>& callsList); +delegate void AudioMuted(const std::string& callId, bool state); using SharedCallback = std::shared_ptr<DRing::CallbackWrapperBase>; using namespace std::placeholders; @@ -129,6 +130,7 @@ internal: void killCall(String^ callId); void switchDebug(); void muteVideo(String^ callId, bool muted); + void muteAudio(const std::string& callId, bool muted); void lookUpName(String^ name); void registerName(String^ accountId, String^ password, String^ username); void registerName_new(const std::string& accountId, const std::string& password, const std::string& username); @@ -155,6 +157,7 @@ internal: event RegistrationStateErrorGeneric^ registrationStateErrorGeneric; event RegistrationStateRegistered^ registrationStateRegistered; 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; private: /* sub classes */ @@ -178,6 +181,7 @@ private: KillCall, switchDebug, MuteVideo, + MuteAudio, LookUpName, LookUpAddress, RegisterName @@ -222,6 +226,7 @@ private: std::string _publicUsername_new; std::string _callid_new; std::string _ringId_new; + bool _audioMuted_new; }; /* functions */ diff --git a/SmartPanelItem.h b/SmartPanelItem.h index a1119c2acb1ebe2398c82aa187721568c7d8dc2a..1f5b34db2198c5e317a67bf3c493d2315b048f85 100644 --- a/SmartPanelItem.h +++ b/SmartPanelItem.h @@ -75,7 +75,7 @@ public: NotifyPropertyChanged("_callStatus"); } } - property bool _videoMuted + property bool _videoMuted // refacto : add set and remove void muteVideo(bool state); { bool get() { @@ -83,6 +83,8 @@ public: } } + property bool _audioMuted; + property Visibility _showMe { Visibility get() diff --git a/VideoPage.xaml b/VideoPage.xaml index b78265fc5b04f818e337f774240074e18755057b..7f0df4f1c66c404c780a0b15f0f27f4e94dab00a 100644 --- a/VideoPage.xaml +++ b/VideoPage.xaml @@ -320,11 +320,26 @@ Tapped="_btnSwitch__Tapped" Visibility="Collapsed"> <SymbolIcon Symbol="Switch"/> </Button> + <!--Tapped="_btnMicrophone__Tapped"--> <Button x:Name="_btnMicrophone_" PointerEntered="btnAny_entered" PointerExited="btnAny_exited" - Tapped="_btnMicrophone__Tapped" Visibility="Collapsed"> - <SymbolIcon Symbol="Microphone"/> + Click="_btnMicrophone__Click"> + <Grid> + <SymbolIcon Symbol="Microphone"/> + <TextBlock x:Name="_txbkMicrophoneMuted_" + Text="" + 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="_btnVideo_" PointerEntered="btnAny_entered" diff --git a/VideoPage.xaml.cpp b/VideoPage.xaml.cpp index 0b6b7db2d270e52d5fdf5ef62b9e4a58a3469356..5fbd6a22f397aeb740adcf31b5173101c421825f 100644 --- a/VideoPage.xaml.cpp +++ b/VideoPage.xaml.cpp @@ -150,6 +150,7 @@ VideoPage::VideoPage() RingD::instance->incomingVideoMuted += ref new RingClientUWP::IncomingVideoMuted(this, &RingClientUWP::Views::VideoPage::OnincomingVideoMuted); 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); } void @@ -288,6 +289,13 @@ void RingClientUWP::Views::VideoPage::_btnSwitch__Tapped(Platform::Object^ sende void RingClientUWP::Views::VideoPage::_btnMicrophone__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e) { switchMicrophoneStateCall(); + auto item = SmartPanelItemsViewModel::instance->_selectedItem; + + auto state = !item->_audioMuted; + item->_audioMuted = state; + + // refacto : compare how video and audios are muted, then decide which solution is best. + RingD::instance->muteAudio(Utils::toString(item->_callId), state); // nb : muteAudio == setMuteAudio } @@ -430,3 +438,23 @@ void RingClientUWP::Views::VideoPage::OnstopPreviewing() { PreviewImage->Visibility = Windows::UI::Xaml::Visibility::Collapsed; } + + +void RingClientUWP::Views::VideoPage::_btnMicrophone__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + switchMicrophoneStateCall(); + auto item = SmartPanelItemsViewModel::instance->_selectedItem; + + auto state = !item->_audioMuted; + item->_audioMuted = state; + + // refacto : compare how video and audios are muted, then decide which solution is best. + RingD::instance->muteAudio(Utils::toString(item->_callId), state); // nb : muteAudio == setMuteAudio +} + + +void RingClientUWP::Views::VideoPage::OnaudioMuted(const std::string &callId, bool state) +{ + _txbkMicrophoneMuted_->Visibility = (state) ? Windows::UI::Xaml::Visibility::Visible + : Windows::UI::Xaml::Visibility::Collapsed; +} diff --git a/VideoPage.xaml.h b/VideoPage.xaml.h index 210e83c05ab51c2d0f5b04c9229f66ca9cf4c5f1..7b306d15175482497c5bb32efd5745c268dbcc73 100644 --- a/VideoPage.xaml.h +++ b/VideoPage.xaml.h @@ -122,6 +122,8 @@ private: void OnincomingVideoMuted(Platform::String ^callId, bool state); void OnstartPreviewing(); void OnstopPreviewing(); + void _btnMicrophone__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void OnaudioMuted(const std::string &callId, bool state); }; } } \ No newline at end of file