我想在通话中实现静音按钮。我正在为iPhone开发VOIP应用程序。现在,当有电话打进并且用户接听时,我想显示一个“静音”按钮,以便用户可以使通话或 session 静音。我通过PJSIP API做了同样的事情。
-(int) mutethecall
{
pj_status_t status = pjsua_conf_adjust_rx_level (0,0);
status = pjsua_conf_adjust_tx_level (0,0);
return (PJ_SUCCESS == status);
}
-(int) unmutethecall
{
pj_status_t status = pjsua_conf_adjust_rx_level (0,1);
status = pjsua_conf_adjust_tx_level (0,1);
return (PJ_SUCCESS == status);
}
问题在于,尽管此代码可用于一对一调用,但不适用于 session 场景。
我想知道是否可以直接关闭麦克风:我可以绕过PJSIP API使用iOS来实现相同的功能吗?
这可能吗?
最佳答案
要取消静音时,可以使用pjsua_conf_disconnect和pjsua_conf_connect完全断开麦克风与 session 的连接。
这是一些达到目的的Objective-C代码:
+(void)muteMicrophone
{
@try {
if( pjsipConfAudioId != 0 ) {
NSLog(@"WC_SIPServer microphone disconnected from call");
pjsua_conf_disconnect(0, pjsipConfAudioId);
}
}
@catch (NSException *exception) {
NSLog(@"Unable to mute microphone: %@", exception);
}
}
+(void)unmuteMicrophone
{
@try {
if( pjsipConfAudioId != 0 ) {
NSLog(@"WC_SIPServer microphone reconnected to call");
pjsua_conf_connect(0,pjsipConfAudioId);
}
}
@catch (NSException *exception) {
NSLog(@"Unable to un-mute microphone: %@", exception);
}
}
请注意,再次在Objective-C中建立调用时便检索到pjsipConfAudioID。
static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
{
pjsua_call_info ci;
PJ_UNUSED_ARG(e);
pjsua_call_get_info(call_id, &ci);
pjsipConfAudioId = ci.conf_slot;
...
}
希望对您有所帮助!
关于iphone - 如何在i上的PJSIP调用中实现静音功能,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11151508/