From 00eaddcf28dc0ef5cc9de49f1e9af389e896b4bf Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 12 Mar 2010 17:27:10 +0100 Subject: [PATCH] add linphone_core_set/get_soft_play_lev --- coreapi/callbacks.c | 2 +- coreapi/linphonecore.c | 29 +++++++++++++++++++++++++++++ coreapi/linphonecore.h | 12 ++++++++++++ coreapi/linphonecore_jni.cc | 12 ++++++++++++ coreapi/private.h | 1 + 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index edce2c4e3..30b5f0d55 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -125,7 +125,7 @@ static void call_ringing(SalOp *h){ } }else{ /*accept early media */ - if (lc->audiostream->ticker!=NULL){ + if (lc->audiostream && lc->audiostream->ticker!=NULL){ /*streams already started */ ms_message("Early media already started."); return; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 0c5ad1772..14faa1195 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -490,6 +490,7 @@ static void sound_config_read(LinphoneCore *lc) /*int tmp;*/ const char *tmpbuf; const char *devid; + float gain=0; #ifdef __linux /*alsadev let the user use custom alsa device within linphone*/ devid=lp_config_get_string(lc->config,"sound","alsadev",NULL); @@ -555,6 +556,9 @@ static void sound_config_read(LinphoneCore *lc) lp_config_get_int(lc->config,"sound","echolimiter",0)); linphone_core_enable_agc(lc, lp_config_get_int(lc->config,"sound","agc",0)); + + gain=lp_config_get_float(lc->config,"sound","soft_play_lev",0); + linphone_core_set_soft_play_level(lc,gain); } static void sip_config_read(LinphoneCore *lc) @@ -1962,6 +1966,10 @@ static void post_configure_audio_streams(LinphoneCore *lc){ float gain=lp_config_get_float(lc->config,"sound","mic_gain",-1); if (gain!=-1) audio_stream_set_mic_gain(st,gain); + float recv_gain = lc->sound_conf.soft_play_lev; + if (recv_gain != 0) { + linphone_core_set_soft_play_level(lc,recv_gain); + } if (linphone_core_echo_limiter_enabled(lc)){ float speed=lp_config_get_float(lc->config,"sound","el_speed",-1); float thres=lp_config_get_float(lc->config,"sound","el_thres",-1); @@ -2351,6 +2359,27 @@ void linphone_core_set_ring_level(LinphoneCore *lc, int level){ if (sndcard) ms_snd_card_set_level(sndcard,MS_SND_CARD_PLAYBACK,level); } + +void linphone_core_set_soft_play_level(LinphoneCore *lc, float level){ + float gain=level; + lc->sound_conf.soft_play_lev=level; + AudioStream *st=lc->audiostream; + if (!st) return; /*just return*/ + + if (st->volrecv){ + ms_filter_call_method(st->volrecv,MS_VOLUME_SET_DB_GAIN,&gain); + }else ms_warning("Could not apply gain: gain control wasn't activated."); +} +float linphone_core_get_soft_play_level(LinphoneCore *lc) { + float gain=0; + AudioStream *st=lc->audiostream; + if (st->volrecv){ + ms_filter_call_method(st->volrecv,MS_VOLUME_GET,&gain); + }else ms_warning("Could not get gain: gain control wasn't activated."); + + return gain; +} + /** * Set sound playback level in 0-100 scale * diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 6e4e658e6..bdd735f26 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -607,6 +607,18 @@ int linphone_core_get_play_level(LinphoneCore *lc); int linphone_core_get_rec_level(LinphoneCore *lc); void linphone_core_set_ring_level(LinphoneCore *lc, int level); void linphone_core_set_play_level(LinphoneCore *lc, int level); +/** + * Allow to control play level before entering sound card: level in db + * + * @ingroup media_parameters +**/ +void linphone_core_set_soft_play_level(LinphoneCore *lc, float level); +/** + * get play level before entering sound card: level in db + * + * @ingroup media_parameters +**/ +float linphone_core_get_soft_play_level(LinphoneCore *lc); void linphone_core_set_rec_level(LinphoneCore *lc, int level); const char * linphone_core_get_ringer_device(LinphoneCore *lc); const char * linphone_core_get_playback_device(LinphoneCore *lc); diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 1c14757ca..a133e2116 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -268,6 +268,18 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSoftPlayLevel( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jfloat gain) { + linphone_core_set_soft_play_level((LinphoneCore*)lc,gain); +} + +extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getSoftPlayLevel( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return linphone_core_get_soft_play_level((LinphoneCore*)lc); +} //ProxyConfig diff --git a/coreapi/private.h b/coreapi/private.h index 6050449d5..f92aa4faa 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -289,6 +289,7 @@ typedef struct sound_config char rec_lev; char play_lev; char ring_lev; + char soft_play_lev; char source; char *local_ring; char *remote_ring;