Commit f0c7dbd1 authored by Ghislain MARY's avatar Ghislain MARY

Merge branch 'master' of git.linphone.org:linphone into belle-sip

parents a0b65209 9bf21045
......@@ -1880,9 +1880,13 @@ void linphone_call_delete_upnp_session(LinphoneCall *call){
}
#endif //BUILD_UPNP
static void linphone_call_log_fill_stats(LinphoneCallLog *log, AudioStream *st){
audio_stream_get_local_rtp_stats (st,&log->local_stats);
log->quality=audio_stream_get_average_quality_rating(st);
static void linphone_call_log_fill_stats(LinphoneCallLog *log, MediaStream *st){
float quality=media_stream_get_average_quality_rating(st);
if (quality>=0){
if (log->quality!=-1){
log->quality*=quality/5.0;
}else log->quality=quality;
}
}
void linphone_call_stop_audio_stream(LinphoneCall *call) {
......@@ -1900,7 +1904,8 @@ void linphone_call_stop_audio_stream(LinphoneCall *call) {
lp_config_set_string(call->core->config,"sound","ec_state",state_str);
}
}
linphone_call_log_fill_stats (call->log,call->audiostream);
audio_stream_get_local_rtp_stats(call->audiostream,&call->log->local_stats);
linphone_call_log_fill_stats (call->log,(MediaStream*)call->audiostream);
if (call->endpoint){
linphone_call_remove_from_conf(call);
}
......@@ -1916,6 +1921,7 @@ void linphone_call_stop_video_stream(LinphoneCall *call) {
ortp_ev_queue_flush(call->videostream_app_evq);
ortp_ev_queue_destroy(call->videostream_app_evq);
call->videostream_app_evq=NULL;
linphone_call_log_fill_stats(call->log,(MediaStream*)call->videostream);
video_stream_stop(call->videostream);
call->videostream=NULL;
}
......@@ -2034,10 +2040,20 @@ float linphone_call_get_record_volume(LinphoneCall *call){
* active audio stream exist. Otherwise it returns the quality rating.
**/
float linphone_call_get_current_quality(LinphoneCall *call){
float audio_rating=-1;
float video_rating=-1;
float result;
if (call->audiostream){
return audio_stream_get_quality_rating(call->audiostream);
audio_rating=media_stream_get_quality_rating((MediaStream*)call->audiostream)/5.0;
}
return -1;
if (call->videostream){
video_rating=media_stream_get_quality_rating((MediaStream*)call->videostream)/5.0;
}
if (audio_rating<0 && video_rating<0) result=-1;
else if (audio_rating<0) result=video_rating*5.0;
else if (video_rating<0) result=audio_rating*5.0;
else result=audio_rating*video_rating*5.0;
return result;
}
/**
......@@ -2052,18 +2068,34 @@ float linphone_call_get_average_quality(LinphoneCall *call){
return -1;
}
static void update_local_stats(LinphoneCallStats *stats, MediaStream *stream){
const MSQualityIndicator *qi=media_stream_get_quality_indicator(stream);
if (qi) {
stats->local_late_rate=ms_quality_indicator_get_local_late_rate(qi);
stats->local_loss_rate=ms_quality_indicator_get_local_loss_rate(qi);
}
}
/**
* Access last known statistics for audio stream, for a given call.
**/
const LinphoneCallStats *linphone_call_get_audio_stats(const LinphoneCall *call) {
return &call->stats[LINPHONE_CALL_STATS_AUDIO];
const LinphoneCallStats *linphone_call_get_audio_stats(LinphoneCall *call) {
LinphoneCallStats *stats=&call->stats[LINPHONE_CALL_STATS_AUDIO];
if (call->audiostream){
update_local_stats(stats,(MediaStream*)call->audiostream);
}
return stats;
}
/**
* Access last known statistics for video stream, for a given call.
**/
const LinphoneCallStats *linphone_call_get_video_stats(const LinphoneCall *call) {
return &call->stats[LINPHONE_CALL_STATS_VIDEO];
const LinphoneCallStats *linphone_call_get_video_stats(LinphoneCall *call) {
LinphoneCallStats *stats=&call->stats[LINPHONE_CALL_STATS_VIDEO];
if (call->videostream){
update_local_stats(stats,(MediaStream*)call->videostream);
}
return stats;
}
/**
......@@ -2267,6 +2299,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
freemsg(call->stats[LINPHONE_CALL_STATS_VIDEO].received_rtcp);
call->stats[LINPHONE_CALL_STATS_VIDEO].received_rtcp = evd->packet;
evd->packet = NULL;
update_local_stats(&call->stats[LINPHONE_CALL_STATS_VIDEO],(MediaStream*)call->videostream);
if (lc->vtable.call_stats_updated)
lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_VIDEO]);
} else if (evt == ORTP_EVENT_RTCP_PACKET_EMITTED) {
......@@ -2275,6 +2308,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
freemsg(call->stats[LINPHONE_CALL_STATS_VIDEO].sent_rtcp);
call->stats[LINPHONE_CALL_STATS_VIDEO].sent_rtcp = evd->packet;
evd->packet = NULL;
update_local_stats(&call->stats[LINPHONE_CALL_STATS_VIDEO],(MediaStream*)call->videostream);
if (lc->vtable.call_stats_updated)
lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_VIDEO]);
} else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED)
......@@ -2308,6 +2342,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
freemsg(call->stats[LINPHONE_CALL_STATS_AUDIO].received_rtcp);
call->stats[LINPHONE_CALL_STATS_AUDIO].received_rtcp = evd->packet;
evd->packet = NULL;
update_local_stats(&call->stats[LINPHONE_CALL_STATS_AUDIO],(MediaStream*)call->audiostream);
if (lc->vtable.call_stats_updated)
lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_AUDIO]);
} else if (evt == ORTP_EVENT_RTCP_PACKET_EMITTED) {
......@@ -2316,6 +2351,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
freemsg(call->stats[LINPHONE_CALL_STATS_AUDIO].sent_rtcp);
call->stats[LINPHONE_CALL_STATS_AUDIO].sent_rtcp = evd->packet;
evd->packet = NULL;
update_local_stats(&call->stats[LINPHONE_CALL_STATS_AUDIO],(MediaStream*)call->audiostream);
if (lc->vtable.call_stats_updated)
lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_AUDIO]);
} else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED)
......
......@@ -122,6 +122,7 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *fro
cl->from=from;
cl->to=to;
cl->status=LinphoneCallAborted; /*default status*/
cl->quality=-1;
return cl;
}
......@@ -412,10 +413,29 @@ const LinphoneAddress *linphone_core_get_current_call_remote_address(struct _Lin
return linphone_call_get_remote_address(call);
}
void linphone_core_set_log_handler(OrtpLogFunc logfunc) {
ortp_set_log_handler(logfunc);
}
void linphone_core_set_log_file(FILE *file) {
if (file == NULL) file = stdout;
ortp_set_log_file(file);
}
void linphone_core_set_log_level(OrtpLogLevel loglevel) {
ortp_set_log_level_mask(loglevel);
if (loglevel == 0) {
sal_disable_logs();
} else {
sal_enable_logs();
}
}
/**
* Enable logs in supplied FILE*.
*
* @ingroup misc
* @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead.
*
* @param file a C FILE* where to fprintf logs. If null stdout is used.
*
......@@ -431,6 +451,7 @@ void linphone_core_enable_logs(FILE *file){
* Enable logs through the user's supplied log callback.
*
* @ingroup misc
* @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead.
*
* @param logfunc The address of a OrtpLogFunc callback whose protoype is
* typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
......@@ -446,6 +467,7 @@ void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){
* Entirely disable logging.
*
* @ingroup misc
* @deprecated Use #linphone_core_set_log_level instead.
**/
void linphone_core_disable_logs(){
ortp_set_log_level_mask(ORTP_ERROR|ORTP_FATAL);
......@@ -472,7 +494,7 @@ static void net_config_read (LinphoneCore *lc)
linphone_core_set_firewall_policy(lc,tmp);
tmp=lp_config_get_int(lc->config,"net","nat_sdp_only",0);
lc->net_conf.nat_sdp_only=tmp;
tmp=lp_config_get_int(lc->config,"net","mtu",0);
tmp=lp_config_get_int(lc->config,"net","mtu",1300);
linphone_core_set_mtu(lc,tmp);
tmp=lp_config_get_int(lc->config,"net","download_ptime",0);
linphone_core_set_download_ptime(lc,tmp);
......@@ -1204,6 +1226,7 @@ static void misc_config_read (LinphoneCore *lc) {
LpConfig *config=lc->config;
lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",15);
lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS);
linphone_core_set_log_level((OrtpLogLevel)lp_config_get_int(config,"misc","log_level",0));
}
......@@ -2164,9 +2187,13 @@ void linphone_core_iterate(LinphoneCore *lc){
lc->initial_subscribes_sent=TRUE;
}
if (one_second_elapsed && lp_config_needs_commit(lc->config)){
lp_config_sync(lc->config);
}
if (one_second_elapsed) {
if (ortp_get_log_level_mask() != lp_config_get_int(lc->config, "misc", "log_level", 0)) {
lp_config_set_int(lc->config, "misc", "log_level", ortp_get_log_level_mask());
}
if (lp_config_needs_commit(lc->config)) {
lp_config_sync(lc->config);
}
}
/**
......
......@@ -347,14 +347,16 @@ struct _LinphoneCallStats {
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*/
float local_late_rate; /**<percentage of packet received too late over last second*/
float local_loss_rate; /**<percentage of lost packet over last second*/
};
/**
* @}
**/
const LinphoneCallStats *linphone_call_get_audio_stats(const LinphoneCall *call);
const LinphoneCallStats *linphone_call_get_video_stats(const LinphoneCall *call);
const LinphoneCallStats *linphone_call_get_audio_stats(LinphoneCall *call);
const LinphoneCallStats *linphone_call_get_video_stats(LinphoneCall *call);
/** Callback prototype */
......@@ -883,8 +885,37 @@ typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *contex
/* THE main API */
LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file);
LINPHONE_PUBLIC void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
/**
* Define a log handler.
*
* @ingroup misc
*
* @param logfunc The function pointer of the log handler.
*/
void linphone_core_set_log_handler(OrtpLogFunc logfunc);
/**
* Define a log file.
*
* @ingroup misc
*
* If the file pointer passed as an argument is NULL, stdout is used instead.
*
* @param file A pointer to the FILE structure of the file to write to.
*/
void linphone_core_set_log_file(FILE *file);
/**
* Define the log level.
*
* @ingroup misc
*
* The loglevel parameter is a bitmask parameter. Therefore to enable only warning and error
* messages, use ORTP_WARNING | ORTP_ERROR. To disable logs, simply set loglevel to 0.
*
* @param loglevel A bitmask of the log levels to set.
*/
void linphone_core_set_log_level(OrtpLogLevel loglevel);
LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file);
LINPHONE_PUBLIC void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
void linphone_core_disable_logs(void);
const char *linphone_core_get_version(void);
const char *linphone_core_get_user_agent_name(void);
......
......@@ -1578,6 +1578,23 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSi
return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
}
extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLossRate(JNIEnv *env, jobject thiz,jlong stats_ptr) {
const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
return stats->local_loss_rate;
}
extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLateRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
return stats->local_late_rate;
}
extern "C" void Java_org_linphone_core_LinphoneCallStatsImpl_updateStats(JNIEnv *env, jobject thiz, jlong call_ptr, jint mediatype) {
if (mediatype==LINPHONE_CALL_STATS_AUDIO)
linphone_call_get_audio_stats((LinphoneCall*)call_ptr);
else
linphone_call_get_video_stats((LinphoneCall*)call_ptr);
}
/*payloadType*/
extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
PayloadType* pt = (PayloadType*)ptr;
......@@ -1702,7 +1719,6 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNI
return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
}
//LinphoneFriend
extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
,jobject thiz
......
......@@ -121,25 +121,25 @@ public interface LinphoneCallStats {
public float getUploadBandwidth();
/**
* Get the sender loss rate since last report
* Get the local loss rate since last report
* @return The sender loss rate
*/
public float getSenderLossRate();
/**
* Get the receiver loss rate since last report
* Get the remote reported loss rate since last report
* @return The receiver loss rate
*/
public float getReceiverLossRate();
/**
* Get the sender interarrival jitter
* Get the local interarrival jitter
* @return The interarrival jitter at last emitted sender report
*/
public float getSenderInterarrivalJitter();
/**
* Get the receiver interarrival jitter
* Get the remote reported interarrival jitter
* @return The interarrival jitter at last received receiver report
*/
public float getReceiverInterarrivalJitter();
......@@ -161,4 +161,16 @@ public interface LinphoneCallStats {
* @return The jitter buffer size in milliseconds
*/
public float getJitterBufferSize();
/**
* Get the local loss rate. Unlike getSenderLossRate() that returns this loss rate "since last emitted RTCP report", the value returned here is updated every second.
* @return The local loss rate percentage.
**/
public float getLocalLossRate();
/**
* Get the local late packets rate. The value returned here is updated every second.
* @return The local late rate percentage.
**/
public float getLocalLateRate();
}
......@@ -68,9 +68,11 @@ class LinphoneCallImpl implements LinphoneCall {
videoStats = stats;
}
public LinphoneCallStats getAudioStats() {
if (audioStats!=null) ((LinphoneCallStatsImpl)audioStats).updateRealTimeStats(this);
return audioStats;
}
public LinphoneCallStats getVideoStats() {
if (videoStats!=null) ((LinphoneCallStatsImpl)videoStats).updateRealTimeStats(this);
return videoStats;
}
public CallDirection getDirection() {
......
......@@ -31,6 +31,9 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
private float roundTripDelay;
private long latePacketsCumulativeNumber;
private float jitterBufferSize;
private float localLossRate;
private float localLateRate;
private long nativePtr;
private native int getMediaType(long nativeStatsPtr);
private native int getIceState(long nativeStatsPtr);
......@@ -43,8 +46,12 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
private native float getRoundTripDelay(long nativeStatsPtr);
private native long getLatePacketsCumulativeNumber(long nativeStatsPtr, long nativeCallPtr);
private native float getJitterBufferSize(long nativeStatsPtr);
private native float getLocalLossRate(long nativeStatsPtr);
private native float getLocalLateRate(long nativeStatsPtr);
private native void updateStats(long nativeCallPtr, int mediaType);
protected LinphoneCallStatsImpl(long nativeCallPtr, long nativeStatsPtr) {
nativePtr=nativeStatsPtr;
mediaType = getMediaType(nativeStatsPtr);
iceState = getIceState(nativeStatsPtr);
downloadBandwidth = getDownloadBandwidth(nativeStatsPtr);
......@@ -56,6 +63,13 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
roundTripDelay = getRoundTripDelay(nativeStatsPtr);
latePacketsCumulativeNumber = getLatePacketsCumulativeNumber(nativeStatsPtr, nativeCallPtr);
jitterBufferSize = getJitterBufferSize(nativeStatsPtr);
}
protected void updateRealTimeStats(LinphoneCall call){
updateStats( ((LinphoneCallImpl)call).nativePtr, mediaType);
localLossRate=getLocalLossRate(nativePtr);
localLateRate=getLocalLateRate(nativePtr);
}
public MediaType getMediaType() {
......@@ -101,4 +115,12 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
public float getJitterBufferSize() {
return jitterBufferSize;
}
public float getLocalLossRate(){
return localLossRate;
}
public float getLocalLateRate(){
return localLateRate;
}
}
mediastreamer2 @ 4f93003c
Subproject commit d9ce543dee40d7cb7da55e50c6716a25f53ea2ba
Subproject commit 4f93003c1eade1442fdedd8dee10f18c98ec47c3
oRTP @ 9f51aa25
Subproject commit 35f5efbfbf7814bd0403249431a6b94d6c4286b4
Subproject commit 9f51aa254fc5c24834614612036485406a8d06a7
This diff is collapsed.
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