3
votes

So I have a compiled and running Siphon app but it just won't make the calls. I get:

registration error - default error message.

Full error is this:

15:04:02.032 pjsua_call.c Making call with acc #0 to sip:[email protected] 15:04:02.032 pjsua_call.c .Unable to make call because account is not valid: Invalid operation (PJ_EINVALIDOP) [status=70013] 15:04:05.580 call.m Error making call: Invalid operation (PJ_EINVALIDOP) [status=70013]

But when I use the same account on a different SIP app, it works perfectly fine.

When pjsip calls sip_dial_with_uri(_sip_acc_id, [url UTF8String], &call_id);

_sip_acc_id is 0 since I believe it's the 0th account that's in the settings for siphon. url is the correct phone number I'm trying to dial but shows something like: sip:[email protected] and call id is just a reference so I dunno if it's important.

When I look at other voip apps, they have a registration process. Where you enter you username, password, and sip server domain or ip.

For Siphon, this is done in the settings file. However, if "register or login" is done in Siphon's code or not, I'm not sure. Could that be the problem?

This is the code that tries to make an actual call:

/** 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"];
    }
  }
}

Also if anyone has a link to the Siphon app's code that's newer and maybe works better, I'd appreciate that as well.

More info:

in call.m file essentially this gets called:

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

and here

acc_id = 0

pj_uri = char *-> "sip:[email protected]" pj_ssize_t -> 33

call_id = 803203976

2
Use this example link. it is most updated i found and working well call recieve. hope that helpsShahid Aslam

2 Answers

6
votes

I figured this out. Turns out, the siphon app wasn't registering the account. The code below is important:

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:%s@%s>", contactname, uname, server);
  else
    acc_cfg.id.slen = pj_ansi_snprintf(acc_cfg.id.ptr, PJSIP_MAX_URL_SIZE, 
                                       "sip:%s@%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
  ...
}

This is where your account gets registered to a SIP server. Make sure the sip_connect function gets called from the main application itself shown below:

/* */
- (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;
}

in my case _sip_acc_id wasn't equal to PJSUA_INVALID_ID therefore sip_connect was never getting called.

Thanks for all of those who tried to solve it in their head? :)

2
votes

You are unlikely to get any useful help unless you post a code snippet as well as error output (at minimum). More context, such as configuration info and relevant aspects of your network, will further improve your chances.

(I would have added this as a comment on the question, but don't yet have the required reputation.)