简体   繁体   中英

How to get current call state using Linphone

I am working on calling app by using Linphone. I want to get current call state from below code. I tried a lot but did not find any solution. Please tell me how to get current call state from global callstatechanged closure?

let callStateChanged: LinphoneCoreCallStateChangedCb = {
    (lc: Optional<OpaquePointer>, call: Optional<OpaquePointer>, callSate: LinphoneCallState,  message: Optional<UnsafePointer<Int8>>) in

    switch callSate{
    case LinphoneCallIncomingReceived: /**<This is a new incoming call */
        NSLog("callStateChanged: LinphoneCallIncomingReceived")

        if answerCall{
            ms_usleep(3 * 1000 * 1000); // Wait 3 seconds to pickup
            linphone_core_accept_call(lc, call)
        }

    case LinphoneCallStreamsRunning: /**<The media streams are established and running*/
        NSLog("callStateChanged: LinphoneCallStreamsRunning")

    case LinphoneCallError: /**<The call encountered an error*/
        NSLog("callStateChanged: LinphoneCallError")

    default:
        NSLog("Default call state")
    }
}

How to access current call state from this code?

This might help you to get current call

func answerCall () {
    if let call = linphone_core_get_current_call(theLinphone.lc) {
        linphone_core_accept_call(theLinphone.lc, call)
       // HERE HOW YOU GET CALL STATE
        let call_state =  linphone_call_get_state(call) 
        // call State may  return
        /* 
typedef enum _LinphoneCallState{
    LinphoneCallIdle,                   /**<Initial call state */
    LinphoneCallIncomingReceived, /**<This is a new incoming call */
    LinphoneCallOutgoingInit, /**<An outgoing call is started */
    LinphoneCallOutgoingProgress, /**<An outgoing call is in progress */
    LinphoneCallOutgoingRinging, /**<An outgoing call is ringing at remote end */
    LinphoneCallOutgoingEarlyMedia, /**<An outgoing call is proposed early media */
    LinphoneCallConnected, /**<Connected, the call is answered */
    LinphoneCallStreamsRunning, /**<The media streams are established and running*/
    LinphoneCallPausing, /**<The call is pausing at the initiative of local end */
    LinphoneCallPaused, /**< The call is paused, remote end has accepted the pause */
    LinphoneCallResuming, /**<The call is being resumed by local end*/
    LinphoneCallRefered, /**<The call is being transfered to another party, resulting in a new outgoing call to follow immediately*/
    LinphoneCallError, /**<The call encountered an error*/
    LinphoneCallEnd, /**<The call ended normally*/
    LinphoneCallPausedByRemote, /**<The call is paused by remote end*/
    LinphoneCallUpdatedByRemote, /**<The call's parameters change is requested by remote end, used for example when video is added by remote */
    LinphoneCallIncomingEarlyMedia, /**<We are proposing early media to an incoming call */
    LinphoneCallUpdating, /**<A call update has been initiated by us */
    LinphoneCallReleased, /**< The call object is no more retained by the core */
    LinphoneCallEarlyUpdatedByRemote, /*<The call is updated by remote while not yet answered (early dialog SIP UPDATE received).*/
    LinphoneCallEarlyUpdating /*<We are updating the call while not yet answered (early dialog SIP UPDATE sent)*/
} LinphoneCallState;
         */

    }

}

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