VoIPGRID / VialerSIPLib

An Objective-c wrapper for PJSIP
GNU General Public License v3.0
133 stars 69 forks source link

sometimes outgoing call get null state only, can not get other state #243

Open fukemy opened 3 years ago

fukemy commented 3 years ago

Version

3.7.3

File / Feature

no file

Expected behavior

call state must have connecting state

Actual behavior

get call state null only

Stacktrace / Error message

didFinishLaunchingWithOptions
IPPhoneLog: Creating new PJSIP Endpoint instance.
13:47:56.842         os_core_unix.c !pjlib 2.10 for POSIX initialized
13:47:56.843         sip_endpoint.c  .Creating endpoint instance...
13:47:56.844                  pjlib  .select() I/O Queue created (0x10a05c228)
13:47:56.845         sip_endpoint.c  .Module "mod-msg-print" registered
13:47:56.845        sip_transport.c  .Transport manager created.
13:47:56.845           pjsua_core.c  .PJSUA state changed: NULL --> CREATED
IPPhoneLog:         sip_endpoint.c  .Module "mod-pjsua-log" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-tsx-layer" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-stateful-util" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-ua" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-100rel" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-pjsua" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-invite" registered
IPPhoneLog:        coreaudio_dev.c  .. dev_id 0: iPhone IO device  (in=1, out=1) 8000Hz
IPPhoneLog:        coreaudio_dev.c  ..core audio initialized
IPPhoneLog:                  pjlib  ..select() I/O Queue created (0x10a84d028)
IPPhoneLog:            pjsua_vid.c  ..Initializing video subsystem..
IPPhoneLog:           openh264.cpp  ...OpenH264 codec initialized
IPPhoneLog:           opengl_dev.c  ...OpenGL device initialized
IPPhoneLog:           darwin_dev.m  ...Darwin video initialized with 3 devices:
IPPhoneLog:           darwin_dev.m  ... 0: [Renderer] iOS - UIView
IPPhoneLog:           darwin_dev.m  ... 1: [Capturer] AVF - Camera mặt trước
IPPhoneLog:           darwin_dev.m  ... 2: [Capturer] AVF - Camera mặt sau
IPPhoneLog:         colorbar_dev.c  ...Colorbar video src initialized with 2 device(s):
IPPhoneLog:         colorbar_dev.c  ... 0: Colorbar generator
IPPhoneLog:         colorbar_dev.c  ... 1: Colorbar-active
IPPhoneLog:         sip_endpoint.c  .Module "mod-evsub" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-presence" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-mwi" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-refer" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-pjsua-pres" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-pjsua-im" registered
IPPhoneLog:         sip_endpoint.c  .Module "mod-pjsua-options" registered
IPPhoneLog:           pjsua_core.c  .1 SIP worker threads created
IPPhoneLog:           pjsua_core.c  .pjsua version 2.10 for iOS-14.5.1/arm-iPhone8,2/iOS-SDK initialized
IPPhoneLog:           pjsua_core.c  .PJSUA state changed: CREATED --> INIT
IPPhoneLog:           pjsua_core.c  SIP UDP socket reachable at 192.168.1.15:49711
IPPhoneLog:         udp0x10992ad10  SIP UDP transport started, published address is 192.168.1.15:49711
IPPhoneLog:           pjsua_core.c  PJSUA state changed: INIT --> STARTING
IPPhoneLog:         sip_endpoint.c  .Module "mod-unsolicited-mwi" registered
IPPhoneLog:           pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING
IPPhoneLog: PJSIP Endpoint started succesfully
IPPhoneLog:            pjsua_acc.c  Adding account: id=sip:22849@kam-01.api-connect.io
IPPhoneLog:            pjsua_acc.c  .Account sip:22849@kam-01.api-connect.io added with id 0
IPPhoneLog: Account added succesfully
account: Optional(<VSLAccount: 0x2807e55c0>
     ID: 0
     State: VSLAccountStateOffline(0)
     Registered: NO
     Registration Status: 100
     Registration Expires: -1
     Account valid YES
)
splash screen viewdidload
appdelegate kbHeight: 226.0
renewToken
Token updated
SignalRService connectionDidOpen Optional("4B0cl-vezMJ3--LaUctCKw") - true
refresh action
Start call to : 
IPPhoneLog: Account valid: YES
IPPhoneLog: Should force registration: NO
IPPhoneLog: Sending registration for account: 0
IPPhoneLog:            pjsua_acc.c  Acc 0: setting registration..
IPPhoneLog:           pjsua_core.c  ..TX 532 bytes Request msg REGISTER/cseq=38051 (tdta0x10a9db0a8) to UDP 203.205.21.26:5060:
REGISTER sip:kam-01.api-connect.io SIP/2.0

Via: SIP/2.0/UDP 192.168.1.15:49711;rport;branch=z9hG4bKPjVUwWx3gG17OUHLTNgW-w1.GMylvIAALc

Max-Forwards: 70

From: <sip:22849@kam-01.api-connect.io>;tag=DfS3iE821ne1UD4k.SC1WunZdmREytuu

To: <sip:22849@kam-01.api-connect.io>

Call-ID: QBsCg7D9wIpycfzSZYuAqD998a02vu3c

CSeq: 38051 REGISTER

User-Agent: Link

Contact: <sip:22849@192.168.1.15:49711;ob>

Expires: 800

Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS

Content-Length:  0

--end msg--
IPPhoneLog: PJSUA callback: registration or unregistration has been initiated.
IPPhoneLog:            pjsua_acc.c  .Acc 0: Registration sent
IPPhoneLog:           pjsua_core.c  .RX 555 bytes Response msg 401/REGISTER/cseq=38051 (rdata0x10a86f028) from UDP 203.205.21.26:5060:
SIP/2.0 401 Unauthorized

Via: SIP/2.0/UDP 192.168.1.15:49711;rport;branch=z9hG4bKPjVUwWx3gG17OUHLTNgW-w1.GMylvIAALc

Record-Route: <sip:siproxd@192.168.1.1:9876;lr>

From: <sip:22849@kam-01.api-connect.io>;tag=DfS3iE821ne1UD4k.SC1WunZdmREytuu

To: <sip:22849@kam-01.api-connect.io>;tag=a3200358be752e787870b3ffce419c21.2c1fcbab

Call-ID: QBsCg7D9wIpycfzSZYuAqD998a02vu3c

CSeq: 38051 REGISTER

WWW-Authenticate: Digest realm="kam-01.api-connect.io", nonce="YNbO6mDWzb5cPUJmBpmfYya7ES1IlJqK"

server: kamailio (5.3.0 (x86_64/linux))

Content-Length: 0

--end msg--
IPPhoneLog:           pjsua_core.c  ....TX 723 bytes Request msg REGISTER/cseq=38052 (tdta0x10a9db0a8) to UDP 203.205.21.26:5060:
REGISTER sip:kam-01.api-connect.io SIP/2.0

Via: SIP/2.0/UDP 192.168.1.15:49711;rport;branch=z9hG4bKPjmDrhF5zPBSC-NPOIeaYrSnwbliel7Ses

Max-Forwards: 70

From: <sip:22849@kam-01.api-connect.io>;tag=DfS3iE821ne1UD4k.SC1WunZdmREytuu

To: <sip:22849@kam-01.api-connect.io>

Call-ID: QBsCg7D9wIpycfzSZYuAqD998a02vu3c

CSeq: 38052 REGISTER

User-Agent: Link

Contact: <sip:22849@192.168.1.15:49711;ob>

Expires: 800

Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS

Authorization: Digest username="22849", realm="kam-01.api-connect.io", nonce="YNbO6mDWzb5cPUJmBpmfYya7ES1IlJqK", uri="sip:kam-01.api-connect.io", response="aaca0caffe4b7b02f77224c4a3d23ce1"

Content-Length:  0

--end msg--
IPPhoneLog:           pjsua_core.c  .RX 503 bytes Response msg 200/REGISTER/cseq=38052 (rdata0x10a86f028) from UDP 203.205.21.26:5060:
SIP/2.0 200 OK

Via: SIP/2.0/UDP 192.168.1.15:49711;rport;branch=z9hG4bKPjmDrhF5zPBSC-NPOIeaYrSnwbliel7Ses

Record-Route: <sip:siproxd@192.168.1.1:9876;lr>

From: <sip:22849@kam-01.api-connect.io>;tag=DfS3iE821ne1UD4k.SC1WunZdmREytuu

To: <sip:22849@kam-01.api-connect.io>;tag=a3200358be752e787870b3ffce419c21.2c1fcbab

Call-ID: QBsCg7D9wIpycfzSZYuAqD998a02vu3c

CSeq: 38052 REGISTER

Contact: <sip:22849@192.168.1.15:49711;ob>;expires=800

server: kamailio (5.3.0 (x86_64/linux))

Content-Length: 0

--end msg--
IPPhoneLog:            pjsua_acc.c  ....SIP outbound status for acc 0 is not active
IPPhoneLog:            pjsua_acc.c  ....sip:22849@kam-01.api-connect.io: registration success, status=200 (OK), will re-register in 800 seconds
IPPhoneLog:            pjsua_acc.c  ....Keep-alive timer started for acc 0, destination:203.205.21.26:5060, interval:15s
IPPhoneLog: PJSUA callback: registration status has changed.
IPPhoneLog: AccountState will change from VSLAccountStateOffline(0) to VSLAccountStateConnected(2)
IPPhoneLog: Account registered succesfully
IPPhoneLog: Call(93345335-FA10-425A-B927-8D16DD98BC3A) added. Calls count:1
IPPhoneLog: "Start Call Transaction" requested succesfully for Call(93345335-FA10-425A-B927-8D16DD98BC3A) with account(0)
startCall: Optional(<VSLCall: 0x282d9a1c0>
     UUID: 93345335-FA10-425A-B927-8D16DD98BC3A
     Call ID: 0
     CallState: VSLCallStateNull
     VSLMediaState: VSLMediaStateNone
     VSLCallTransferState: VSLCallTransferStateUnkown
     Account: 0
     Last Status: (null)(0)
     Number to Call: 0393318881
     Local URI: (null)
     Remote URI: (null)
     Caller Name: (null)
     Caller Number: (null)
     Is Incoming: NO
     Is muted: NO
     On Speaker: NO
     On Hold: NO
     User Did Hangup: NO
) - nil
new call state null
audioSessionDidActivate
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null
new call state null

this problem sometimes appear, not always

fukemy commented 3 years ago

hi, can u help me explain this problem, i can not found anything with above logs

fukemy commented 3 years ago

i found the delegate for CXProvider is not called

performStartCallAction -> not call

im tried to debug then found that im using 2 CXProvider. May be it conflict

APPDELEGATE
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        print("didFinishLaunchingWithOptions")
        pushRegistry.delegate = self
        pushRegistry.desiredPushTypes = [.voIP]

        firebaseConfig(application)

        commonConfig()

        //SIP regiter

        DDLogWrapper.setup()
        setupSIPCallKit()
        setupLogCallBack()
        setupVoIPEndpoint()
        setupAccount()
//        setupIncomingCallBlock()

//        #if DEBUG
//        #else
//            CrashEye.add(delegate: self)
//        #endif

        callObserver = CXCallObserver()
        callObserver.setDelegate(self, queue: nil)

        Siren.shared.wail()
        Keyboard.setup() {
            let kbHeight = Keyboard.height() // != 0 :)
            print("appdelegate kbHeight: \(kbHeight)")
        }

        if let _ = CallManager.sharedInstance.currentCall{
            //app is open when have calling, so do not loop through splash screen to avoid re-set rootViewController
            initiateFirstScreen("HomeVC", storyboardName : "main")
        }else{
            initiateFirstScreen("SplashScreen", storyboardName : "sheet")
        }
        return true
    }
class CallManager: NSObject, CXProviderDelegate {

    var provider : CXProvider?
    var callController : CXCallController?
    var currentCall : CallInfoModel?
    var callBackgroundHandlerIdentifier : UIBackgroundTaskIdentifier?
    weak var delegate : CallManagerDelegate?

    override init() {
        super.init()
        providerAndControllerSetup()
    }

    static let sharedInstance = CallManager()

Can u give me some advice? Thanks so much