Cocoapod for baresip.
CFNetwork
、AudioToolbox
、AVFoundation
、SystemConfiguration
和 CoreMedia
。libstdc++.tbd
和 libresolv.9.tbd
。请参阅 baresip 文档。
在您的 -Bridging_Header.h
中导入头文件。
#import <re.h>
#import <baresip.h>
var agent: COpaquePointer = COpaquePointer(nilLiteral: ())
sip(&agent)
sipClose(agent)
func sip(inout agent: COpaquePointer)
{
var error = libre_init()
if error != 0
{
return
}
// Initialize dynamic modules.
mod_init()
// Make configure file.
let mainBundle = NSBundle.mainBundle()
if let path = mainBundle.resourcePath
{
conf_path_set(getCString(path))
}
error = conf_configure()
if error != 0
{
return
}
// Initialize the SIP stack.
error = ua_init("SIP", 1, 1, 1, 0)
if error != 0
{
return
}
// Load modules.
error = conf_modules()
if error != 0
{
return
}
let addr: String = "sip:user:[email protected]:port;transport=udp;answermode=auto"
// Start user agent.
error = ua_alloc(&agent, getCString(addr))
if error != 0
{
return
}
// Make an outgoing call.
error = ua_connect(agent, nil, nil, "sip:[email protected]:port", nil, VIDMODE_OFF);
if error != 0
{
return
}
// Start the main loop.
re_main(nil)
}
private func sipClose(agent: COpaquePointer)
{
mem_deref(UnsafeMutablePointer(agent))
ua_close()
mod_close()
// Close and check for memory leaks.
libre_close()
tmr_debug()
mem_debug()
}