On Thu, Aug 14, 2008 at 12:37 PM, cedric leveque <levequecedric at hotmail.com>wrote: > Nobody have any idea ? > > Why don't you check the source location as pointed out by the assertion message and see what the assert is complaining about. Cheers Benny > > ------------------------------ > From: levequecedric@xxxxxxxxxxx > To: pjsip at lists.pjsip.org > Date: Wed, 13 Aug 2008 17:52:57 +0200 > Subject: [pjsua]B2BUA and Adding function in PJSUA_Call.c > > > Hi, > > I want create a Back to Back User Agent who is transparent for UA that > establishing a call. > So I need to forward all incoming call to its final destination. > I try to use PJSUA, but I didn't find any function doing this, and I try to > create it, with this code : > > *********************************************** > * > * > * Code Adding in the end of pjsua_call.c (and definition in .h) * > * > * > *********************************************** > > /* > * Forwarding call to the specified URI using the specified account. > */ > PJ_DEF(pj_status_t) pjsua_forward(pjsua_call_id call_id, > pjsip_msg *msg) > { > pjsip_tx_data *tdata; > pj_str_t contact; > pj_status_t status; > > pjsua_call_info * info; > pjsua_acc_id acc_id; > > /* Get Info about current call. */ > pjsua_call_get_info (call_id, &info); > > /* Set account id to current account id */ > /*acc_id = info -> acc_id;*/ > /* Create request. */ > status = pjsip_endpt_create_request(pjsua_var.endpt, > &pjsip_message_method, NULL, NULL,NULL, NULL, NULL, -1, NULL, &tdata); > > if (status != PJ_SUCCESS) { > pjsua_perror(THIS_FILE, "Unable to create request", status); > return status; > } > /* If account is locked to specific transport, then set transport to > * the request. > */ > /*if (pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) { > pjsip_tpselector tp_sel; > pjsua_init_tpselector(pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel); > pjsip_tx_data_set_transport(tdata, &tp_sel); > }*/ > > /* Add msg to tdata->msg */ > tdata->msg = msg; > /* Add message body */ > status = pjsip_msg_body_copy(tdata->pool, tdata->msg->body, msg->body); > if (status != PJ_SUCCESS) { > pjsua_perror(THIS_FILE, "Unable to create msg body", PJ_ENOMEM); > pjsip_tx_data_dec_ref(tdata); > return PJ_ENOMEM; > } > /* Add route set */ > /*pjsua_set_msg_route_set(tdata, &pjsua_var.acc[acc_id].route_set);*/ > /* Send request (statefully) */ > status = pjsip_endpt_send_request( pjsua_var.endpt, tdata, -1, > NULL, NULL); > if (status != PJ_SUCCESS) { > pjsua_perror(THIS_FILE, "Unable to send request", status); > return status; > } > return PJ_SUCCESS; > } > > > > > And I create a Basic PJSUA Application Like this : > > *********************************************************** > * > * > * Basic PJSUA Application to test pjsua_forward in objective of made a > B2BUA * > * > * > *********************************************************** > > #include <pjsua-lib/pjsua.h> > #define THIS_FILE __FILE__ > /* Init PJSUA. */ > static pj_status_t app_init(void); > /* Run PJSUA */ > static pj_status_t app_run(void); > > > /* Callback called by the library when call's state has changed */ > static void on_call_state(pjsua_call_id call_id, pjsip_event *e) > { > pjsua_call_info ci; > PJ_UNUSED_ARG(e); > pjsua_call_get_info(call_id, &ci); > PJ_LOG(3,(THIS_FILE, "Call %d state=%.*s", call_id, > (int)ci.state_text.slen, > ci.state_text.ptr)); > } > > /* Display error and exit application */ > static void error_exit(const char *title, pj_status_t status) > { > pjsua_perror(THIS_FILE, title, status); > pjsua_destroy(); > exit(1); > } > /* Callback called by the library upon receiving incoming call */ > static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, > pjsip_rx_data *rdata) > { > pjsua_call_info ci; > PJ_UNUSED_ARG(acc_id); > PJ_UNUSED_ARG(rdata); > pjsua_call_get_info(call_id, &ci); > PJ_LOG(3,(THIS_FILE, "Incoming call from %.*s!!", > (int)ci.remote_info.slen, > ci.remote_info.ptr)); > /* Automatically answer incoming calls with 200/OK */ > pjsua_forward(call_id, rdata->msg_info.msg); > } > > int main(int argc, char *argv[]) > { > app_init(); > app_run(); > } > > static pj_status_t app_init(void) > { > pjsua_config ua_cfg; > pjsua_logging_config log_cfg; > pjsua_media_config media_cfg; > pj_status_t status; > // Must create pjsua before anything else! > status = pjsua_create(); > if (status != PJ_SUCCESS) { > pjsua_perror(THIS_FILE, "Error initializing pjsua", status); > return status; > } > // Initialize configs with default settings. > pjsua_config_default(&ua_cfg); > pjsua_logging_config_default(&log_cfg); > pjsua_media_config_default(&media_cfg); > // At the very least, application would want to override > // the call callbacks in pjsua_config: > ua_cfg.cb.on_incoming_call = &on_incoming_call; > ua_cfg.cb.on_call_state = on_call_state; > // Customize other settings (or initialize them from application > specific > // configuration file): > // Initialize pjsua > status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg); > if (status != PJ_SUCCESS) { > pjsua_perror(THIS_FILE, "Error initializing pjsua", status); > return status; > } > /* Add UDP transport. */ > { > pjsua_transport_config cfg; > pjsua_transport_config_default(&cfg); > cfg.port = 5060; > status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL); > if (status != PJ_SUCCESS) error_exit("Error creating transport", > status); > } > } > static pj_status_t app_run(void) > { > pj_status_t status; > // Start pjsua > status = pjsua_start(); > if (status != PJ_SUCCESS) { > pjsua_destroy(); > pjsua_perror(THIS_FILE, "Error starting pjsua", status); > return status; > } > // Run application loop > while (1) { > char choice[10]; > > printf("Running."); > fgets(choice, sizeof(choice), stdin); > printf("%s", choice); > } > } > > > > > Compiling it's ok, running it's, but when incomming calls arrives I have > this error : > > ******* > * Error * > ******* > After reception of the Invite, I can show it on the console screen, and > just after I have this : > b2b: ../src/pjsua-lib/pjsua_acc.c:1347: pjsua_acc_find_for_incoming: > Assertion `pjsua_var.acc_cnt!=0' failed. > Abandon > > > > > To understand my error, I try to log on a file when I arrives in first > function I have created, but, I don't arrives to this. > I don't understand what's happens !!! > > Anyone can helps me ? > > I thanks you by advance for your help. > > > C?dric. > > ------------------------------ > Tous vos amis discutent sur Messenger, et vous ? T?l?chargez Messenger, > c'est gratuit ! <http://www.windowslive.fr/messenger/> > ------------------------------ > Consultez vos emails sur votre mobile ! Cr?ez un compte Hotmail, c'est > gratuit ! <http://www.messengersurvotremobile.com/?d=hotmail> > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080814/df3cade7/attachment.html