2012-09-05 22 views
2

所以我有一個編譯和運行的虹吸應用程序,但它只是不會打電話。 我得到:虹吸調用不起作用 - pjsip

註冊錯誤 - 默認錯誤消息。

完整的錯誤是這樣的:

15:04:02.032 pjsua_call.c撥打電話與ACC#0到SIP:[email protected] 15:04:02.032 pjsua_call.c .Unable進行呼叫,因爲賬號是無效的:無效操作(PJ_EINVALIDOP)狀態= 70013] 15:04:05.580 call.m錯誤撥打電話:無效操作(PJ_EINVALIDOP)狀態= 70013]

但是當我使用同一個帳戶在不同的SIP應用程序,它工作得很好。

當pjsip調用sip_dial_with_uri(_sip_acc_id,[url UTF8String],& call_id);

_sip_acc_id爲0,因爲我認爲這是在虹吸設置中的第0個帳戶。 網址是正確的電話號碼我正在嘗試撥打,但顯示如下: SIP:[email protected] 和呼叫ID只是一個參考,所以我不知道它是否重要。

當我看着其他voip應用程序,他們有一個註冊過程。你在哪裏輸入用戶名,密碼和SIP服務器域或IP。

對於虹吸管,這是在設置文件中完成的。但是,如果「註冊或登錄」是在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"]; 
    } 
    } 
} 

此外,如果任何人有一個鏈接到虹吸式應用程序的代碼,這是新的,也許效果更好,我會很感激這一點。

更多信息:

在call.m文件基本上是這樣被調用

status = pjsua_call_make_call(acc_id, &pj_uri, 0, NULL, NULL, call_id); 

這裏

ACC_ID = 0

pj_uri =字符* - >「SIP: [email protected]「 pj_ssize_t - > 33

CALL_ID = 803203976

+1

使用[此示例鏈接](https://github.com/radif/SIPHON-SIP-Client-that-actually-compiles)。它是我找到的最新的更新,並且很好地接聽電話。希望有幫助 –

回答

4

我想通了這一點。原來,虹吸應用程序沒有註冊該帳戶。 下面的代碼是很重要的:

pj_status_t sip_connect(pj_pool_t *pool, pjsua_acc_id *acc_id) 
{ 

// ID 
    acc_cfg.id.ptr = (char*) pj_pool_alloc(/*app_config.*/pool, PJSIP_MAX_URL_SIZE); 
    if (contactname && strlen(contactname)) 
    acc_cfg.id.slen = pj_ansi_snprintf(acc_cfg.id.ptr, PJSIP_MAX_URL_SIZE, 
             "\"%s\"<sip:%[email protected]%s>", contactname, uname, server); 
    else 
    acc_cfg.id.slen = pj_ansi_snprintf(acc_cfg.id.ptr, PJSIP_MAX_URL_SIZE, 
             "sip:%[email protected]%s", uname, server); 
    if ((status = pjsua_verify_sip_url(acc_cfg.id.ptr)) != 0) 
    { 
    PJ_LOG(1,(THIS_FILE, "Error: invalid SIP URL '%s' in local id argument", 
     acc_cfg.id)); 
    [app displayParameterError: @"Invalid value for username or server."]; 
    return status; 
    } 

    // Registrar 
    acc_cfg.reg_uri.ptr = (char*) pj_pool_alloc(/*app_config.*/pool, 
    PJSIP_MAX_URL_SIZE); 
    acc_cfg.reg_uri.slen = pj_ansi_snprintf(acc_cfg.reg_uri.ptr, 
    PJSIP_MAX_URL_SIZE, "sip:%s", server); 
    if ((status = pjsua_verify_sip_url(acc_cfg.reg_uri.ptr)) != 0) 
    { 
    PJ_LOG(1,(THIS_FILE, "Error: invalid SIP URL '%s' in registrar argument", 
     acc_cfg.reg_uri)); 
    [app displayParameterError: @"Invalid value for server parameter."]; 
    return status; 
    } 

    ... 
    more code here 
    ... 
} 

這是你的帳戶被註冊到SIP服務器。 確保sip_connect函數從下圖所示的主應用程序本身叫做:

/* */ 
- (BOOL)sipConnect 
{ 
    pj_status_t status; 

    if (![self sipStartup]) 
    return FALSE; 

    //if ([self wakeUpNetwork] == NO) 
    // return NO; 
    NSLog(@"%i", _sip_acc_id); 
    //if (_sip_acc_id == PJSUA_INVALID_ID) 
    //{ 
    self.networkActivityIndicatorVisible = YES; 
    if ((status = sip_connect(_app_config.pool, &_sip_acc_id)) != PJ_SUCCESS) 
    { 
     self.networkActivityIndicatorVisible = NO; 
     return FALSE; 
    } 
    //} 

    return TRUE; 
} 
在我的情況_sip_acc_id

不等於PJSUA_INVALID_ID因此sip_connect從未得到調用。

感謝所有那些試圖在頭腦中解決它的人? :)

2

你不可能得到任何有益的幫助,除非你發佈代碼片段以及(至少)錯誤輸出。更多上下文(如配置信息和網絡的相關方面)將進一步提高您的機會。

(我會增加,這個是有問題的評論,但還沒有所需的聲譽。)

+0

好的,用更多的信息更新了這個問題。 – c0d3Junk13