Changeset 5721 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Jan 8, 2018 4:08:35 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r5710 r5721 664 664 } 665 665 } 666 667 668 static pj_status_t dlg_set_target(pjsip_dialog *dlg, const pj_str_t *target) 669 { 670 pjsip_uri *target_uri; 671 pj_str_t tmp; 672 pj_status_t status; 673 674 /* Parse target & verify */ 675 pj_strdup_with_null(dlg->pool, &tmp, target); 676 target_uri = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen, 0); 677 if (!target_uri) { 678 return PJSIP_EINVALIDURI; 679 } 680 if (!PJSIP_URI_SCHEME_IS_SIP(target_uri) && 681 !PJSIP_URI_SCHEME_IS_SIPS(target_uri)) 682 { 683 return PJSIP_EINVALIDSCHEME; 684 } 685 686 /* Add the new target */ 687 status = pjsip_target_set_add_uri(&dlg->target_set, dlg->pool, 688 target_uri, 0); 689 if (status != PJ_SUCCESS) 690 return status; 691 692 /* Set it as current target */ 693 status = pjsip_target_set_set_current(&dlg->target_set, 694 pjsip_target_set_get_next(&dlg->target_set)); 695 if (status != PJ_SUCCESS) 696 return status; 697 698 /* Update dialog target URI */ 699 dlg->target = target_uri; 700 701 return PJ_SUCCESS; 702 } 703 704 705 /* Get account contact for call and update dialog transport */ 706 void call_update_contact(pjsua_call *call, pj_str_t **new_contact) 707 { 708 pjsip_tpselector tp_sel; 709 pjsua_acc *acc = &pjsua_var.acc[call->acc_id]; 710 711 if (acc->cfg.force_contact.slen) 712 *new_contact = &acc->cfg.force_contact; 713 else if (acc->contact.slen) 714 *new_contact = &acc->contact; 715 716 /* When contact is changed, the account transport may have been 717 * changed too, so let's update the dialog's transport too. 718 */ 719 pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 720 pjsip_dlg_set_transport(call->inv->dlg, &tp_sel); 721 } 722 723 666 724 667 725 /* … … 2512 2570 pjsua_acc_is_valid(call->acc_id)) 2513 2571 { 2514 new_contact = &pjsua_var.acc[call->acc_id].contact;2572 call_update_contact(call, &new_contact); 2515 2573 } 2516 2574 … … 2519 2577 { 2520 2578 dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 2579 } 2580 2581 if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) && 2582 msg_data && msg_data->target_uri.slen) 2583 { 2584 status = dlg_set_target(dlg, &msg_data->target_uri); 2585 if (status != PJ_SUCCESS) { 2586 pjsua_perror(THIS_FILE, "Unable to set new target", status); 2587 goto on_return; 2588 } 2521 2589 } 2522 2590 … … 2639 2707 pjsua_acc_is_valid(call->acc_id)) 2640 2708 { 2641 new_contact = &pjsua_var.acc[call->acc_id].contact;2709 call_update_contact(call, &new_contact); 2642 2710 } 2643 2711 … … 2646 2714 { 2647 2715 dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 2716 } 2717 2718 if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) && 2719 msg_data && msg_data->target_uri.slen) 2720 { 2721 status = dlg_set_target(dlg, &msg_data->target_uri); 2722 if (status != PJ_SUCCESS) { 2723 pjsua_perror(THIS_FILE, "Unable to set new target", status); 2724 goto on_return; 2725 } 2648 2726 } 2649 2727 … … 2757 2835 pjsua_acc_is_valid(call->acc_id)) 2758 2836 { 2759 new_contact = &pjsua_var.acc[call->acc_id].contact;2837 call_update_contact(call, &new_contact); 2760 2838 } 2761 2839 … … 2764 2842 { 2765 2843 dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 2844 } 2845 2846 if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) && 2847 msg_data && msg_data->target_uri.slen) 2848 { 2849 status = dlg_set_target(dlg, &msg_data->target_uri); 2850 if (status != PJ_SUCCESS) { 2851 pjsua_perror(THIS_FILE, "Unable to set new target", status); 2852 goto on_return; 2853 } 2766 2854 } 2767 2855
Note: See TracChangeset
for help on using the changeset viewer.