Skip to content

Instantly share code, notes, and snippets.

@AdilSoomro
Last active December 9, 2015 21:08
Show Gist options
  • Save AdilSoomro/4328066 to your computer and use it in GitHub Desktop.
Save AdilSoomro/4328066 to your computer and use it in GitHub Desktop.
baresip initialization code
int err;
/* Initialise System library */
err = libre_init();
/* Initialise dynamic modules */
mod_init();
err = net_init(); // do not prefer IP v6
if (err) {
NSLog(@"network init failed (%@)\n", strerror(err));
//return err;
}
err = ua_init([@"MyApp 1.0" cStringUsingEncoding:NSASCIIStringEncoding],true,
true, true, true);
if (err)
{
NSLog(@"User Agents init failed (%s)\n", strerror(err));
}
NSMutableString *addr = [NSMutableString string];
[addr appendFormat:@"<sip:%@:%@@%@;transport=%@>;regint=%d", //;sipnat=outbound",
@"adil.soomro", @"password", @"iptel.org:5060",
@"tcp",
60];
[addr appendFormat:@";auth_user=%@", @"adil.soomro"];
//[addr appendFormat:@";medianat=stun;stunserver=stun:%@", @""];
NSLog(@"UserString %@", addr);
struct pl pl_addr;
pl_set_str(&pl_addr, [addr cStringUsingEncoding:NSASCIIStringEncoding]);
if (ua_add(&pl_addr) == 0)
{
NSLog(@"Starting User");
}
else{
NSLog(@"Error Starting User");
}
/* Start all User-Agents */
err = ua_start_all();
if (err)
NSLog(@"User Agents start failed (%s) Error Code = %d\n", strerror(err), err);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment