Commit 2d8c8d46 authored by Ronan's avatar Ronan
Browse files

feat(call): add a public api to mute speaker

parent 91b10dbf
......@@ -673,6 +673,20 @@ LINPHONE_PUBLIC float linphone_call_get_microphone_volume_gain(const LinphoneCal
*/
LINPHONE_PUBLIC void linphone_call_set_microphone_volume_gain(LinphoneCall *call, float volume);
/**
* Get speaker muted state.
* @param call The #LinphoneCall object.
* @return The speaker muted state.
**/
LINPHONE_PUBLIC bool_t linphone_call_get_speaker_muted (const LinphoneCall *call);
/**
* Set speaker muted state.
* @param call The #LinphoneCall object.
* @param muted The speaker muted state.
**/
LINPHONE_PUBLIC void linphone_call_set_speaker_muted (LinphoneCall *call, bool_t muted);
/**
* Get microphone muted state.
* @param call The #LinphoneCall object.
......
......@@ -541,6 +541,14 @@ void linphone_call_set_microphone_volume_gain (LinphoneCall *call, float volume)
L_GET_CPP_PTR_FROM_C_OBJECT(call)->setMicrophoneVolumeGain(volume);
}
bool_t linphone_call_get_speaker_muted (const LinphoneCall *call) {
return L_GET_PRIVATE_FROM_C_OBJECT(call)->getSpeakerMuted();
}
void linphone_call_set_speaker_muted (LinphoneCall *call, bool_t muted) {
L_GET_PRIVATE_FROM_C_OBJECT(call)->setSpeakerMuted(!!muted);
}
bool_t linphone_call_get_microphone_muted (const LinphoneCall *call) {
return L_GET_PRIVATE_FROM_C_OBJECT(call)->getMicrophoneMuted();
}
......
......@@ -59,6 +59,9 @@ public:
bool getRingingBeep () const { return ringingBeep; }
void setRingingBeep (bool value) { ringingBeep = value; }
bool getSpeakerMuted () const;
void setSpeakerMuted (bool muted);
bool getMicrophoneMuted () const;
void setMicrophoneMuted (bool muted);
......
......@@ -63,6 +63,14 @@ SalCallOp * CallPrivate::getOp () const {
return getActiveSession()->getPrivate()->getOp();
}
bool CallPrivate::getSpeakerMuted () const {
return static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->getSpeakerMuted();
}
void CallPrivate::setSpeakerMuted (bool muted) {
static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->setSpeakerMuted(muted);
}
bool CallPrivate::getMicrophoneMuted () const {
return static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->getMicrophoneMuted();
}
......
......@@ -66,6 +66,10 @@ public:
int getAf () const { return af; }
bool getSpeakerMuted () const;
void setSpeakerMuted (bool muted);
void forceSpeakerMuted (bool muted);
bool getMicrophoneMuted () const;
void setMicrophoneMuted (bool muted);
......@@ -259,6 +263,7 @@ private:
int sendDtmf ();
void stunAuthRequestedCb (const char *realm, const char *nonce, const char **username, const char **password, const char **ha1);
private:
static const std::string ecStateStore;
static const int ecStateMaxLen;
......@@ -324,6 +329,7 @@ private:
// Upload bandwidth used by audio.
int audioBandwidth = 0;
bool speakerMuted = false;
bool microphoneMuted = false;
bool allMuted = false;
......
......@@ -507,6 +507,33 @@ void MediaSessionPrivate::stopStreamsForIceGathering () {
// -----------------------------------------------------------------------------
bool MediaSessionPrivate::getSpeakerMuted () const {
return speakerMuted;
}
void MediaSessionPrivate::setSpeakerMuted (bool muted) {
if (speakerMuted == muted)
return;
speakerMuted = muted;
if (state == CallSession::State::StreamsRunning)
forceSpeakerMuted(speakerMuted);
}
void MediaSessionPrivate::forceSpeakerMuted (bool muted) {
L_Q();
if (!audioStream)
return;
if (muted)
audio_stream_set_spk_gain(audioStream, 0);
else
audio_stream_set_spk_gain_db(audioStream, q->getCore()->getCCore()->sound_conf.soft_play_lev);
}
// -----------------------------------------------------------------------------
bool MediaSessionPrivate::getMicrophoneMuted () const {
return microphoneMuted;
}
......@@ -522,7 +549,7 @@ void MediaSessionPrivate::setMicrophoneMuted (bool muted) {
return;
if (state == CallSession::State::StreamsRunning) {
if (muted)
if (microphoneMuted)
audio_stream_set_mic_gain(audioStream, 0);
else
audio_stream_set_mic_gain_db(audioStream, q->getCore()->getCCore()->sound_conf.soft_mic_lev);
......@@ -2635,6 +2662,7 @@ void MediaSessionPrivate::prepareEarlyMediaForking () {
void MediaSessionPrivate::postConfigureAudioStreams (bool muted) {
L_Q();
q->getCore()->getPrivate()->postConfigureAudioStream(audioStream, muted);
forceSpeakerMuted(speakerMuted);
if (linphone_core_dtmf_received_has_listener(q->getCore()->getCCore()))
audio_stream_play_received_dtmfs(audioStream, false);
if (recordActive)
......
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