Commit 60022a5d authored by Nicolas Jager's avatar Nicolas Jager

Audio : implementation of (un)muting actions.

Change-Id: I034fe535593ddf41e825c97ba707164c9e256268
Tuleap: #790
parent 890921f2
......@@ -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);
......
......@@ -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 */
......
......@@ -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()
......
......@@ -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="&#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="_btnVideo_"
PointerEntered="btnAny_entered"
......
......@@ -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;
}
......@@ -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
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