title: PJSIP - Creating an Objective C Wrapper
body: <p>I'm attempting to make a simple objective C wrapper by exposing the high level C/C++ API. For a proof of concept, I've implemented the simple SIP UA example given at</p>
  
  <p><a href="http://svn.pjsip.org/repos/pjproject/trunk/pjsip-apps/src/samples/simple_pjsua.c" rel="nofollow">http://svn.pjsip.org/repos/pjproject/trunk/pjsip-apps/src/samples/simple_pjsua.c</a></p>
  
  <p>I can get as far as the creating the SIP user account (pjsua_acc_add function below) </p>
  
  <pre><code>- (void) registerWithSipServer {
  
      /* Register to SIP server by creating SIP account. */
      pjsua_acc_config a_cfg;
      pjsua_acc_id acc_id;
      pj_status_t status;
  
  
      pjsua_acc_config_default(&amp;a_cfg);
      a_cfg.id = pj_str("sip:" SIP_USER "@" SIP_DOMAIN);
      a_cfg.reg_uri = pj_str("sip:" SIP_DOMAIN);
      a_cfg.cred_count = 1;
      a_cfg.cred_info[0].realm = pj_str(SIP_DOMAIN);
      a_cfg.cred_info[0].scheme = pj_str("digest");
      a_cfg.cred_info[0].username = pj_str(SIP_USER);
      a_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
      a_cfg.cred_info[0].data = pj_str(SIP_PASSWD);
  
      status = pjsua_acc_add(&amp;a_cfg, PJ_TRUE, &amp;acc_id);
  
      if (status != PJ_SUCCESS) {
          NSLog(@"Failed to start PJSUA");
      }
  
  
  }
  </code></pre>
  
  <p>but when I try and add it, I get an assertion</p>
  
  <blockquote>
    <p>11:59:07.083       endpoint  ..Request msg REGISTER/cseq=1665
    (tdta0xbb15200) created. Assertion failed: (mod_stateful_util.id !=
    -1), function pjsip_endpt_send_request, file ../src/pjsip/sip_util_statefull.c, line 99.</p>
  </blockquote>
  
  <p>Tracking that down line 99 in sip_util_statefull.c we get the function</p>
  
  <pre><code>PJ_ASSERT_RETURN(mod_stateful_util.id != -1, PJ_EINVALIDOP);
  </code></pre>
  
  <p>I've tried to figure out why this fails but have so far come unstuck. Anybody else attempted this?</p>