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); } }
Linphone::Core::LinphoneCallStats::LinphoneCallStats(::LinphoneCall *call, Linphone::Core::MediaType mediaType) : call(call) { API_LOCK; const ::LinphoneCallStats *stats = nullptr; if (mediaType == Linphone::Core::MediaType::Audio) { stats = linphone_call_get_audio_stats(this->call); } else { stats = linphone_call_get_video_stats(this->call); } FillStats(stats); }
void check_rtcp(LinphoneCall *call) { MSTimeSpec ts; linphone_call_ref(call); liblinphone_tester_clock_start(&ts); do { if (linphone_call_get_audio_stats(call)->round_trip_delay > 0.0 && (!linphone_call_log_video_enabled(linphone_call_get_call_log(call)) || linphone_call_get_video_stats(call)->round_trip_delay > 0.0)) { break; } wait_for_until(call->core, NULL, NULL, 0, 20); /*just to sleep while iterating*/ } while (!liblinphone_tester_clock_elapsed(&ts, 15000)); BC_ASSERT_GREATER(linphone_call_get_audio_stats(call)->round_trip_delay, 0.0, float, "%f"); if (linphone_call_log_video_enabled(linphone_call_get_call_log(call))) { BC_ASSERT_GREATER(linphone_call_get_video_stats(call)->round_trip_delay, 0.0, float, "%f"); } linphone_call_unref(call); }
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 forked_outgoing_early_media_video_call_with_inactive_audio_test(void) { LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); LinphoneCoreManager *marie1 = linphone_core_manager_new("marie_early_rc"); LinphoneCoreManager *marie2 = linphone_core_manager_new("marie_early_rc"); MSList *lcs = NULL; LinphoneCallParams *pauline_params; LinphoneCallParams *marie1_params; LinphoneCallParams *marie2_params; LinphoneVideoPolicy pol; LinphoneCall *marie1_call; LinphoneCall *marie2_call; LinphoneCall *pauline_call; LinphoneInfoMessage *info; int dummy = 0; pol.automatically_accept = 1; pol.automatically_initiate = 1; linphone_core_enable_video(pauline->lc, TRUE, TRUE); linphone_core_enable_video(marie1->lc, TRUE, TRUE); linphone_core_set_video_policy(marie1->lc, &pol); linphone_core_enable_video(marie2->lc, TRUE, TRUE); linphone_core_set_video_policy(marie2->lc, &pol); linphone_core_set_audio_port_range(marie2->lc, 40200, 40300); linphone_core_set_video_port_range(marie2->lc, 40400, 40500); lcs = ms_list_append(lcs,marie1->lc); lcs = ms_list_append(lcs,marie2->lc); lcs = ms_list_append(lcs,pauline->lc); pauline_params = linphone_core_create_default_call_parameters(pauline->lc); linphone_call_params_enable_early_media_sending(pauline_params, TRUE); linphone_call_params_enable_video(pauline_params, TRUE); marie1_params = configure_for_early_media_video_receiving_with_inactive_audio(marie1); marie2_params = configure_for_early_media_video_receiving_with_inactive_audio(marie2); linphone_core_invite_address_with_params(pauline->lc, marie1->identity, pauline_params); linphone_call_params_destroy(pauline_params); BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1, 3000)); pauline_call = linphone_core_get_current_call(pauline->lc); marie1_call = linphone_core_get_current_call(marie1->lc); marie2_call = linphone_core_get_current_call(marie2->lc); BC_ASSERT_PTR_NOT_NULL(pauline_call); BC_ASSERT_PTR_NOT_NULL(marie1_call); BC_ASSERT_PTR_NOT_NULL(marie2_call); if (pauline_call && marie1_call && marie2_call) { /* wait a bit that streams are established */ wait_for_list(lcs, &dummy, 1, 6000); BC_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth == 0); BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth == 0); BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie2_call)->download_bandwidth == 0); BC_ASSERT_TRUE(linphone_call_get_video_stats(pauline_call)->download_bandwidth == 0); BC_ASSERT_TRUE(linphone_call_get_video_stats(marie1_call)->download_bandwidth > 0); BC_ASSERT_TRUE(linphone_call_get_video_stats(marie2_call)->download_bandwidth > 0); linphone_call_params_set_audio_direction(marie1_params, LinphoneMediaDirectionSendRecv); linphone_core_accept_call_with_params(marie1->lc, linphone_core_get_current_call(marie1->lc), marie1_params); BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallStreamsRunning, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1, 3000)); /* marie2 should get her call terminated */ BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallEnd, 1, 1000)); /*wait a bit that streams are established*/ wait_for_list(lcs, &dummy, 1, 3000); BC_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth > 71); BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth > 71); BC_ASSERT_TRUE(linphone_call_get_video_stats(pauline_call)->download_bandwidth > 0); BC_ASSERT_TRUE(linphone_call_get_video_stats(marie1_call)->download_bandwidth > 0); /* send an INFO in reverse side to check that dialogs are properly established */ info = linphone_core_create_info_message(marie1->lc); linphone_call_send_info_message(marie1_call, info); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_inforeceived, 1, 3000)); } linphone_core_terminate_all_calls(pauline->lc); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallEnd, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallEnd, 1, 3000)); linphone_call_params_destroy(marie1_params); linphone_call_params_destroy(marie2_params); ms_list_free(lcs); linphone_core_manager_destroy(marie1); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(pauline); }
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(); }
static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void) { LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); LinphoneCoreManager *marie1 = linphone_core_manager_new("marie_early_rc"); LinphoneCoreManager *marie2 = linphone_core_manager_new("marie_early_rc"); bctbx_list_t *lcs = NULL; LinphoneCallParams *pauline_params; LinphoneCallParams *marie1_params; LinphoneCallParams *marie2_params; LinphoneVideoPolicy pol; LinphoneCall *marie1_call; LinphoneCall *marie2_call; LinphoneCall *pauline_call; LinphoneInfoMessage *info; int dummy = 0; pol.automatically_accept = 1; pol.automatically_initiate = 1; linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, TRUE); linphone_core_enable_video_capture(marie1->lc, TRUE); linphone_core_enable_video_display(marie1->lc, TRUE); linphone_core_set_video_policy(marie1->lc, &pol); linphone_core_enable_video_capture(marie2->lc, TRUE); linphone_core_enable_video_display(marie2->lc, TRUE); linphone_core_set_video_policy(marie2->lc, &pol); linphone_core_set_audio_port_range(marie2->lc, 40200, 40300); linphone_core_set_video_port_range(marie2->lc, 40400, 40500); lcs = bctbx_list_append(lcs,marie1->lc); lcs = bctbx_list_append(lcs,marie2->lc); lcs = bctbx_list_append(lcs,pauline->lc); pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_early_media_sending(pauline_params, TRUE); linphone_call_params_enable_video(pauline_params, TRUE); marie1_params = configure_for_early_media_video_receiving_with_inactive_audio(marie1); marie2_params = configure_for_early_media_video_receiving_with_inactive_audio(marie2); linphone_core_invite_address_with_params(pauline->lc, marie1->identity, pauline_params); linphone_call_params_destroy(pauline_params); BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingReceived, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingReceived, 1, 3000)); marie1_call = linphone_core_get_current_call(marie1->lc); marie2_call = linphone_core_get_current_call(marie2->lc); if (marie1_call){ linphone_call_set_next_video_frame_decoded_callback(marie1_call, linphone_call_iframe_decoded_cb, marie1->lc); } if (marie2_call){ linphone_call_set_next_video_frame_decoded_callback(marie2_call, linphone_call_iframe_decoded_cb, marie2->lc); } BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1, 3000)); pauline_call = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(pauline_call); BC_ASSERT_PTR_NOT_NULL(marie1_call); BC_ASSERT_PTR_NOT_NULL(marie2_call); if (pauline_call && marie1_call && marie2_call) { linphone_call_set_next_video_frame_decoded_callback(pauline_call, linphone_call_iframe_decoded_cb, pauline->lc); /* wait a bit that streams are established */ wait_for_list(lcs, &dummy, 1, 3000); BC_ASSERT_EQUAL(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 0, float, "%f"); BC_ASSERT_EQUAL(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 0, float, "%f"); BC_ASSERT_EQUAL(linphone_call_get_audio_stats(marie2_call)->download_bandwidth, 0, float, "%f"); BC_ASSERT_LOWER(linphone_call_get_video_stats(pauline_call)->download_bandwidth, 11, float, "%f"); /* because of stun packets*/ BC_ASSERT_GREATER(linphone_call_get_video_stats(marie1_call)->download_bandwidth, 0, float, "%f"); BC_ASSERT_GREATER(linphone_call_get_video_stats(marie2_call)->download_bandwidth, 0, float, "%f"); BC_ASSERT_GREATER(marie1->stat.number_of_IframeDecoded, 1, int, "%i"); BC_ASSERT_GREATER(marie2->stat.number_of_IframeDecoded, 1, int, "%i"); linphone_call_params_set_audio_direction(marie1_params, LinphoneMediaDirectionSendRecv); linphone_core_accept_call_with_params(marie1->lc, linphone_core_get_current_call(marie1->lc), marie1_params); BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallStreamsRunning, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1, 3000)); /* marie2 should get her call terminated */ BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallEnd, 1, 1000)); /*wait a bit that streams are established*/ wait_for_list(lcs, &dummy, 1, 3000); BC_ASSERT_GREATER(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 71, float, "%f"); BC_ASSERT_GREATER(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 71, float, "%f"); BC_ASSERT_GREATER(linphone_call_get_video_stats(pauline_call)->download_bandwidth, 0, float, "%f"); BC_ASSERT_GREATER(linphone_call_get_video_stats(marie1_call)->download_bandwidth, 0, float, "%f"); BC_ASSERT_GREATER(pauline->stat.number_of_IframeDecoded, 1, int, "%i"); /* send an INFO in reverse side to check that dialogs are properly established */ info = linphone_core_create_info_message(marie1->lc); linphone_call_send_info_message(marie1_call, info); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_inforeceived, 1, 3000)); }