add nortp mute feature

This commit is contained in:
Simon Morlat 2010-06-03 12:07:17 +02:00
parent 450dfc2ab9
commit df7af48647
5 changed files with 96 additions and 4 deletions

View file

@ -78,6 +78,9 @@ static int lpc_cmd_ports(LinphoneCore *lc, char *args);
static int lpc_cmd_speak(LinphoneCore *lc, char *args);
static int lpc_cmd_codec(LinphoneCore *lc, char *args);
static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args);
static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args);
static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args);
static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args);
/* Command handler helpers */
static void linphonec_proxy_add(LinphoneCore *lc);
@ -223,6 +226,14 @@ LPC_COMMAND commands[] = {
"'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n"
"'ec off' : turn echo cancellation (EC) off\n"
"'ec show' : show EC status" },
{ "mute", lpc_cmd_mute_mic,
"Mute microphone and suspend voice transmission."},
{ "unmute", lpc_cmd_unmute_mic,
"Unmute microphone and resume voice transmission."},
{ "nortp-on-audio-mute", lpc_cmd_rtp_no_xmit_on_audio_mute,
"Set the rtp_no_xmit_on_audio_mute configuration parameter",
" If set to 1 then rtp transmission will be muted when\n"
" audio is muted , otherwise rtp is always sent."},
{ (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
};
@ -1606,9 +1617,11 @@ static int lpc_cmd_status(LinphoneCore *lc, char *args)
linphonec_out("hook=offhook\n");
break;
case GSTATE_CALL_OUT_CONNECTED:
linphonec_out("Call out, hook=%s duration=%i\n", linphonec_get_callee(),
linphone_core_get_current_call_duration(lc));
break;
linphonec_out("Call out, hook=%s duration=%i, muted=%s rtp-xmit-muted=%s\n", linphonec_get_callee(),
linphone_core_get_current_call_duration(lc),
lc->audio_muted ? "yes" : "no",
linphone_core_is_rtp_muted(lc) ? "yes" : "no");
break;
case GSTATE_CALL_IN_CONNECTED:
linphonec_out("hook=answered duration=%i\n" ,
linphone_core_get_current_call_duration(lc));
@ -1820,6 +1833,41 @@ static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
return 1;
}
static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args)
{
if ( lc->call != NULL )
linphone_core_mute_mic(lc, 1);
return 1;
}
static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args)
{
if ( lc->call != NULL )
linphone_core_mute_mic(lc, 0);
return 1;
}
static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args)
{
bool_t rtp_xmit_off=FALSE;
char *status;
gstate_t call_state=linphone_core_get_state(lc,GSTATE_GROUP_CALL);
if(args){
if(strstr(args,"1"))rtp_xmit_off=TRUE;
if(call_state == GSTATE_CALL_IDLE)
linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_xmit_off);
else
linphonec_out("nortp-on-audio-mute: call in progress - cannot change state\n");
}
rtp_xmit_off=linphone_core_get_rtp_no_xmit_on_audio_mute(lc);
if(rtp_xmit_off)status="off";
else status="on";
linphonec_out("rtp transmit %s when audio muted\n",status);
return 1;
}
/***************************************************************************
*
* Command table management funx

View file

@ -730,6 +730,8 @@ static void rtp_config_read(LinphoneCore *lc)
int port;
int jitt_comp;
int nortp_timeout;
bool_t rtp_no_xmit_on_audio_mute;
port=lp_config_get_int(lc->config,"rtp","audio_rtp_port",7078);
linphone_core_set_audio_port(lc,port);
@ -742,6 +744,8 @@ static void rtp_config_read(LinphoneCore *lc)
jitt_comp=lp_config_get_int(lc->config,"rtp","video_jitt_comp",60);
nortp_timeout=lp_config_get_int(lc->config,"rtp","nortp_timeout",30);
linphone_core_set_nortp_timeout(lc,nortp_timeout);
rtp_no_xmit_on_audio_mute=lp_config_get_int(lc->config,"rtp","rtp_no_xmit_on_audio_mute",FALSE);
linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_no_xmit_on_audio_mute);
}
static PayloadType * find_payload(RtpProfile *prof, const char *mime_type, int clock_rate, const char *recv_fmtp){
@ -1362,6 +1366,10 @@ int linphone_core_get_nortp_timeout(const LinphoneCore *lc){
return lc->rtp_conf.nortp_timeout;
}
bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc){
return lc->rtp_conf.rtp_no_xmit_on_audio_mute;
}
/**
* Sets the nominal audio jitter buffer size in milliseconds.
*
@ -1372,6 +1380,10 @@ void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value)
lc->rtp_conf.audio_jitt_comp=value;
}
void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc,bool_t rtp_no_xmit_on_audio_mute){
lc->rtp_conf.rtp_no_xmit_on_audio_mute=rtp_no_xmit_on_audio_mute;
}
/**
* Sets the UDP port used for audio streaming.
*
@ -2154,6 +2166,7 @@ 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);
lc->audio_muted=FALSE;
float recv_gain = lc->sound_conf.soft_play_lev;
if (recv_gain != 0) {
linphone_core_set_soft_play_level(lc,recv_gain);
@ -2907,6 +2920,10 @@ void linphone_core_mute_mic(LinphoneCore *lc, bool_t val){
if (lc->audiostream!=NULL){
audio_stream_set_mic_gain(lc->audiostream,
(val==TRUE) ? 0 : 1.0);
if ( linphone_core_get_rtp_no_xmit_on_audio_mute(lc) ){
audio_stream_mute_rtp(lc->audiostream,val);
}
lc->audio_muted=val;
}
}
@ -2919,6 +2936,24 @@ bool_t linphone_core_is_mic_muted(LinphoneCore *lc) {
return gain==0;
}
// returns audio mute status for active stream
bool_t linphone_core_is_audio_muted(LinphoneCore *lc){
if( lc->audiostream != NULL )
return (lc->audio_muted);
return FALSE;
}
// returns rtp transmission status for an active stream
// if audio is muted and config parameter rtp_no_xmit_on_audio_mute
// was set on then rtp transmission is also muted
bool_t linphone_core_is_rtp_muted(LinphoneCore *lc){
if( (lc->audiostream != NULL) &&
linphone_core_get_rtp_no_xmit_on_audio_mute(lc)){
return lc->audio_muted;
}
return FALSE;
}
void linphone_core_enable_agc(LinphoneCore *lc, bool_t val){
lc->sound_conf.agc=val;
}

View file

@ -688,6 +688,12 @@ void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted);
**/
bool_t linphone_core_is_mic_muted(LinphoneCore *lc);
bool_t linphone_core_is_audio_muted(LinphoneCore *lc);
bool_t linphone_core_is_rtp_muted(LinphoneCore *lc);
bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc);
void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, bool_t val);
void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *contact,LinphoneOnlineStatus os);
LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc);

View file

@ -273,6 +273,8 @@ typedef struct rtp_config
int audio_jitt_comp; /*jitter compensation*/
int video_jitt_comp; /*jitter compensation*/
int nortp_timeout;
bool_t rtp_no_xmit_on_audio_mute;
/* stop rtp xmit when audio muted */
}rtp_config_t;
@ -401,6 +403,7 @@ struct _LinphoneCore
bool_t preview_finished;
bool_t auto_net_state_mon;
bool_t network_reachable;
bool_t audio_muted;
};
#endif /* _PRIVATE_H */

@ -1 +1 @@
Subproject commit ba988a9a44f837481ec3c6dec8a1acad56f0fa32
Subproject commit 2c65063096918cce1dfcc6f01c0cbf43c3232dc0