Changeset 284 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Mar 5, 2006 11:54:02 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r268 r284 38 38 { 39 39 pj_str_t dest_uri; 40 pjsip_dialog *dlg ;40 pjsip_dialog *dlg = NULL; 41 41 pjmedia_sdp_session *offer; 42 pjsip_inv_session *inv ;42 pjsip_inv_session *inv = NULL; 43 43 int call_index = -1; 44 44 pjsip_tx_data *tdata; … … 142 142 143 143 on_error: 144 PJ_TODO(DESTROY_DIALOG_ON_FAIL); 144 if (inv != NULL) { 145 pjsip_inv_terminate(inv, PJSIP_SC_OK, PJ_FALSE); 146 } else { 147 pjsip_dlg_terminate(dlg); 148 } 149 145 150 if (call_index != -1) { 146 151 pjsua.calls[call_index].inv = NULL; … … 160 165 pjsip_tx_data *response = NULL; 161 166 unsigned options = 0; 162 pjsip_inv_session *inv ;167 pjsip_inv_session *inv = NULL; 163 168 int acc_index; 164 169 int call_index = -1; … … 261 266 262 267 pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 263 264 // TODO: Need to delete dialog 268 pjsip_dlg_terminate(dlg); 265 269 return PJ_TRUE; 266 270 } … … 287 291 288 292 pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 289 290 // TODO: Need to delete dialog 293 pjsip_inv_terminate(inv, 500, PJ_FALSE); 291 294 292 295 } else { … … 723 726 } 724 727 728 /* Disconnect call */ 729 static void call_disconnect(pjsip_inv_session *inv, 730 int st_code) 731 { 732 pjsip_tx_data *tdata; 733 pj_status_t status; 734 735 status = pjsip_inv_end_session(inv, st_code, NULL, &tdata); 736 if (status == PJ_SUCCESS) 737 status = pjsip_inv_send_msg(inv, tdata, NULL); 738 739 if (status != PJ_SUCCESS) { 740 pjsua_perror(THIS_FILE, "Unable to disconnect call", status); 741 } 742 } 725 743 726 744 /* … … 744 762 745 763 pjsua_perror(THIS_FILE, "SDP negotiation has failed", status); 764 765 /* Disconnect call if this is not a re-INVITE */ 766 if (inv->state != PJSIP_INV_STATE_CONFIRMED) { 767 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 768 } 746 769 return; 747 770 … … 763 786 "Unable to retrieve currently active local SDP", 764 787 status); 788 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 765 789 return; 766 790 } … … 772 796 "Unable to retrieve currently active remote SDP", 773 797 status); 798 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 774 799 return; 775 800 } … … 789 814 pjsua_perror(THIS_FILE, "Unable to create media session", 790 815 status); 816 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 791 817 return; 792 818 } … … 818 844 pjmedia_session_destroy(call->session); 819 845 call->session = NULL; 846 call_disconnect(inv, PJSIP_SC_INTERNAL_SERVER_ERROR); 820 847 return; 821 848 } … … 910 937 * Hangup call. 911 938 */ 912 void pjsua_call_hangup(int call_index , int code)939 void pjsua_call_hangup(int call_index) 913 940 { 914 941 pjsua_call *call; 942 int code; 915 943 pj_status_t status; 916 944 pjsip_tx_data *tdata; … … 923 951 return; 924 952 } 953 954 if (call->inv->state == PJSIP_INV_STATE_CONFIRMED) 955 code = PJSIP_SC_OK; 956 else if (call->inv->role == PJSIP_ROLE_UAS) 957 code = PJSIP_SC_DECLINE; 958 else 959 code = PJSIP_SC_REQUEST_TERMINATED; 925 960 926 961 status = pjsip_inv_end_session(call->inv, code, NULL, &tdata); … … 1190 1225 * Terminate all calls. 1191 1226 */ 1192 void pjsua_call_hangup_all( )1227 void pjsua_call_hangup_all(void) 1193 1228 { 1194 1229 int i; … … 1196 1231 for (i=0; i<pjsua.max_calls; ++i) { 1197 1232 pjsip_tx_data *tdata; 1233 int st_code; 1198 1234 pjsua_call *call; 1199 1235 … … 1203 1239 call = &pjsua.calls[i]; 1204 1240 1205 if (pjsip_inv_end_session(call->inv, 410, NULL, &tdata)==0) { 1241 if (call->inv->state == PJSIP_INV_STATE_CONFIRMED) { 1242 st_code = 200; 1243 } else { 1244 st_code = PJSIP_SC_GONE; 1245 } 1246 1247 if (pjsip_inv_end_session(call->inv, st_code, NULL, &tdata)==0) { 1206 1248 if (tdata) 1207 1249 pjsip_inv_send_msg(call->inv, tdata, NULL);
Note: See TracChangeset
for help on using the changeset viewer.