mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 07:08:11 +00:00
Add upnp call stats
This commit is contained in:
parent
ef0eb806a7
commit
be6d786ba2
6 changed files with 129 additions and 70 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,71 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.24"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkDialog" id="call_statistics">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">Call statistics</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<signal name="response" handler="linphone_gtk_call_statistics_closed" swapped="no"/>
|
||||
<signal name="response" handler="linphone_gtk_call_statistics_closed"/>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkTable" id="table1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="n_rows">6</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="audio_codec_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Audio codec</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
|
@ -75,7 +38,6 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="video_codec_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Video codec</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
|
@ -87,7 +49,6 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Audio IP bandwidth usage</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
|
@ -99,7 +60,6 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="audio_codec">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
|
@ -109,7 +69,6 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="video_codec">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
|
@ -121,7 +80,6 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="audio_bandwidth_usage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
|
@ -133,8 +91,7 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Media connectivity</property>
|
||||
<property name="label" translatable="yes">Audio Media connectivity</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
|
|
@ -143,15 +100,8 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="media_connectivity">
|
||||
<object class="GtkLabel" id="audio_media_connectivity">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
|
@ -163,7 +113,6 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Video IP bandwidth usage</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
|
@ -175,7 +124,6 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="video_bandwidth_usage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
|
@ -184,6 +132,27 @@
|
|||
<property name="bottom_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Video Media connectivity</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="video_media_connectivity">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
@ -191,7 +160,6 @@
|
|||
<child type="label">
|
||||
<object class="GtkLabel" id="call_statistics_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"><b>Call statistics and information</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
|
|
@ -203,6 +171,34 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue