Changeset 415:8d28c251c714 in mediastreamer2


Ignore:
Timestamp:
Apr 15, 2009 8:41:24 AM (4 years ago)
Author:
smorlat <smorlat@…>
Branch:
default
Message:

add a new gain control setting

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@418 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

Location:
linphone
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • linphone/coreapi/linphonecore.c

    r371 r415  
    14181418        lc->audiostream=audio_stream_new(linphone_core_get_audio_port(lc),linphone_core_ipv6_enabled(lc)); 
    14191419        if (linphone_core_echo_limiter_enabled(lc)){ 
    1420                 const char * type=lp_config_get_string(lc->config,"sound","el_type","mic"); 
     1420                const char *type=lp_config_get_string(lc->config,"sound","el_type","mic"); 
     1421                float gain=lp_config_get_float(lc->config,"sound","mic_gain",-1); 
    14211422                if (strcasecmp(type,"mic")==0) 
    14221423                        audio_stream_enable_echo_limiter(lc->audiostream,ELControlMic); 
    14231424                else if (strcasecmp(type,"speaker")==0) 
    14241425                        audio_stream_enable_echo_limiter(lc->audiostream,ELControlSpeaker); 
     1426                if (gain>0){ 
     1427                        audio_stream_enable_gain_control(lc->audiostream,TRUE); 
     1428                } 
     1429                 
    14251430        } 
    14261431#ifdef VIDEO_ENABLED 
     
    14441449                float thres=lp_config_get_float(lc->config,"sound","el_thres",-1); 
    14451450                float force=lp_config_get_float(lc->config,"sound","el_force",-1); 
     1451                float gain=lp_config_get_float(lc->config,"sound","mic_gain",-1); 
    14461452                MSFilter *f=NULL; 
    14471453                if (st->el_type==ELControlMic){ 
     
    14641470                if (force!=-1) 
    14651471                        ms_filter_call_method(f,MS_VOLUME_SET_EA_FORCE,&force); 
     1472                if (gain!=-1) 
     1473                        ms_filter_call_method(st->volsend,MS_VOLUME_SET_GAIN,&gain); 
    14661474        } 
    14671475        if (lc->vtable.dtmf_received!=NULL){ 
  • linphone/mediastreamer2/include/mediastreamer2/mediastream.h

    r378 r415  
    5353        EchoLimiterType el_type; /*use echo limiter: two MSVolume, measured input level controlling local output level*/ 
    5454        bool_t play_dtmfs; 
     55        bool_t use_gc; 
    5556}; 
    5657 
     
    102103void audio_stream_enable_echo_limiter(AudioStream *stream, EchoLimiterType type); 
    103104 
    104 /* stop the above process*/ 
     105/*enable gain control, to be done before start() */ 
     106void audio_stream_enable_gain_control(AudioStream *stream, bool_t val); 
     107 
     108void audio_stream_set_mic_gain(AudioStream *stream, float gain); 
     109 
     110/* stop the audio streaming thread and free everything*/ 
    105111void audio_stream_stop (AudioStream * stream); 
    106112 
  • linphone/mediastreamer2/src/audiostream.c

    r357 r415  
    248248        } 
    249249 
    250         if (stream->el_type!=ELInactive){ 
     250        if (stream->el_type!=ELInactive || stream->use_gc){ 
    251251                stream->volsend=ms_filter_new(MS_VOLUME_ID); 
    252252                stream->volrecv=ms_filter_new(MS_VOLUME_ID); 
    253                 if (stream->el_type==ELControlSpeaker) 
    254                         ms_filter_call_method(stream->volrecv,MS_VOLUME_SET_PEER,stream->volsend); 
    255                 else ms_filter_call_method(stream->volsend,MS_VOLUME_SET_PEER,stream->volrecv); 
     253                if (stream->el_type!=ELInactive){ 
     254                        if (stream->el_type==ELControlSpeaker) 
     255                                ms_filter_call_method(stream->volrecv,MS_VOLUME_SET_PEER,stream->volsend); 
     256                        else ms_filter_call_method(stream->volsend,MS_VOLUME_SET_PEER,stream->volrecv); 
     257                } 
    256258        } 
    257259 
     
    380382        stream->rtpsend=ms_filter_new(MS_RTP_SEND_ID); 
    381383        stream->play_dtmfs=TRUE; 
     384        stream->use_gc=FALSE; 
    382385        return stream; 
    383386} 
     
    398401void audio_stream_enable_echo_limiter(AudioStream *stream, EchoLimiterType type){ 
    399402        stream->el_type=type; 
     403} 
     404 
     405void audio_stream_enable_gain_control(AudioStream *stream, bool_t val){ 
     406        stream->use_gc=val; 
     407} 
     408 
     409void audio_stream_set_mic_gain(AudioStream *stream, float gain){ 
     410        if (stream->volsend){ 
     411                ms_filter_call_method(stream->volsend,MS_VOLUME_SET_GAIN,&gain); 
     412        }else ms_warning("Could not apply gain: gain control wasn't activated. " 
     413                        "Use audio_stream_enable_gain_control() before starting the stream."); 
    400414} 
    401415 
Note: See TracChangeset for help on using the changeset viewer.