johanlantz / pj-nat64

Helpers for NAT64 handling pending official solutions from pjsip
MIT License
16 stars 4 forks source link

module integration issue #5

Open ai-ls opened 7 years ago

ai-ls commented 7 years ago

Hi. I integrate your code with my pjsip project, but I have a issue.

I register module, but it doesn't work! And I need do some other setting? Here is my code.

status = pjsua_start();
if (status != PJ_SUCCESS) {
    CLog(@"pjsua_start error...");
    return ;
}
pj_nat64_enable_rewrite_module();

pjsua_acc_config acc_cfg;
pjsua_acc_config_default(&acc_cfg);
acc_cfg.reg_retry_interval = 10;
acc_cfg.id = pj_str((char *)[NSString stringWithFormat:@"sip:%@@%@", username, server].UTF8String);
acc_cfg.reg_uri = pj_str((char *)[NSString stringWithFormat:@"sip:%@", server].UTF8String);
acc_cfg.cred_count = 1;
acc_cfg.cred_info[0].scheme = pj_str("digest");
acc_cfg.cred_info[0].realm = pj_str("*");
acc_cfg.cred_info[0].username = pj_str((char *)username.UTF8String);
acc_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
acc_cfg.cred_info[0].data = pj_str((char *)password.UTF8String);
acc_cfg.transport_id = tp_id;
acc_cfg.ipv6_media_use = PJSUA_IPV6_ENABLED;
pjsua_acc_add(&acc_cfg, PJ_TRUE, &acc_id);
johanlantz commented 7 years ago

I can only advice you do debug what is going on in your specific case. We use this in production since a couple of month but I know others have had to to minor adaptations to make it work in their environments (especially for the Route-Record rewriting that I have not implemented since it was not needed for us).

ai-ls commented 7 years ago
pjsip_transport* active_transport;
if (active_transport->factory->type & PJSIP_TRANSPORT_IPV6) {
  PJ_LOG(2,(THIS_FILE, "New transport is ipv6, activate ipv6 media"));
  pjsua_var.acc[your_active_account].cfg.ipv6_media_use = PJSUA_IPV6_ENABLED;
  if (your_config.nat_64_bitmap) {
    PJ_LOG(4,(THIS_FILE, "Activating NAT64 rewriting with value=%d", your_config.nat_64_bitmap));
    pj_nat64_set_options(your_config.nat_64_bitmap);
  }
}

thanks, which callback function we should call above code? in on_call_media_state(pjsua_call_id call_id) or on_call_state(pjsua_call_id call_id, pjsip_event *e) ?

ai-ls commented 7 years ago

Hi, do you have some simple code that I can refer?

johanlantz commented 7 years ago

Sorry, the module is shared as is. I can not share more production code. I know several other projects has integrated it but you might have to do some tweaks. I have the module activation in the on_reg_state callback since at that state you do not yet care about media but signalling has completed and you can figure out if you are on ipv6 or not. (This code just assumes that you are behind NAT64 if the transport is ipv6).