Commit be6d786b authored by Yann Diorcet's avatar Yann Diorcet

Add upnp call stats

parent ef0eb806
......@@ -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
}
......
......@@ -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;/**<Last RTCP packet sent, as a mblk_t structure. See oRTP documentation for details how to extract information from it*/
float round_trip_delay; /**<Round trip propagation time in seconds if known, -1 if unknown.*/
LinphoneIceState ice_state; /**< State of ICE processing. */
LinphoneUpnpState upnp_state; /**< State of uPnP processing. */
float download_bandwidth; /**<Download bandwidth measurement of received stream, expressed in kbit/s, including IP/UDP/RTP headers*/
float upload_bandwidth; /**<Download bandwidth measurement of sent stream, expressed in kbit/s, including IP/UDP/RTP headers*/
};
......
......@@ -576,11 +576,16 @@ int linphone_core_update_upnp(LinphoneCore *lc, LinphoneCall *call) {
return linphone_core_update_upnp_audio_video(call, call->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;
}
......
......@@ -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
This diff is collapsed.
......@@ -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){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment