【发布时间】:2012-09-05 18:02:11
【问题描述】:
所以我有一个已编译并正在运行的 Siphon 应用程序,但它不会进行调用。 我明白了:
注册错误 - 默认错误消息。
完全错误是这样的:
15:04:02.032 pjsua_call.c 使用 acc #0 拨打 sip:6476805821@voip5-2.acanac.com 15:04:02.032 pjsua_call.c .无法拨打电话,因为帐户无效:无效操作 (PJ_EINVALIDOP) [status=70013] 15:04:05.580 call.m 调用错误:无效操作 (PJ_EINVALIDOP) [status=70013]
但是当我在不同的 SIP 应用程序上使用同一个帐户时,它工作得非常好。
当pjsip调用sip_dial_with_uri(_sip_acc_id, [url UTF8String], &call_id);
_sip_acc_id 为 0,因为我相信它是 siphon 设置中的第 0 个帐户。 url 是我尝试拨打的正确电话号码,但显示如下: 啜饮:62304892@url.com call id 只是一个参考,所以我不知道它是否重要。
当我查看其他 voip 应用程序时,他们有一个注册过程。在哪里输入您的用户名、密码和 sip 服务器域或 ip。
对于 Siphon,这是在设置文件中完成的。但是,是否在 Siphon 的代码中完成了“注册或登录”,我不确定。 会不会是这个问题?
这是尝试进行实际调用的代码:
/** FIXME plutôt à mettre dans l'objet qui gère les appels **/
-(void) dialup:(NSString *)phoneNumber number:(BOOL)isNumber
{
pjsua_call_id call_id;
pj_status_t status;
NSString *number;
UInt32 hasMicro, size;
// Verify if microphone is available (perhaps we should verify in another place ?)
size = sizeof(hasMicro);
AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable,
&size, &hasMicro);
/*if (!hasMicro)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"No Microphone Available", @"SiphonApp")
message:NSLocalizedString(@"Connect a microphone to phone", @"SiphonApp")
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"SiphonApp")
otherButtonTitles:nil];
[alert show];
[alert release];
return;
}*/
if (isNumber)
number = [self normalizePhoneNumber:phoneNumber];
else
number = phoneNumber;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"removeIntlPrefix"])
{
number = [number stringByReplacingOccurrencesOfString:@"+"
withString:@""
options:0
range:NSMakeRange(0,1)];
}
else
{
NSString *prefix = [[NSUserDefaults standardUserDefaults] stringForKey:
@"intlPrefix"];
if ([prefix length] > 0)
{
number = [number stringByReplacingOccurrencesOfString:@"+"
withString:prefix
options:0
range:NSMakeRange(0,1)];
}
}
// Manage pause symbol
NSArray * array = [number componentsSeparatedByString:@","];
[callViewController setDtmfCmd:@""];
if ([array count] > 1)
{
number = [array objectAtIndex:0];
[callViewController setDtmfCmd:[array objectAtIndex:1]];
}
if (!isConnected && [self wakeUpNetwork] == NO)
{
_phoneNumber = [[NSString stringWithString: number] retain];
if (isIpod)
{
UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:nil
message:NSLocalizedString(@"You must enable Wi-Fi or SIP account to place a call.",@"SiphonApp")
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK",@"SiphonApp")
otherButtonTitles:nil] autorelease];
[alertView show];
}
else
{
UIActionSheet *actionSheet = [[[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"The SIP server is unreachable!",@"SiphonApp")
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel",@"SiphonApp")
destructiveButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"Cellular call",@"SiphonApp"),
nil] autorelease];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView: self.window];
}
return;
}
if ([self sipConnect])
{
NSRange range = [number rangeOfString:@"@"];
NSLog(@"%i", _sip_acc_id);
if (range.location != NSNotFound)
{
status = sip_dial_with_uri(_sip_acc_id, [[NSString stringWithFormat:@"sip:%@", number] UTF8String], &call_id);
}
else
status = sip_dial(_sip_acc_id, [number UTF8String], &call_id);
if (status != PJ_SUCCESS)
{
// FIXME
//[self displayStatus:status withTitle:nil];
const pj_str_t *str = pjsip_get_status_text(status);
NSString *msg = [[NSString alloc]
initWithBytes:str->ptr
length:str->slen
encoding:[NSString defaultCStringEncoding]];
[self displayError:msg withTitle:@"registration error"];
}
}
}
另外,如果有人有指向 Siphon 应用程序代码的链接,该代码更新并且可能效果更好,我也将不胜感激。
更多信息:
在 call.m 文件中本质上是这样调用的:
status = pjsua_call_make_call(acc_id, &pj_uri, 0, NULL, NULL, call_id);
这里
acc_id = 0
pj_uri = char *-> "sip:6476805821@voip5-2.acanac.com" pj_ssize_t -> 33
call_id = 803203976
【问题讨论】:
-
使用this example link。这是我发现的最新版本,并且运行良好,请致电接收。希望有帮助