static void call_forking_declined(bool_t declined_globaly){ LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_tcp"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); MSList* lcs=ms_list_append(NULL,pauline->lc); lcs=ms_list_append(lcs,marie->lc); lcs=ms_list_append(lcs,marie2->lc); lcs=ms_list_append(lcs,marie3->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie3->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); linphone_core_invite_address(pauline->lc,marie->identity); /*pauline should hear ringback*/ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,3000)); /*all devices from Marie should be ringing*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallIncomingReceived,1,1000)); /*marie1 finally declines the call*/ linphone_core_decline_call(marie->lc,linphone_core_get_current_call(marie->lc), declined_globaly ? LinphoneReasonDeclined : LinphoneReasonBusy ); if (declined_globaly){ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); /*all devices should stop ringing*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,1000)); }else{ /*pauline should continue ringing and be able to hear a call taken by marie2 */ linphone_core_accept_call(marie2->lc, linphone_core_get_current_call(marie2->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,2000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,2000)); liblinphone_tester_check_rtcp(pauline,marie2); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,1000)); linphone_core_terminate_call(marie2->lc,linphone_core_get_current_call(marie2->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); } linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); ms_list_free(lcs); }
static void cb_call_state_changed (LinphoneCore *lc, LinphoneCall *call, LinphoneCallState st, const char *msg){ char *from; from = linphone_call_get_remote_address_as_string (call); switch (st) { case LinphoneCallEnd: ShowStatus ("Call with %s ended (%s).", from, linphone_reason_to_string (linphone_call_get_reason (call))); inCall = FALSE; if (argCallee) running = FALSE; break; case LinphoneCallStreamsRunning: printf ("I: Media streams established with %s (%s).\n", from, (linphone_call_params_video_enabled( linphone_call_get_current_params(call)) ? "video":"audio")); break; case LinphoneCallIncomingReceived: ShowStatus ("Receiving new incoming call from %s", from, NULL); linphone_call_enable_camera (call, TRUE); // necessary? if (inCall) linphone_core_decline_call (lc, call, LinphoneReasonBusy); else linphone_core_accept_call (lc, call); // TBD: must this call be moved outside this handler? break; case LinphoneCallOutgoingInit: ShowStatus ("Establishing call to %s", from, NULL); break; case LinphoneCallOutgoingProgress: ShowStatus ("Call to %s in progress.", from, NULL); break; case LinphoneCallOutgoingRinging: ShowStatus ("Call to %s ringing.", from, NULL); break; case LinphoneCallConnected: ShowStatus ("Connected to %s.", from, NULL); inCall = TRUE; break; case LinphoneCallOutgoingEarlyMedia: printf ("I: Call with %s early media.", from); break; case LinphoneCallError: ShowStatus ("Call error with %s.", from, NULL); if (argCallee) error = TRUE; break; /* case LinphoneCallUpdatedByRemote: printf ("### cb_call_state_changed: Call %i with %s updated.\n", id, from); cp = linphone_call_get_current_params(call); // TBD: auto-start camera? if (!linphone_call_camera_enabled (call) && linphone_call_params_video_enabled (cp)){ printf ("Far end requests to share video.\nType 'camera on' if you agree.\n"); } break; case LinphoneCallPausing: printf ("### cb_call_state_changed: Pausing call %i with %s.\n", id, from); break; case LinphoneCallPaused: printf ("### cb_call_state_changed: Call %i with %s is now paused.\n", id, from); break; case LinphoneCallPausedByRemote: printf ("### cb_call_state_changed: Call %i has been paused by %s.\n",id,from); break; case LinphoneCallResuming: printf ("### cb_call_state_changed: Resuming call %i with %s.\n", id, from); break; */ default: break; } ms_free(from); }