Changeset 141 for pjproject/trunk/pjsip/src/pjsip/sip_util_statefull.c
- Timestamp:
- Feb 7, 2006 6:48:01 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_util_statefull.c
r107 r141 22 22 #include <pjsip/sip_transaction.h> 23 23 #include <pjsip/sip_event.h> 24 #include <pjsip/sip_errno.h> 24 25 #include <pj/pool.h> 26 #include <pj/assert.h> 25 27 26 struct aux_tsx_data28 struct tsx_data 27 29 { 28 30 void *token; 29 void (*cb)(void*, pjsip_event*);31 void (*cb)(void*, pjsip_event*); 30 32 }; 31 33 32 static void aux_tsx_handler( pjsip_transaction *tsx, pjsip_event *event);34 static void mod_util_on_tsx_state(pjsip_transaction*, pjsip_event*); 33 35 34 pjsip_module aux_tsx_module = 36 /* This module will be registered in pjsip_endpt.c */ 37 38 pjsip_module mod_stateful_util = 35 39 { 36 NULL, NULL, /* prev and next*/37 { " Aux-Tsx", 7}, /* Name.*/38 -1, /* Id*/39 PJSIP_MOD_PRIORITY_APPLICATION -1, /* Priority*/40 NULL, /* User data.*/41 0, /* Number of methods supported (=0).*/42 { 0 }, /* Array of methods (none)*/43 NULL, /* load()*/44 NULL, /* start()*/45 NULL, /* stop()*/46 NULL, /* unload()*/47 NULL, /* on_rx_request()*/48 NULL, /* on_rx_response()*/49 & aux_tsx_handler, /* tsx_handler()*/40 NULL, NULL, /* prev, next. */ 41 { "mod-stateful-util", 17 }, /* Name. */ 42 -1, /* Id */ 43 PJSIP_MOD_PRIORITY_APPLICATION, /* Priority */ 44 NULL, /* User data. */ 45 NULL, /* load() */ 46 NULL, /* start() */ 47 NULL, /* stop() */ 48 NULL, /* unload() */ 49 NULL, /* on_rx_request() */ 50 NULL, /* on_rx_response() */ 51 NULL, /* on_tx_request. */ 52 NULL, /* on_tx_response() */ 53 &mod_util_on_tsx_state, /* on_tsx_state() */ 50 54 }; 51 55 52 static void aux_tsx_handler( pjsip_transaction *tsx, pjsip_event *event)56 static void mod_util_on_tsx_state(pjsip_transaction *tsx, pjsip_event *event) 53 57 { 54 struct aux_tsx_data *tsx_data;58 struct tsx_data *tsx_data; 55 59 56 60 if (event->type != PJSIP_EVENT_TSX_STATE) 57 61 return; 58 if (tsx->module_data[aux_tsx_module.id] == NULL) 62 63 tsx_data = tsx->mod_data[mod_stateful_util.id]; 64 if (tsx_data == NULL) 59 65 return; 66 60 67 if (tsx->status_code < 200) 61 68 return; … … 64 71 * by clearing the transaction's module_data. 65 72 */ 66 tsx_data = tsx->module_data[aux_tsx_module.id]; 67 tsx->module_data[aux_tsx_module.id] = NULL; 73 tsx->mod_data[mod_stateful_util.id] = NULL; 68 74 69 75 if (tsx_data->cb) { … … 80 86 { 81 87 pjsip_transaction *tsx; 82 struct aux_tsx_data *tsx_data;88 struct tsx_data *tsx_data; 83 89 pj_status_t status; 84 90 85 status = pjsip_endpt_create_tsx(endpt, &tsx); 86 if (!tsx) { 91 PJ_ASSERT_RETURN(endpt && tdata && (timeout==-1 || timeout>0), PJ_EINVAL); 92 93 status = pjsip_tsx_create_uac(&mod_stateful_util, tdata, &tsx); 94 if (status != PJ_SUCCESS) { 87 95 pjsip_tx_data_dec_ref(tdata); 88 return -1;96 return status; 89 97 } 90 98 91 tsx_data = pj_pool_alloc(tsx->pool, sizeof(struct aux_tsx_data));99 tsx_data = pj_pool_alloc(tsx->pool, sizeof(struct tsx_data)); 92 100 tsx_data->token = token; 93 101 tsx_data->cb = cb; 94 tsx->mod ule_data[aux_tsx_module.id] = tsx_data;102 tsx->mod_data[mod_stateful_util.id] = tsx_data; 95 103 96 if (pjsip_tsx_init_uac(tsx, tdata) != 0) { 97 pjsip_endpt_destroy_tsx(endpt, tsx); 98 pjsip_tx_data_dec_ref(tdata); 99 return -1; 100 } 104 PJ_TODO(IMPLEMENT_TIMEOUT_FOR_SEND_REQUEST); 101 105 102 pjsip_endpt_register_tsx(endpt, tsx); 103 pjsip_tx_data_invalidate_msg(tdata); 104 pjsip_tsx_on_tx_msg(tsx, tdata); 105 pjsip_tx_data_dec_ref(tdata); 106 return 0; 106 return pjsip_tsx_send_msg(tsx, NULL); 107 107 } 108 108
Note: See TracChangeset
for help on using the changeset viewer.