Commit 91b10dbf authored by Ronan's avatar Ronan Committed by Ronan

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

parent b8e06084
......@@ -1449,13 +1449,13 @@ static void sip_config_read(LinphoneCore *lc) {
tmp=lp_config_get_int(lc->config,"sip","delayed_timeout",4);
linphone_core_set_delayed_timeout(lc,tmp);
/*In case of remote provisionning, function sip_config_read is initialy called in core_init, then in state ConfiguringSuccessfull*/
/*Accordingly, to avoid proxy_config to be added twice, it is mandatory to reset proxy config list from LinphoneCore*/
/*We assume, lc->config contains an accurate list of proxy_config, so no need to keep it from LinphoneCore */
/*Consequence in case of remote provisionning, linphone_core_add_proxy function should not be called before state GlobalOn*/
linphone_core_clear_proxy_config(lc);
/* get proxies config */
for(i=0;; i++){
LinphoneProxyConfig *cfg=linphone_proxy_config_new_from_config_file(lc,i);
......@@ -4583,10 +4583,10 @@ void linphone_core_enable_mic(LinphoneCore *lc, bool_t enable) {
list = linphone_core_get_calls(lc);
for (elem = list; elem != NULL; elem = elem->next) {
call = (LinphoneCall *)elem->data;
linphone_call_set_audio_muted(call, !enable);
linphone_call_set_microphone_muted(call, !enable);
AudioStream *astream = reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
if (astream)
linphone_core_mute_audio_stream(lc, astream, linphone_call_get_audio_muted(call));
linphone_core_mute_audio_stream(lc, astream, linphone_call_get_microphone_muted(call));
}
}
......@@ -4598,7 +4598,7 @@ bool_t linphone_core_mic_enabled(LinphoneCore *lc) {
ms_warning("%s(): No current call!", __FUNCTION__);
return TRUE;
}
return !linphone_call_get_audio_muted(call);
return !linphone_call_get_microphone_muted(call);
}
bool_t linphone_core_is_rtp_muted(LinphoneCore *lc){
......@@ -4608,7 +4608,7 @@ bool_t linphone_core_is_rtp_muted(LinphoneCore *lc){
return FALSE;
}
if( linphone_core_get_rtp_no_xmit_on_audio_mute(lc)){
return linphone_call_get_audio_muted(call);
return linphone_call_get_microphone_muted(call);
}
return FALSE;
}
......
......@@ -70,9 +70,6 @@ LINPHONE_PUBLIC LinphoneCallLog * linphone_call_get_log(const LinphoneCall *call
// FIXME: Remove this declaration, use LINPHONE_PUBLIC as ugly workaround, already defined in tester_utils.h
LINPHONE_PUBLIC IceSession *linphone_call_get_ice_session(const LinphoneCall *call);
bool_t linphone_call_get_audio_muted(const LinphoneCall *call);
void linphone_call_set_audio_muted(LinphoneCall *call, bool_t value);
// FIXME: Remove this declaration, use LINPHONE_PUBLIC as ugly workaround, already defined in tester_utils.h
LINPHONE_PUBLIC bool_t linphone_call_get_all_muted(const LinphoneCall *call);
......
......@@ -481,7 +481,7 @@ LINPHONE_PUBLIC LinphoneStatus linphone_call_accept_early_media_with_params (Lin
/**
* Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore.
* It triggers a SIP reINVITE in order to perform a new offer/answer of media capabilities.
* It triggers a SIP reINVITE in order to perform a new offer/answer of media capabilities.
* Changing the size of the transmitted video after calling #linphone_core_set_preferred_video_size() can be used by passing NULL as params argument.
* In case no changes are requested through the #LinphoneCallParams argument, then this argument can be omitted and set to NULL.
* WARNING: Updating a call in the #LinphoneCallPaused state will still result in a paused call even if the media directions set in the
......@@ -642,7 +642,7 @@ LINPHONE_PUBLIC float linphone_call_get_record_volume(const LinphoneCall *call);
* If the sound backend supports it, the returned gain is equal to the gain set
* with the system mixer.
* @param call The call.
* @return Percenatge of the max supported volume gain. Valid values are in [ 0.0 : 1.0 ].
* @return Percentage of the max supported volume gain. Valid values are in [ 0.0 : 1.0 ].
* In case of failure, a negative value is returned
*/
LINPHONE_PUBLIC float linphone_call_get_speaker_volume_gain(const LinphoneCall *call);
......@@ -659,8 +659,8 @@ LINPHONE_PUBLIC void linphone_call_set_speaker_volume_gain(LinphoneCall *call, f
* Get microphone volume gain.
* If the sound backend supports it, the returned gain is equal to the gain set
* with the system mixer.
* @param call The call.
* @return double Percenatge of the max supported volume gain. Valid values are in [ 0.0 : 1.0 ].
* @param call The #LinphoneCall object.
* @return double Percentage of the max supported volume gain. Valid values are in [ 0.0 : 1.0 ].
* In case of failure, a negative value is returned
*/
LINPHONE_PUBLIC float linphone_call_get_microphone_volume_gain(const LinphoneCall *call);
......@@ -668,11 +668,25 @@ LINPHONE_PUBLIC float linphone_call_get_microphone_volume_gain(const LinphoneCal
/**
* Set microphone volume gain.
* If the sound backend supports it, the new gain will synchronized with the system mixer.
* @param call The call.
* @param call The #LinphoneCall object.
* @param volume Percentage of the max supported gain. Valid values are in [ 0.0 : 1.0 ].
*/
LINPHONE_PUBLIC void linphone_call_set_microphone_volume_gain(LinphoneCall *call, float volume);
/**
* Get microphone muted state.
* @param call The #LinphoneCall object.
* @return The microphone muted state.
**/
LINPHONE_PUBLIC bool_t linphone_call_get_microphone_muted (const LinphoneCall *call);
/**
* Set microphone muted state.
* @param call The #LinphoneCall object.
* @param muted The microphone muted state.
**/
LINPHONE_PUBLIC void linphone_call_set_microphone_muted (LinphoneCall *call, bool_t muted);
/**
* Obtain real-time quality rating of the call
*
......@@ -796,7 +810,7 @@ LINPHONE_PUBLIC void linphone_call_set_params(LinphoneCall *call, const Linphone
* @param call the #LinphoneCall object
* @return the call's local parameters.
**/
LINPHONE_PUBLIC const LinphoneCallParams * linphone_call_get_params(LinphoneCall *call);
LINPHONE_PUBLIC const LinphoneCallParams *linphone_call_get_params(LinphoneCall *call);
/**
* @}
......
......@@ -126,14 +126,6 @@ IceSession * linphone_call_get_ice_session (const LinphoneCall *call) {
return L_GET_PRIVATE_FROM_C_OBJECT(call)->getIceSession();
}
bool_t linphone_call_get_audio_muted (const LinphoneCall *call) {
return L_GET_PRIVATE_FROM_C_OBJECT(call)->getAudioMuted();
}
void linphone_call_set_audio_muted (LinphoneCall *call, bool_t value) {
L_GET_PRIVATE_FROM_C_OBJECT(call)->setAudioMuted(!!value);
}
bool_t linphone_call_get_all_muted (const LinphoneCall *call) {
return L_GET_CPP_PTR_FROM_C_OBJECT(call)->getAllMuted();
}
......@@ -549,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_microphone_muted (const LinphoneCall *call) {
return L_GET_PRIVATE_FROM_C_OBJECT(call)->getMicrophoneMuted();
}
void linphone_call_set_microphone_muted (LinphoneCall *call, bool_t muted) {
L_GET_PRIVATE_FROM_C_OBJECT(call)->setMicrophoneMuted(!!muted);
}
float linphone_call_get_current_quality (const LinphoneCall *call) {
return L_GET_CPP_PTR_FROM_C_OBJECT(call)->getCurrentQuality();
}
......
......@@ -48,7 +48,6 @@ public:
std::shared_ptr<Call> startReferredCall (const MediaSessionParams *params);
virtual std::shared_ptr<CallSession> getActiveSession () const { return nullptr; }
bool getAudioMuted () const;
std::shared_ptr<RealTimeTextChatRoom> getChatRoom ();
LinphoneProxyConfig *getDestProxy () const;
......@@ -56,9 +55,13 @@ public:
unsigned int getMediaStartCount () const;
MediaStream *getMediaStream (LinphoneStreamType type) const;
SalCallOp *getOp () const;
bool getRingingBeep () const { return ringingBeep; }
void setAudioMuted (bool value);
void setRingingBeep (bool value) { ringingBeep = value; }
bool getMicrophoneMuted () const;
void setMicrophoneMuted (bool muted);
LinphoneCallStats *getStats (LinphoneStreamType type) const;
void createPlayer () const;
......
......@@ -34,10 +34,6 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
bool CallPrivate::getAudioMuted () const {
return static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->getAudioMuted();
}
shared_ptr<RealTimeTextChatRoom> CallPrivate::getChatRoom () {
L_Q();
if (!chatRoom && (q->getState() != CallSession::State::End) && (q->getState() != CallSession::State::Released)) {
......@@ -67,8 +63,12 @@ SalCallOp * CallPrivate::getOp () const {
return getActiveSession()->getPrivate()->getOp();
}
void CallPrivate::setAudioMuted (bool value) {
static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->setAudioMuted(value);
bool CallPrivate::getMicrophoneMuted () const {
return static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->getMicrophoneMuted();
}
void CallPrivate::setMicrophoneMuted (bool muted) {
static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->setMicrophoneMuted(muted);
}
LinphoneCallStats *CallPrivate::getStats (LinphoneStreamType type) const {
......@@ -414,7 +414,7 @@ void CallPrivate::onFirstVideoFrameDecoded (const shared_ptr<CallSession> &sessi
}
void CallPrivate::onResetFirstVideoFrameDecoded (const shared_ptr<CallSession> &session) {
/*we are called here by the MediaSession when the stream start to know whether there is the deprecated nextVideoFrameDecoded callback set,
/*we are called here by the MediaSession when the stream start to know whether there is the deprecated nextVideoFrameDecoded callback set,
* so that we can request the notification of the next frame decoded.*/
#ifdef VIDEO_ENABLED
if (nextVideoFrameDecoded._func)
......
......@@ -66,7 +66,8 @@ public:
int getAf () const { return af; }
bool getAudioMuted () const { return audioMuted; }
bool getMicrophoneMuted () const;
void setMicrophoneMuted (bool muted);
MediaSessionParams *getCurrentParams () const { return static_cast<MediaSessionParams *>(currentParams); }
MediaSessionParams *getParams () const { return static_cast<MediaSessionParams *>(params); }
......@@ -90,7 +91,6 @@ public:
int getStreamIndex (MediaStream *ms) const;
SalCallOp * getOp () const { return op; }
MSWebCam *getVideoDevice () const;
void setAudioMuted (bool value) { audioMuted = value; }
void initializeStreams ();
void stopStreams ();
......@@ -324,8 +324,9 @@ private:
// Upload bandwidth used by audio.
int audioBandwidth = 0;
bool microphoneMuted = false;
bool allMuted = false;
bool audioMuted = false;
bool automaticallyPaused = false;
bool pausedByApp = false;
bool recordActive = false;
......
......@@ -507,6 +507,30 @@ void MediaSessionPrivate::stopStreamsForIceGathering () {
// -----------------------------------------------------------------------------
bool MediaSessionPrivate::getMicrophoneMuted () const {
return microphoneMuted;
}
void MediaSessionPrivate::setMicrophoneMuted (bool muted) {
L_Q();
if (microphoneMuted == muted)
return;
microphoneMuted = muted;
if (!audioStream)
return;
if (state == CallSession::State::StreamsRunning) {
if (muted)
audio_stream_set_mic_gain(audioStream, 0);
else
audio_stream_set_mic_gain_db(audioStream, q->getCore()->getCCore()->sound_conf.soft_mic_lev);
}
}
// -----------------------------------------------------------------------------
void MediaSessionPrivate::setCurrentParams (MediaSessionParams *msp) {
if (currentParams)
delete currentParams;
......@@ -1379,7 +1403,7 @@ void MediaSessionPrivate::makeLocalMediaDescription () {
strncpy(md->addr, mediaLocalIp.c_str(), sizeof(md->addr));
md->addr[sizeof(md->addr) - 1] = '\0';
LinphoneAddress *addr = nullptr;
if (destProxy) {
addr = linphone_address_clone(linphone_proxy_config_get_identity_address(destProxy));
......@@ -1769,7 +1793,7 @@ void MediaSessionPrivate::setupDtlsParams (MediaStream *ms) {
char *certificate = nullptr;
char *key = nullptr;
char *fingerprint = nullptr;
sal_certificates_chain_parse_directory(&certificate, &key, &fingerprint,
linphone_core_get_user_certificates_path(q->getCore()->getCCore()), "linphone-dtls-default-identity", SAL_CERTIFICATE_RAW_FORMAT_PEM, true, true);
if (fingerprint) {
......@@ -2441,8 +2465,8 @@ void MediaSessionPrivate::initializeAudioStream () {
audio_stream_enable_echo_limiter(audioStream, ELControlFull);
}
/* Equalizer location in the graph: 'mic' = in input graph, otherwise in output graph.
Any other value than mic will default to output graph for compatibility */
// Equalizer location in the graph: 'mic' = in input graph, otherwise in output graph.
// Any other value than mic will default to output graph for compatibility.
string location = lp_config_get_string(linphone_core_get_config(q->getCore()->getCCore()), "sound", "eq_location", "hp");
audioStream->eq_loc = (location == "mic") ? MSEqualizerMic : MSEqualizerHP;
lInfo() << "Equalizer location: " << location;
......@@ -2760,7 +2784,7 @@ void MediaSessionPrivate::startAudioStream (CallSession::State targetState, bool
(linphone_core_rtcp_enabled(q->getCore()->getCCore()) && !isMulticast) ? (stream->rtcp_port ? stream->rtcp_port : stream->rtp_port + 1) : 0,
usedPt, &io);
if (err == 0)
postConfigureAudioStreams((allMuted || audioMuted) && (listener && !listener->isPlayingRingbackTone(q->getSharedFromThis())));
postConfigureAudioStreams((allMuted || microphoneMuted) && (listener && !listener->isPlayingRingbackTone(q->getSharedFromThis())));
}
ms_media_stream_sessions_set_encryption_mandatory(&audioStream->ms.sessions, isEncryptionMandatory());
if ((targetState == CallSession::State::Paused) && !captcard && !playfile.empty()) {
......@@ -3641,8 +3665,8 @@ LinphoneStatus MediaSessionPrivate::startUpdate (const string &subject) {
op->setLocalMediaDescription(nullptr);
LinphoneStatus result = CallSessionPrivate::startUpdate(subject);
if (q->getCore()->getCCore()->sip_conf.sdp_200_ack) {
/* We are NOT offering, set local media description after sending the call so that we are ready to
* process the remote offer when it will arrive. */
// We are NOT offering, set local media description after sending the call so that we are ready to
// process the remote offer when it will arrive.
op->setLocalMediaDescription(localDesc);
}
return result;
......@@ -4315,7 +4339,7 @@ int MediaSession::startInvite (const Address *destination, const string &subject
}
if (getCore()->getCCore()->sip_conf.sdp_200_ack) {
/* We are NOT offering, set local media description after sending the call so that we are ready to
process the remote offer when it will arrive. */
process the remote offer when it will arrive. */
d->op->setLocalMediaDescription(d->localDesc);
}
return result;
......@@ -4647,7 +4671,7 @@ float MediaSession::getPlayVolume () const {
float MediaSession::getRecordVolume () const {
L_D();
if (d->audioStream && d->audioStream->volsend && !d->audioMuted && (d->state == CallSession::State::StreamsRunning)) {
if (d->audioStream && d->audioStream->volsend && !d->microphoneMuted && (d->state == CallSession::State::StreamsRunning)) {
float vol = 0;
ms_filter_call_method(d->audioStream->volsend, MS_VOLUME_GET, &vol);
return vol;
......
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