/** * \fn _ics_core_transfer_call() * \brief Chuyen huong cuoc goi * \param agr1: ics_t *data * agr2: int call_id_1 * agr3: int call_id_2 */ static void _ics_core_transfer_call(ics_t *data, int call_id_1, int call_id_2) { #if 0 if ( (call_id_1 != call_id_2) && pjsua_call_is_active(call_id_1) && pjsua_call_is_active(call_id_2) ) { pjsua_call_xfer_replaces(call_id_1, call_id_2, 0, NULL); } else printf("Cannot transfer call!\n"); #endif //For test only: #if 1 int i, max; pjsua_call_info ci; max = pjsua_call_get_count(); printf("You have %d active call%s\n", max, (max>1?"s":"")); for (i = 0; i < max; i++){ if (pjsua_call_is_active(i)) { pjsua_call_get_info(i, &ci); pjsua_call_xfer_replaces(current_call, ci.id, 0, NULL); break; } } #endif }
bool BlabbleCall::TransferReplace(const BlabbleCallPtr& otherCall) { BlabbleAccountPtr p = CheckAndGetParent(); if (!p) return false; if (!otherCall) return false; pj_status_t status = pjsua_call_xfer_replaces(call_id_, otherCall->call_id_, PJSUA_XFER_NO_REQUIRE_REPLACES, NULL); if (status == PJ_SUCCESS) { LocalEnd(); } return status == PJ_SUCCESS; }
static void ui_call_transfer_replaces(pj_bool_t no_refersub) { if (current_call == -1) { PJ_LOG(3,(THIS_FILE, "No current call")); } else { int call = current_call; int dst_call; pjsip_generic_string_hdr refer_sub; pj_str_t STR_REFER_SUB = { "Refer-Sub", 9 }; pj_str_t STR_FALSE = { "false", 5 }; pjsua_call_id ids[PJSUA_MAX_CALLS]; pjsua_call_info ci; pjsua_msg_data msg_data; char buf[128]; unsigned i, count; count = PJ_ARRAY_SIZE(ids); pjsua_enum_calls(ids, &count); if (count <= 1) { puts("There are no other calls"); return; } pjsua_call_get_info(current_call, &ci); printf("Transfer call [%d] %.*s to one of the following:\n", current_call, (int)ci.remote_info.slen, ci.remote_info.ptr); for (i=0; i<count; ++i) { pjsua_call_info call_info; if (ids[i] == call) continue; pjsua_call_get_info(ids[i], &call_info); printf("%d %.*s [%.*s]\n", ids[i], (int)call_info.remote_info.slen, call_info.remote_info.ptr, (int)call_info.state_text.slen, call_info.state_text.ptr); } if (!simple_input("Enter call number to be replaced", buf, sizeof(buf))) return; dst_call = my_atoi(buf); /* Check if call is still there. */ if (call != current_call) { puts("Call has been disconnected"); return; } /* Check that destination call is valid. */ if (dst_call == call) { puts("Destination call number must not be the same " "as the call being transferred"); return; } if (dst_call >= PJSUA_MAX_CALLS) { puts("Invalid destination call number"); return; } if (!pjsua_call_is_active(dst_call)) { puts("Invalid destination call number"); return; } pjsua_msg_data_init(&msg_data); if (no_refersub) { /* Add Refer-Sub: false in outgoing REFER request */ pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, &STR_FALSE); pj_list_push_back(&msg_data.hdr_list, &refer_sub); } pjsua_call_xfer_replaces(call, dst_call, PJSUA_XFER_NO_REQUIRE_REPLACES, &msg_data); } }