nudesip:注册时无法访问服务器

时间:2020-08-18 11:15:09

标签: objective-c swift baresip baresip-ios

我正在尝试为iOS中的baresip调用学习VoIP,我使用了taresip,它的工作正常,现在我继续学习baresip。下面是注册代码。

required init?(username: String, password: String, agent: inout OpaquePointer?) throws {
        guard libre_init() == 0 else { throw SipError.libre }
        
        // Initialize dynamic modules.
        mod_init()
        
        // Make configure file.
        if let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first {
            conf_path_set(path)
        }
        guard conf_configure() == 0 else { throw SipError.config }
        
        guard baresip_init(conf_config()) == 0 else { print("baresip init error"); return }

        // Initialize the SIP stack.
        guard ua_init("SIP", 1, 1, 1) == 0 else { throw SipError.stack }
        
        // Load modules.
        guard conf_modules() == 0 else { throw SipError.modules }
        
         //let addr = "sip:\(username)@6x.1x3.x3.xx4;auth_pass=\(password);transport=upd;answermode=manual;audio_codecs=PCMU/8000/1;audio_codecs=PCMA/8000/1"
        
        let addr = "sip:\(username):\(password)@6x.1x3.x3.xx4;transport=udp;answermode=manual"
        
        // Start user agent.
        guard ua_alloc(&agent, addr) == 0 else { throw SipError.userAgent }
        
        uag_event_register({ (userAgent, event, call, prm, arg) in
            print(event)
            if event.rawValue == 6 {
                DispatchQueue.main.async {
                    if let handler = SipClient.incommingCallHandler {
                        handler(call)
                    }
                }
            }
            if event.rawValue == 10 {
                print("Call Closed")
                DispatchQueue.main.async {
                    if let handler = SipClient.callEnded {
                        //re_cancel()
                        handler()
                    }
                }
            }
        }, nil)
        
        let registered = ua_isregistered(agent)
        if registered == 0 {
            print("USER \(username)@xxx.xx.xx REGISTERED!!!!!")
        } else {
            print("USER REGISTERATION FAILED!!!")
        }
        
        DispatchQueue.global(qos: .userInitiated).async {
            re_main(nil)
        }
    }
    
    

    2020-08-18 16:18:39.114364+0530 baredemo[3781:1593382] [si_destination_compare] send failed: Invalid argument
2020-08-18 16:18:39.114479+0530 baredemo[3781:1593382] [si_destination_compare] send failed: Undefined error: 0
2020-08-18 16:18:39.114528+0530 baredemo[3781:1593382] [si_destination_compare] send failed: Invalid argument
Local network address:  IPv4=pdp_ip1|10.67.50.101  IPv6=pdp_ip1|2405:205:ca0b:271e:1cb5:ebc:4cda:476e
[31mdl: mod: ./stdio.so (dlopen(//stdio.so, 6): image not found)
[;m[31mmodule stdio.so: No such file or directory
[;maucodec: PCMU/8000/1
aucodec: PCMA/8000/1
[31mdl: mod: ./coreaudio.so (dlopen(//coreaudio.so, 6): image not found)
[;m[31mmodule coreaudio.so: No such file or directory
[;mvidsrc: avcapture
medianat: stun
medianat: turn
medianat: ice
medianat: ice-lite
[31muuid: fopen() \260\216W/uuid (No such file or directory)
[;m[31mdl: mod: ./uuid.so (dlopen(//uuid.so, 6): image not found)
[;m[31mmodule uuid.so: No such file or directory
[;maccount: creating accounts template \260\216W/accounts
[31mdl: mod: ./account.so (dlopen(//account.so, 6): image not found)
[;m[31mmodule account.so: No such file or directory
[;mcontact: creating contacts template \260\216W/contacts
[31mdl: mod: ./contact.so (dlopen(//contact.so, 6): image not found)
[;m[31mmodule contact.so: No such file or directory
[;mPopulated 2 audio codecs
Populated 0 audio filters
Populated 0 video codecs
Populated 0 video filters
USER 204@xxxxxs.xxxxxx.xxx REGISTERED!!!!!
No Video codec used.
call: connecting to 'sip:202@xx.xx3.x3.xx4'..
sip:202@xx.xxxx.x3.xxx: session closed: Operation timed out
Call event: 
call_event(rawValue: 4)
call: terminate call '102cef6876199d23' with sip:202@xx.xxx.xx.xx4
ua_event(rawValue: 11)

但是当我打印日志let registered = ua_isregistered(agent)时,它返回0,并获得成功,但是当我看到服务器的日志什么都没得到时。

我认为这是[si_destination_compare] send failed: Invalid argument的问题,我搜索了很多东西,但找不到解决方案。谁能帮我吗?

谢谢。

0 个答案:

没有答案