/** * \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 }
PJ_DECL(pj_status_t) vid_set_android_capturer(jobject window) { unsigned ci, i, count; pj_status_t status = PJ_ENOTFOUND; pjsua_call *call; pjsua_call_id calls_id[PJSUA_MAX_ACC]; count = PJ_ARRAY_SIZE(calls_id); status = pjsua_enum_calls(calls_id, &count); if(status != PJ_SUCCESS){ return status; } PJ_LOG(4, (THIS_FILE, "Setup android capturer for all calls")); PJSUA_LOCK(); for(ci = 0; ci < count; ++ci){ pjsua_call_id call_id = calls_id[ci]; if(pjsua_call_is_active(call_id) && pjsua_call_has_media(call_id)){ call = &pjsua_var.calls[call_id]; for (i = 0; i < call->med_cnt; ++i) { pjsua_call_media *call_med = &call->media[i]; vid_set_stream_window(call_med, PJMEDIA_DIR_CAPTURE, window); status = PJ_SUCCESS; } } } PJSUA_UNLOCK(); return status; }
pj_bool_t find_prev_call() { int i, max; max = pjsua_call_get_max_count(); for (i=current_call-1; i>=0; --i) { if (pjsua_call_is_active(i)) { current_call = i; return PJ_TRUE; } } for (i=max-1; i>current_call; --i) { if (pjsua_call_is_active(i)) { current_call = i; return PJ_TRUE; } } current_call = PJSUA_INVALID_ID; return PJ_FALSE; }
/* * Find next call when current call is disconnected or when user * press ']' */ pj_bool_t find_next_call() { int i, max; max = pjsua_call_get_max_count(); for (i=current_call+1; i<max; ++i) { if (pjsua_call_is_active(i)) { current_call = i; return PJ_TRUE; } } for (i=0; i<current_call; ++i) { if (pjsua_call_is_active(i)) { current_call = i; return PJ_TRUE; } } current_call = PJSUA_INVALID_ID; return PJ_FALSE; }
static void _ics_conference_call(ics_t *data, int call_id) { int i, max; PJ_UNUSED_ARG(data); max = pjsua_call_get_count(); SHOW_LOG(3, "Let's conference call!\n"); pjsua_call_info ci; #if 1 if ( (call_id != current_call) && pjsua_call_is_active(call_id) ) { pjsua_call_reinvite(call_id, PJ_TRUE, NULL); for (i = 0; i < max; i++) { if (pjsua_call_has_media(i) != 0) { pjsua_conf_connect(pjsua_call_get_conf_port(call_id), pjsua_call_get_conf_port(i)); pjsua_conf_connect(pjsua_call_get_conf_port(i), pjsua_call_get_conf_port(call_id)); } } } else SHOW_LOG(3, "Cannot transfer call!\n"); #endif //For test only: #if 1 for (i = 0; i < max; i++){ if (pjsua_call_is_active(i) && (i != current_call)) { pjsua_call_reinvite(i, PJ_TRUE, NULL); pjsua_call_get_info(i, &ci); pjsua_conf_connect(pjsua_call_get_conf_port(ci.id), pjsua_call_get_conf_port(current_call)); pjsua_conf_connect(pjsua_call_get_conf_port(current_call), pjsua_call_get_conf_port(ci.id)); } break; } #endif }
void _ics_core_list_call(ics_t *data) { int i, max; pjsua_call_info ci; max = pjsua_call_get_count(); printf("Your call list:\n"); for (i = 0; i < max; i++){ if (pjsua_call_is_active(i)) { pjsua_call_get_info(i, &ci); printf("Call id : %d to %.*s [%.*s]\n", ci.id, (int)ci.remote_info.slen, ci.remote_info.ptr, (int)ci.state_text.slen, ci.state_text.ptr); } } printf("Your current call id : %d\n", current_call); }
void _ics_list_call(ics_t *data) { int i, max; pjsua_call_info ci; PJ_UNUSED_ARG(data); max = pjsua_call_get_count(); SHOW_LOG(3, "Your call list:\n"); for (i = 0; i < max; i++){ if (pjsua_call_is_active(i)) { pjsua_call_get_info(i, &ci); SHOW_LOG(3, "Call id : %d to %.*s [%.*s]\n", ci.id, (int)ci.remote_info.slen, ci.remote_info.ptr, (int)ci.state_text.slen, ci.state_text.ptr); } } SHOW_LOG(3, "Your current call id : %d\n", current_call); }
static void ui_call_redirect(char menuin[]) { if (current_call == PJSUA_INVALID_ID) { PJ_LOG(3,(THIS_FILE, "No current call")); } else { if (!pjsua_call_is_active(current_call)) { PJ_LOG(1,(THIS_FILE, "Call %d has gone", current_call)); } else if (menuin[1] == 'a') { pjsua_call_process_redirect(current_call, PJSIP_REDIRECT_ACCEPT_REPLACE); } else if (menuin[1] == 'A') { pjsua_call_process_redirect(current_call, PJSIP_REDIRECT_ACCEPT); } else if (menuin[1] == 'r') { pjsua_call_process_redirect(current_call, PJSIP_REDIRECT_REJECT); } else { pjsua_call_process_redirect(current_call, PJSIP_REDIRECT_STOP); } } }
bool BlabbleCall::is_active() { return ((bool)CheckAndGetParent() && pjsua_call_is_active(call_id_)); }
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); } }