How to implement mute function in PJSIP call on iOS

I wanted to enter the Mute button in my call. I am working on a VOIP application for the iPhone. Now that the call comes in and the user picks up, I want to display the Mute button so that the user can disconnect the call or conference. I did the same through the 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);
}

The problem is that although this code works for a single call, it does not work for conference scripts.

I wonder if I can mute the microphone directly: can I implement the same with iOS, bypassing the PJSIP API?

Is it possible?

+5
source share
1 answer

, pjsua_conf_disconnect pjsua_conf_connect, .

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);
    }
}

, pjsipConfAudioID , , Objective-C...

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;
    ...
}

, !

+7

All Articles