[pjsip] Send Info Message with defined body

Lele 86eldnl at gmail.com
Mon Jan 16 03:12:43 EST 2017

Hi guys,

I'll try to send an Sip Info message on PJSIP_INV_STATE_CONFIRMED state
during enstablished dialog.

On on_call_state(.) pjsua Callback I have introduced the following code but
I obtained a crash:


void PjCallback::on_call_state(pjsua_call_id call_id, pjsip_event *e) {


     pj_status_t status;


     //Obtain detail information about the specified call

     pjsua_call_info ci;

     status = pjsua_call_get_info(call_id, &ci);


     //Obtain detail information about the specified call

pjsip_tx_data tdata;


//Pointer to tdata

     pjsip_tx_data  *pTdata;

//take the address of tdata

     pTdata = &tdata;


//Pointer to pointer tdata

     pjsip_tx_data  **ppTdata;

//take the address of pTdata using address of operator &

     ppTdata = &pTdata;


     //Get incoming message buffer

     pjsip_rx_data *rdata;

     rdata = e->body.tsx_state.src.rdata;


     //Get pjsip_dialog

pjsip_dialog *dlg;

     dlg = pjsip_rdata_get_dlg(rdata);


     //Get endpoint

     pjsip_endpoint *endpt = pjsua_get_pjsip_endpt();


     //Define standard xml to send in Info Sip body message

     pj_str_t xmlString = pj_str("<note>




<body>Don't forget me this weekend!</body>


     pj_str_t typeMessage = pj_str("text");

     pj_str_t subtypeMessage = pj_str("xml");


     pj_pool_t *poolTest;

     poolTest = pjsua_pool_create("infoMessage", 1000, 1000);

     pjsip_msg_body *createMessageBody;


     char dup[1500];


     switch(ci.state) {

     case PJSIP_INV_STATE_CONFIRMED:                  

           //Body Sip Info message

           createMessageBody = pjsip_msg_body_create(poolTest, &typeMessage,
&subtypeMessage, &xmlString);

           pjsip_print_text_body(createMessageBody, dup, sizeof(dup));


           //Create dialog request

           status = pjsip_dlg_create_request(dlg, &pjsip_info_method, -1,

           if (status == PJ_SUCCESS) {

                //Send request (send Info message

                status = pjsip_dlg_send_request(dlg, pTdata, -1, NULL);








I get a crash when I call pjsip_msg_body_create function. Where is the
problem? Thanks in advice.


Best Regards


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20170116/31470e10/attachment-0002.html>

More information about the pjsip mailing list