Commit 94755c15 authored by QuentinArguillere's avatar QuentinArguillere
Browse files

Add call to new method audio_stream_enable_mic, and flag...

Add call to new method audio_stream_enable_mic, and flag disable_record_on_mute to the core configuration
parent 63bce652
......@@ -1401,7 +1401,7 @@ static void sound_config_read(LinphoneCore *lc) {
linphone_core_set_playback_gain_db (lc,linphone_config_get_float(lc->config,"sound","playback_gain_db",0));
linphone_core_set_mic_gain_db (lc,linphone_config_get_float(lc->config,"sound","mic_gain_db",0));
linphone_core_set_disable_record_on_mute(lc, linphone_config_get_bool(lc->config,"sound","disable_record_on_mute", FALSE));
linphone_core_set_remote_ringback_tone (lc,linphone_config_get_string(lc->config,"sound","ringback_tone",NULL));
/*just parse requested stream feature once at start to print out eventual errors*/
......@@ -4691,6 +4691,18 @@ void linphone_core_set_mic_gain_db (LinphoneCore *lc, float gaindb){
bool_t linphone_core_get_disable_record_on_mute(LinphoneCore *lc) {
return lc->sound_conf.disable_record_on_mute;
void linphone_core_set_disable_record_on_mute(LinphoneCore *lc, bool_t disable) {
lc->sound_conf.disable_record_on_mute = disable;
if (linphone_core_ready(lc)){
float linphone_core_get_mic_gain_db(LinphoneCore *lc) {
return lc->sound_conf.soft_mic_lev;
......@@ -6525,13 +6537,14 @@ static void sound_config_uninit(LinphoneCore *lc)
if (config->local_ring) ms_free(config->local_ring);
if (config->remote_ring) ms_free(config->remote_ring);
lc->tones=bctbx_list_free_with_data(lc->tones, (void (*)(void*))linphone_tone_description_destroy);
lc->sound_conf = {0};
static void video_config_uninit(LinphoneCore *lc)
const LinphoneVideoDefinition *vdef = linphone_core_get_preferred_video_definition(lc);
......@@ -312,6 +312,7 @@ struct sound_config
bool_t ec;
bool_t ea;
bool_t agc;
bool_t disable_record_on_mute;
struct codecs_config
......@@ -2428,6 +2428,28 @@ LINPHONE_PUBLIC void linphone_core_set_mic_gain_db(LinphoneCore *core, float lev
LINPHONE_PUBLIC float linphone_core_get_mic_gain_db(LinphoneCore *core);
* Calling this method with disable=true will cause the microhone to be completely deactivated when muted,
* when given possible by the implementation on the platform on which liblinphone is running.
* Otherwise, sound recording remains active but silence is sent instead of recorded audio.
* Playback sound will be briefly interrupted while the audio is reconfigured.
* Currently only implemented for IOS, it will also disable Apple's microphone recording indicator when microphone is muted.
* @param core #LinphoneCore object @notnil
* @param disable True if you wish to entirely stop the audio recording when muting the microphone.
* @ingroup media_parameters
LINPHONE_PUBLIC void linphone_core_set_disable_record_on_mute(LinphoneCore *core, bool_t disable);
* Get whether the microphone will be completely deactivated when muted. Please refer to linphone_core_set_disable_record_on_mute().
* @param core #LinphoneCore object @notnil
* @return True if you wish to entirely stop the audio recording when muting the microphone.
* @ingroup media_parameters
LINPHONE_PUBLIC bool_t linphone_core_get_disable_record_on_mute(LinphoneCore *core);
* Allow to control play level before entering sound card: gain in db
* @param core #LinphoneCore object @notnil
......@@ -47,7 +47,8 @@ LINPHONE_BEGIN_NAMESPACE
MS2AudioStream::MS2AudioStream(StreamsGroup &sg, const OfferAnswerContext &params) : MS2Stream(sg, params){
string bindIp = getBindIp();
mStream = audio_stream_new2(getCCore()->factory, bindIp.empty() ? nullptr : bindIp.c_str(), mPortConfig.rtpPort, mPortConfig.rtcpPort);
mStream->disable_record_on_mute = getCCore()->sound_conf.disable_record_on_mute;
/* Initialize zrtp even if we didn't explicitely set it, just in case peer offers it */
if (linphone_core_media_encryption_supported(getCCore(), LinphoneMediaEncryptionZRTP)) {
LinphoneCallLog *log = getMediaSession().getLog();
......@@ -472,7 +473,7 @@ void MS2AudioStream::stop(){
/* In mediastreamer2, stop actually stops and destroys. We immediately need to recreate the stream object for later use, keeping the
/* In mediastreamer2, stop actually stops and destroys. We immediately need to recreate the stream object for later use, keeping the
* sessions (for RTP, SRTP, ZRTP etc) that were setup at the beginning. */
mStream = audio_stream_new_with_sessions(getCCore()->factory, &mSessions);
......@@ -549,11 +550,8 @@ void MS2AudioStream::parameterizeEqualizer(AudioStream *as, LinphoneCore *lc) {
void MS2AudioStream::postConfigureAudioStream(AudioStream *as, LinphoneCore *lc, bool muted){
float micGain = lc->sound_conf.soft_mic_lev;
if (muted)
audio_stream_set_mic_gain(as, 0);
audio_stream_set_mic_gain_db(as, micGain);
audio_stream_enable_mic(as, !muted);
float recvGain = lc->sound_conf.soft_play_lev;
if (static_cast<int>(recvGain)){
if (as->volrecv)
......@@ -590,6 +588,7 @@ void MS2AudioStream::postConfigureAudioStream(AudioStream *as, LinphoneCore *lc,
if (as->volrecv) {
/* Parameters for a limited noise-gate effect, using echo limiter threshold */
float micGain = lc->sound_conf.soft_mic_lev;
float floorGain = (float)(1 / pow(10, micGain / 10));
int spkAgc = linphone_config_get_int(config, "sound", "speaker_agc_enabled", 0);
MSFilter *f = as->volrecv;
......@@ -643,11 +642,7 @@ void MS2AudioStream::handleEvent(const OrtpEvent *ev){
void MS2AudioStream::enableMic(bool value){
mMicMuted = !value;
if (mMicMuted)
audio_stream_set_mic_gain(mStream, 0);
audio_stream_set_mic_gain_db(mStream, getCCore()->sound_conf.soft_mic_lev);
audio_stream_enable_mic(mStream, value);
bool MS2AudioStream::micEnabled()const{
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