static void linphonec_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState st, const char *msg){ char *from=linphone_call_get_remote_address_as_string(call); long id=(long)linphone_call_get_user_pointer (call); switch(st){ case LinphoneCallEnd: linphonec_out("Call %i with %s ended (%s).\n", id, from, linphone_reason_to_string(linphone_call_get_reason(call))); break; case LinphoneCallResuming: linphonec_out("Resuming call %i with %s.\n", id, from); break; case LinphoneCallStreamsRunning: linphonec_out("Media streams established with %s for call %i (%s).\n", from,id,( linphone_call_params_video_enabled( linphone_call_get_current_params(call)) ? "video":"audio")); break; case LinphoneCallPausing: linphonec_out("Pausing call %i with %s.\n", id, from); break; case LinphoneCallPaused: linphonec_out("Call %i with %s is now paused.\n", id, from); break; case LinphoneCallPausedByRemote: linphonec_out("Call %i has been paused by %s.\n",id,from); break; case LinphoneCallIncomingReceived: linphonec_call_identify(call); linphone_call_enable_camera (call,linphonec_camera_enabled); id=(long)linphone_call_get_user_pointer (call); linphonec_set_caller(from); if ( auto_answer) { answer_call=TRUE; } linphonec_out("Receiving new incoming call from %s, assigned id %i\n", from,id); break; case LinphoneCallOutgoingInit: linphonec_call_identify(call); id=(long)linphone_call_get_user_pointer (call); linphonec_out("Establishing call id to %s, assigned id %i\n", from,id); break; case LinphoneCallUpdatedByRemote: linphonec_call_updated(call); break; case LinphoneCallOutgoingProgress: linphonec_out("Call %i to %s in progress.\n", id, from); break; case LinphoneCallOutgoingRinging: linphonec_out("Call %i to %s ringing.\n", id, from); break; case LinphoneCallConnected: linphonec_out("Call %i with %s connected.\n", id, from); break; case LinphoneCallOutgoingEarlyMedia: linphonec_out("Call %i with %s early media.\n", id, from); break; case LinphoneCallError: linphonec_out("Call %i with %s error.\n", id, from); break; default: break; } ms_free(from); }
void linphone_gtk_update_video_button(LinphoneCall *call){ GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call); GtkWidget *button; const LinphoneCallParams *params=linphone_call_get_current_params(call); gboolean has_video=linphone_call_params_video_enabled(params); if (call_view==NULL) return; button=linphone_gtk_get_widget(call_view,"video_button"); gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(has_video ? GTK_STOCK_REMOVE : GTK_STOCK_ADD,GTK_ICON_SIZE_BUTTON)); g_object_set_data(G_OBJECT(button),"adding_video",GINT_TO_POINTER(!has_video)); if (!linphone_core_video_supported(linphone_call_get_core(call))){ gtk_widget_set_sensitive(button,FALSE); return; } if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"signal_connected"))==0){ g_signal_connect(G_OBJECT(button),"clicked",(GCallback)video_button_clicked,call); g_object_set_data(G_OBJECT(button),"signal_connected",GINT_TO_POINTER(1)); } GtkWidget *conf_frame=(GtkWidget *)g_object_get_data(G_OBJECT(linphone_gtk_get_main_window()),"conf_frame"); gtk_widget_set_sensitive(button,linphone_call_get_state(call)==LinphoneCallStreamsRunning); if(conf_frame!=NULL){ gtk_widget_set_sensitive(button,FALSE); } }
static void quality_reporting_session_report_if_video_stopped() { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneCall* call_pauline = NULL; LinphoneCall* call_marie = NULL; LinphoneCallParams* pauline_params; LinphoneCallParams* marie_params; linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, FALSE); marie_params=linphone_core_create_default_call_parameters(marie->lc); linphone_call_params_enable_video(marie_params,TRUE); pauline_params=linphone_core_create_default_call_parameters(pauline->lc); linphone_call_params_enable_video(pauline_params,TRUE); if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_local); CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0); CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0); CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000)); CU_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); /*remove video*/ linphone_call_params_enable_video(pauline_params,FALSE); linphone_core_update_call(pauline->lc,call_pauline,pauline_params); CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,5000)); CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,5000)); CU_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); linphone_core_terminate_all_calls(marie->lc); CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,2,5000)); CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,2,5000)); } linphone_call_params_destroy(marie_params); linphone_call_params_destroy(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
static bool_t media_report_enabled(LinphoneCall * call, int stats_type){ if (! quality_reporting_enabled(call)) return FALSE; if (stats_type == LINPHONE_CALL_STATS_VIDEO && !linphone_call_params_video_enabled(linphone_call_get_current_params(call))) return FALSE; return (call->log->reporting.reports[stats_type] != NULL); }
static void _refresh_call_stats(GtkWidget *callstats, LinphoneCall *call) { const LinphoneCallStats *as=linphone_call_get_audio_stats(call); const LinphoneCallStats *vs=linphone_call_get_video_stats(call); const char *audio_media_connectivity = _("Direct or through server"); const char *video_media_connectivity = _("Direct or through server"); const LinphoneCallParams *curparams=linphone_call_get_current_params(call); gboolean has_video=linphone_call_params_video_enabled(curparams); MSVideoSize size_received = linphone_call_params_get_received_video_size(curparams); MSVideoSize size_sent = linphone_call_params_get_sent_video_size(curparams); const char *rtp_profile = linphone_call_params_get_rtp_profile(curparams); gchar *tmp = g_strdup_printf("%s", rtp_profile); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"rtp_profile")),tmp); g_free(tmp); tmp=g_strdup_printf(_("download: %f\nupload: %f (kbit/s)"), as->download_bandwidth,as->upload_bandwidth); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"audio_bandwidth_usage")),tmp); g_free(tmp); if (has_video) { gchar *size_r=g_strdup_printf(_("%ix%i @ %f fps"),size_received.width,size_received.height, linphone_call_params_get_received_framerate(curparams)); gchar *size_s=g_strdup_printf(_("%ix%i @ %f fps"),size_sent.width,size_sent.height, linphone_call_params_get_sent_framerate(curparams)); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_size_recv")),size_r); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_size_sent")),size_s); tmp=g_strdup_printf(_("download: %f\nupload: %f (kbit/s)"),vs->download_bandwidth,vs->upload_bandwidth); g_free(size_r); g_free(size_s); } else { tmp=NULL; } gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_bandwidth_usage")),tmp); if (tmp) g_free(tmp); if(as->upnp_state != LinphoneUpnpStateNotAvailable && as->upnp_state != LinphoneUpnpStateIdle) { audio_media_connectivity = upnp_state_to_string(as->upnp_state); } else if(as->ice_state != LinphoneIceStateNotActivated) { audio_media_connectivity = ice_state_to_string(as->ice_state); } gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"audio_media_connectivity")),audio_media_connectivity); if (has_video) { if(vs->upnp_state != LinphoneUpnpStateNotAvailable && vs->upnp_state != LinphoneUpnpStateIdle) { video_media_connectivity = upnp_state_to_string(vs->upnp_state); } else if(vs->ice_state != LinphoneIceStateNotActivated) { video_media_connectivity = ice_state_to_string(vs->ice_state); } } else video_media_connectivity=NULL; gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_media_connectivity")),video_media_connectivity); if (as->round_trip_delay>0) { tmp=g_strdup_printf(_("%.3f seconds"),as->round_trip_delay); gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"round_trip_time")),tmp); g_free(tmp); } }
int Java_com_acsoftware_android_domophone_LibLP_nGetVideoEnabled(JNIEnv* env ,jobject thiz) { if ( Java_com_acsoftware_android_domophone_LibLP_nActiveCall(env, thiz) == 1 ) { if ( linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(lc))) ) { return 1; } else { return 0; } } return _VideoEnabled; }
void linphone_gtk_in_call_show_video(LinphoneCall *call){ GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call); GtkWidget *video_window=(GtkWidget*)g_object_get_data(G_OBJECT(callview),"video_window"); const LinphoneCallParams *params=linphone_call_get_current_params(call); LinphoneCore *lc=linphone_gtk_get_core(); if (((bool_t)lp_config_get_int(linphone_core_get_config(lc), "video", "rtp_io", FALSE)) == FALSE) { if (linphone_call_get_state(call)!=LinphoneCallPaused && params && linphone_call_params_video_enabled(params)){ if (video_window==NULL){ video_window=create_video_window(call); g_object_set_data(G_OBJECT(callview),"video_window",video_window); } linphone_core_set_native_video_window_id(lc,get_native_handle(gtk_widget_get_window(video_window))); gtk_window_present(GTK_WINDOW(video_window)); }else{ if (video_window){ gtk_widget_destroy(video_window); g_object_set_data(G_OBJECT(callview),"video_window",NULL); } } } }
static void _call_state(LinphoneCore *lc, LinphoneCall* call, LinphoneCallState state,const char* message) { JNIEnv *env = 0; if (jvm->AttachCurrentThread(&env,NULL) != 0) { ms_error("cannot attach VM\n"); return; } switch(state) { case LinphoneCallIncomingReceived: Java_com_acsoftware_android_domophone_LibLP_nSetVideoEnabled(env, NULL, _VideoEnabled ? JNI_TRUE : JNI_FALSE); Java_com_acsoftware_android_domophone_LibLP_nSetAudioEnabled(env, NULL, _AudioEnabled ? JNI_TRUE : JNI_FALSE); linphone_core_accept_call(lc, call); break; case LinphoneCallStreamsRunning: Java_com_acsoftware_android_domophone_LibLP_nSetAudioEnabled(env, NULL, _AudioEnabled ? JNI_TRUE : JNI_FALSE); CallMethod(env, "SipCallStarted"); if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) { // linphone_core_set_native_video_window_id(lc, (unsigned long)MainVC.videoFrame); // linphone_call_set_next_video_frame_decoded_callback(callptr, showVideoView, NULL); CallMethod(env, "ShowVideoWindow"); } break; case LinphoneCallError: case LinphoneCallEnd: case LinphoneCallReleased: CallMethod(env, "SipTerminate"); break; default: break; } }
static void linphonec_call_updated(LinphoneCall *call){ const LinphoneCallParams *cp=linphone_call_get_current_params(call); if (!linphone_call_camera_enabled (call) && linphone_call_params_video_enabled (cp)){ linphonec_out("Far end requests to share video.\nType 'camera on' if you agree.\n"); } }
bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state) { LinphoneCall *c1,*c2; bool_t audio_success=FALSE; bool_t video_success=FALSE; bool_t text_success=FALSE; bool_t video_enabled, realtime_text_enabled; MSTimeSpec ts; c1=linphone_core_get_current_call(caller->lc); c2=linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(c1); BC_ASSERT_PTR_NOT_NULL(c2); if (!c1 || !c2) return FALSE; linphone_call_ref(c1); linphone_call_ref(c2); BC_ASSERT_EQUAL(linphone_call_params_video_enabled(linphone_call_get_current_params(c1)),linphone_call_params_video_enabled(linphone_call_get_current_params(c2)), int, "%d"); BC_ASSERT_EQUAL(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)),linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c2)), int, "%d"); video_enabled=linphone_call_params_video_enabled(linphone_call_get_current_params(c1)); realtime_text_enabled=linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)); liblinphone_tester_clock_start(&ts); do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_audio_stats(c1)->ice_state==state && linphone_call_get_audio_stats(c2)->ice_state==state ){ audio_success=TRUE; check_ice_from_rtp(c1,c2,LinphoneStreamTypeAudio); check_ice_from_rtp(c2,c1,LinphoneStreamTypeAudio); break; } linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } ms_usleep(20000); }while(!liblinphone_tester_clock_elapsed(&ts,10000)); if (video_enabled){ liblinphone_tester_clock_start(&ts); do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_video_stats(c1)->ice_state==state && linphone_call_get_video_stats(c2)->ice_state==state ){ video_success=TRUE; check_ice_from_rtp(c1,c2,LinphoneStreamTypeVideo); check_ice_from_rtp(c2,c1,LinphoneStreamTypeVideo); break; } linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } ms_usleep(20000); }while(!liblinphone_tester_clock_elapsed(&ts,10000)); } if (realtime_text_enabled){ liblinphone_tester_clock_start(&ts); do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_text_stats(c1)->ice_state==state && linphone_call_get_text_stats(c2)->ice_state==state ){ text_success=TRUE; check_ice_from_rtp(c1,c2,LinphoneStreamTypeText); check_ice_from_rtp(c2,c1,LinphoneStreamTypeText); break; } linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } ms_usleep(20000); }while(!liblinphone_tester_clock_elapsed(&ts,10000)); } /*make sure encryption mode are preserved*/ if (c1) { const LinphoneCallParams* call_param = linphone_call_get_current_params(c1); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); } if (c2) { const LinphoneCallParams* call_param = linphone_call_get_current_params(c2); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(callee->lc), int, "%d"); } linphone_call_unref(c1); linphone_call_unref(c2); return video_enabled ? (realtime_text_enabled ? text_success && audio_success && video_success : audio_success && video_success) : realtime_text_enabled ? text_success && audio_success : audio_success; }
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); }
void CallStatsModel::updateStats(LinphoneCall *call) { if (!call) { return; } float quality = linphone_call_get_current_quality(call); if (quality >= 4) { _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_4.png"; } else if (quality >= 3) { _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_3.png"; } else if (quality >= 2) { _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_2.png"; } else if (quality >= 1) { _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_1.png"; } else { _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_0.png"; } const LinphoneCallParams *params = linphone_call_get_current_params(call); if (!params) { return; } LinphoneMediaEncryption encryption = linphone_call_params_get_media_encryption(params); _currentCallSecurityIcon = "/images/statusbar/security_ko.png"; if (encryption == LinphoneMediaEncryptionSRTP || encryption == LinphoneMediaEncryptionDTLS) { _currentCallSecurityIcon = "/images/statusbar/security_ok.png"; } else if (encryption == LinphoneMediaEncryptionZRTP) { _callSecurityToken = tr("ZRTP token is %1.\r\nYou should only accept if you have the same token as your correspondent.").arg(linphone_call_get_authentication_token(call)); bool isAuthTokenVerified = linphone_call_get_authentication_token_verified(call); if (isAuthTokenVerified) { _currentCallSecurityIcon = "/images/statusbar/security_ok.png"; } else { _currentCallSecurityIcon = "/images/statusbar/security_pending.png"; } emit zrtpUpdated(); } const LinphoneCallStats *audioStats = linphone_call_get_audio_stats(call); if (audioStats) { _iceStatus = IceStateToString(linphone_call_stats_get_ice_state(audioStats)); _downloadAudioBandwidth = QString("<html>↓ %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_download_bandwidth(audioStats))); _uploadAudioBandwidth = QString("<html>↑ %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_upload_bandwidth(audioStats))); } const LinphonePayloadType *audioPayload = linphone_call_params_get_used_audio_codec(params); if (audioPayload) { _audioCodec = QString(linphone_payload_type_get_mime_type(audioPayload)) + "/" + QString::number(payload_type_get_rate(audioPayload)) + "/" + QString::number(linphone_payload_type_get_channels(audioPayload)); } if (linphone_call_params_video_enabled(params)) { const LinphoneCallStats *videoStats = linphone_call_get_video_stats(call); if (videoStats) { _downloadVideoBandwidth = QString("<html>↓ %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_download_bandwidth(videoStats))); _uploadVideoBandwidth = QString("<html>↑ %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_upload_bandwidth(videoStats))); } const LinphonePayloadType *videoPayload = linphone_call_params_get_used_video_codec(params); if (videoPayload) { _videoCodec = QString(linphone_payload_type_get_mime_type(videoPayload)); } MSVideoSize sentVideoSize = linphone_call_params_get_sent_video_size(params); float framerate = linphone_call_params_get_sent_framerate(params); _sentVideoSize = QString("%1x%2 @ %3 fps").arg(QString::number(sentVideoSize.width), QString::number(sentVideoSize.height), QString::number((int)framerate)); MSVideoSize receivedVideoSize = linphone_call_params_get_received_video_size(params); framerate = linphone_call_params_get_received_framerate(params); _receivedVideoSize = QString("%1x%2 @ %3 fps").arg(QString::number(receivedVideoSize.width), QString::number(receivedVideoSize.height), QString::number((int)framerate)); } emit statsUpdated(); }