简体   繁体   中英

How to mute PJSUA call in android

I am developing VOIP app in android using PJSUA, here I want to mute call

I am reading doc related to PJSUA and I find method that is used for such purpose but could not implement in android APP, please anyone who can help me to set call in mute mode

Here I provide the detail from PJSUA docs,

     pj_status_t pjsua_conf_adjust_rx_level (pjsua_conf_port_id slot,
    float level )   

Adjust the signal level to be received from the specified port (to the bridge) by making it louder or quieter.

Parameters

  • slot: The conference bridge slot number.
  • level: Signal level adjustment. Value 1.0 means no level adjustment, while value 0 means to mute the port.

Returns

  • PJ_SUCCESS on success, or the appropriate error code.

I want solution like that to hold call in android using PJSUA

public void holdCall() {
    CallOpParam prm = new CallOpParam(true);
    try {
        currentCall.setHold(prm);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Thanks

hopefully, you are doing well. as I am also new in PJSUA in android. I read much more documentation for making call mute. but I found one possible , best solution for it which is working perfectly in my environment, these are given below

 public void setMute(boolean mute) {
    // return immediately if we are not changing the current state
    CallInfo info;
    try {
        info = getCurrentCall().getInfo();
    } catch (Exception exc) {
        return;
    }

    for (int i = 0; i < info.getMedia().size(); i++) {
        Media media = getCurrentCall().getMedia(i);
        CallMediaInfo mediaInfo = info.getMedia().get(i);

        if (mediaInfo.getType() == pjmedia_type.PJMEDIA_TYPE_AUDIO
                && media != null
                && mediaInfo.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE) {
            AudioMedia audioMedia = AudioMedia.typecastFromMedia(media);

            // connect or disconnect the captured audio
            try {
                AudDevManager mgr = MyApp.ep.audDevManager();

                if (mute) {
                    mgr.getCaptureDevMedia().stopTransmit(audioMedia);
                } else {
                    mgr.getCaptureDevMedia().startTransmit(audioMedia);
                }

            } catch (Exception exc) {
            }
        }
    }
}

and for pjsip support one of us good man did brilliant job here . so you can see code.

enjoy your code time:)

I'm also developing a pjsua app. I'm setting mute on OS layer and it's working well.

AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
audioManager.setMicrophoneMute(true);

Btw, turning speaker on - same way:

audioManager.setSpeakerphoneOn(true);

Even I recommend to turn speaker off and unset mute before every call because some other dialer apps do not turn them off after call end.

I have find solution for mute and unmute call using PJSUA to learn about about pjsua function please visit that link enter link description here

  CallInfo info;
    try {
        info = currentCall.getInfo();
    } catch (Exception e) {
        Log.e("Exception caught while getting call info.", e.toString());
        return;
    }

    for (int i = 0; i < info.getMedia().size(); i++) {
        Media media = currentCall.getMedia(i);
        CallMediaInfo mediaInfo = info.getMedia().get(i);
        if (mediaInfo.getType() == pjmedia_type.PJMEDIA_TYPE_AUDIO && media != null
                && mediaInfo.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE) {
            AudioMedia audioMedia = AudioMedia.typecastFromMedia(media);
            try {
                AudDevManager mgr = MyApp.ep.audDevManager();
                if (isMute) {
                    mgr.getCaptureDevMedia().stopTransmit(audioMedia);
                } else {
                    mgr.getCaptureDevMedia().startTransmit(audioMedia);
                }
            } catch (Exception e) {
                Log.e("Exception caught while connecting audio media to sound device.", e.toString());
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM