diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index f4525399b..eece911b4 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -286,6 +286,7 @@ void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall * #ifdef BUILD_UPNP if(call->upnp_session != NULL) { linphone_core_update_local_media_description_from_upnp(md, call->upnp_session); + linphone_core_update_upnp_state_in_call_stats(call); } #endif //BUILD_UPNP linphone_address_destroy(addr); @@ -421,6 +422,11 @@ void linphone_call_init_stats(LinphoneCallStats *stats, int type) { stats->received_rtcp = NULL; stats->sent_rtcp = NULL; stats->ice_state = LinphoneIceStateNotActivated; +#ifdef BUILD_UPNP + stats->upnp_state = LinphoneUpnpStateIdle; +#else + stats->upnp_state = LinphoneUpnpStateNotAvailable; +#endif //BUILD_UPNP } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 1003e9546..6af0bad34 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -284,6 +284,27 @@ enum _LinphoneIceState{ **/ typedef enum _LinphoneIceState LinphoneIceState; +/** + * Enum describing uPnP states. + * @ingroup initializing +**/ +enum _LinphoneUpnpState{ + LinphoneUpnpStateIdle, /**< uPnP is not activate */ + LinphoneUpnpStatePending, /**< uPnP process is in progress */ + LinphoneUpnpStateAdding, /**< Internal use: Only used by port binding */ + LinphoneUpnpStateRemoving, /**< Internal use: Only used by port binding */ + LinphoneUpnpStateNotAvailable, /**< uPnP is not available */ + LinphoneUpnpStateOk, /**< uPnP is enabled */ + LinphoneUpnpStateKo, /**< uPnP processing has failed */ +}; + +/** + * Enum describing uPnP states. + * @ingroup initializing +**/ +typedef enum _LinphoneUpnpState LinphoneUpnpState; + + /** * The LinphoneCallStats objects carries various statistic informations regarding quality of audio or video streams. * @@ -309,6 +330,7 @@ struct _LinphoneCallStats { mblk_t* sent_rtcp;/**audiostream!=NULL, call->videostream!=NULL); } +void linphone_core_update_upnp_state_in_call_stats(LinphoneCall *call) { + call->stats[LINPHONE_CALL_STATS_AUDIO].upnp_state = call->upnp_session->audio->state; + call->stats[LINPHONE_CALL_STATS_VIDEO].upnp_state = call->upnp_session->video->state; +} + int linphone_upnp_call_process(LinphoneCall *call) { LinphoneCore *lc = call->core; UpnpContext *lupnp = lc->upnp; int ret = -1; - LinphoneUpnpState oldState; + LinphoneUpnpState oldState, newState; if(lupnp == NULL) { return ret; @@ -644,6 +649,7 @@ int linphone_upnp_call_process(LinphoneCall *call) { } else { call->upnp_session->state = LinphoneUpnpStateIdle; } + newState = call->upnp_session->state; /* When change is done proceed update */ if(oldState != LinphoneUpnpStateOk && oldState != LinphoneUpnpStateKo && @@ -673,6 +679,14 @@ int linphone_upnp_call_process(LinphoneCall *call) { } ms_mutex_unlock(&lupnp->mutex); + + /* + * Update uPnP call stats + */ + if(oldState != newState) { + linphone_core_update_upnp_state_in_call_stats(call); + } + return ret; } diff --git a/coreapi/upnp.h b/coreapi/upnp.h index a98e15574..b3a5b9e49 100644 --- a/coreapi/upnp.h +++ b/coreapi/upnp.h @@ -24,16 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphonecore.h" #include "sal.h" -typedef enum { - LinphoneUpnpStateIdle, - LinphoneUpnpStatePending, // Only used by uPnP context - LinphoneUpnpStateAdding, // Only used by port binding - LinphoneUpnpStateRemoving, // Only used by port binding - LinphoneUpnpStateNotAvailable, // Only used by uPnP context - LinphoneUpnpStateOk, - LinphoneUpnpStateKo, -} LinphoneUpnpState; - typedef struct _UpnpSession UpnpSession; typedef struct _UpnpContext UpnpContext; @@ -50,5 +40,6 @@ UpnpContext *linphone_upnp_context_new(LinphoneCore *lc); void linphone_upnp_context_destroy(UpnpContext *ctx); LinphoneUpnpState linphone_upnp_context_get_state(UpnpContext *ctx); const char *linphone_upnp_context_get_external_ipaddress(UpnpContext *ctx); +void linphone_core_update_upnp_state_in_call_stats(LinphoneCall *call); #endif //LINPHONE_UPNP_H diff --git a/gtk/call_statistics.ui b/gtk/call_statistics.ui index 444710472..6ed8bd9bd 100644 --- a/gtk/call_statistics.ui +++ b/gtk/call_statistics.ui @@ -1,71 +1,34 @@ - + - False 5 Call statistics dialog - + True - False 2 - - - True - False - end - - - - - - gtk-close - True - True - True - False - True - - - False - False - 1 - - - - - False - True - end - 0 - - True - False 0 none True - False 12 True - False 6 2 True True - False Audio codec @@ -75,7 +38,6 @@ True - False Video codec @@ -87,7 +49,6 @@ True - False Audio IP bandwidth usage @@ -99,7 +60,6 @@ True - False 1 @@ -109,7 +69,6 @@ True - False 1 @@ -121,7 +80,6 @@ True - False 1 @@ -133,8 +91,7 @@ True - False - Media connectivity + Audio Media connectivity 4 @@ -143,15 +100,8 @@ - - - - - - - + True - False 1 @@ -163,7 +113,6 @@ True - False Video IP bandwidth usage @@ -175,7 +124,6 @@ True - False 1 @@ -184,6 +132,27 @@ 4 + + + True + Video Media connectivity + + + 5 + 6 + + + + + True + + + 1 + 2 + 5 + 6 + + @@ -191,7 +160,6 @@ True - False <b>Call statistics and information</b> True @@ -203,6 +171,34 @@ 1 + + + True + end + + + + + + gtk-close + True + True + True + True + + + False + False + 1 + + + + + False + end + 0 + + diff --git a/gtk/incall_view.c b/gtk/incall_view.c index 192e92fab..8bf19c19c 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -231,10 +231,29 @@ static const char *ice_state_to_string(LinphoneIceState ice_state){ return "invalid"; } +static const char *upnp_state_to_string(LinphoneUpnpState ice_state){ + switch(ice_state){ + case LinphoneUpnpStateIdle: + return _("uPnP not activated"); + case LinphoneUpnpStatePending: + return _("uPnP in progress"); + case LinphoneUpnpStateNotAvailable: + return _("uPnp not available"); + case LinphoneUpnpStateOk: + return _("uPnP is running"); + case LinphoneUpnpStateKo: + return _("uPnP failed"); + default: + break; + } + return "invalid"; +} + 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); - LinphoneIceState ice_state=as->ice_state; + const char *audio_media_connectivity = _("Direct"); + const char *video_media_connectivity = _("Direct"); gchar *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); @@ -243,7 +262,18 @@ static void _refresh_call_stats(GtkWidget *callstats, LinphoneCall *call){ vs->download_bandwidth,vs->upload_bandwidth); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_bandwidth_usage")),tmp); g_free(tmp); - gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"media_connectivity")),ice_state_to_string(ice_state)); + 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(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); + } + gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_media_connectivity")),video_media_connectivity); } static gboolean refresh_call_stats(GtkWidget *callstats){