Commit d9ce543d authored by Simon Morlat's avatar Simon Morlat

quality indicator enhancement: make it use locally computed statistics every...

quality indicator enhancement: make it use locally computed statistics every seconds, so that its state reflects the quality in a more realtime manner.
parent f6c51a11
......@@ -142,6 +142,7 @@ struct _AudioStream
EchoLimiterType el_type; /*use echo limiter: two MSVolume, measured input level controlling local output level*/
MSQualityIndicator *qi;
time_t start_time;
time_t last_iterate_time;
uint32_t features;
bool_t play_dtmfs;
bool_t use_gc;
......
......@@ -128,6 +128,7 @@ static void audio_stream_process_rtcp(AudioStream *stream, mblk_t *m){
}
void audio_stream_iterate(AudioStream *stream){
time_t curtime=time(NULL);
if (stream->is_beginning && ms_time(NULL)-stream->start_time>15){
rtp_session_set_rtcp_report_interval(stream->ms.session,5000);
stream->is_beginning=FALSE;
......@@ -140,8 +141,6 @@ void audio_stream_iterate(AudioStream *stream){
audio_stream_process_rtcp(stream,ortp_event_get_data(ev)->packet);
stream->last_packet_time=ms_time(NULL);
}else if (evt==ORTP_EVENT_RTCP_PACKET_EMITTED){
/*we choose to update the quality indicator when the oRTP stack decides to emit a RTCP report */
if (stream->qi) ms_quality_indicator_update_local(stream->qi);
ms_message("audio_stream_iterate(): local statistics available\n\tLocal's current jitter buffer size:%f ms",rtp_session_get_jitter_stats(stream->ms.session)->jitter_buffer_size_ms);
}else if ((evt==ORTP_EVENT_STUN_PACKET_RECEIVED)&&(stream->ms.ice_check_list)){
ice_handle_stun_packet(stream->ms.ice_check_list,stream->ms.session,ortp_event_get_data(ev));
......@@ -150,6 +149,9 @@ void audio_stream_iterate(AudioStream *stream){
}
}
if (stream->ms.ice_check_list) ice_check_list_process(stream->ms.ice_check_list,stream->ms.session);
/*we choose to update the quality indicator as much as possible, since local statistics can be computed realtime. */
if (stream->qi && curtime>stream->last_iterate_time) ms_quality_indicator_update_local(stream->qi);
stream->last_iterate_time=curtime;
}
bool_t audio_stream_alive(AudioStream * stream, int timeout){
......
......@@ -36,7 +36,7 @@ struct _MSQualityIndicator{
float local_rating;
float remote_rating;
uint64_t last_packet_count;
uint32_t last_lost;
uint32_t last_ext_seq;
uint32_t last_late;
int count;
};
......@@ -114,6 +114,7 @@ void ms_quality_indicator_update_local(MSQualityIndicator *qi){
const rtp_stats_t *stats=rtp_session_get_stats(qi->session);
int lost,late,recvcnt;
float loss_rate=0,late_rate=0;
uint32_t ext_seq=rtp_session_get_rcv_ext_seq_number(qi->session);
recvcnt=stats->packet_recv-qi->last_packet_count;
if (recvcnt==0){
......@@ -121,17 +122,22 @@ void ms_quality_indicator_update_local(MSQualityIndicator *qi){
return;/* no information usable*/
}else if (recvcnt<0){
qi->last_packet_count=stats->packet_recv;
qi->last_ext_seq=ext_seq;
recvcnt=0; /*should not happen obviously*/
return;
}else if (qi->last_packet_count==0){
qi->last_ext_seq=ext_seq;
}
lost=stats->cum_packet_loss-qi->last_lost;
qi->last_lost=stats->cum_packet_loss;
lost=(ext_seq-qi->last_ext_seq) - (recvcnt);
qi->last_ext_seq=ext_seq;
qi->last_packet_count=stats->packet_recv;
late=stats->outoftime-qi->last_late;
qi->last_late=stats->outoftime;
qi->last_packet_count=stats->packet_recv;
if (lost<0) lost=0;
if (lost<0) lost=0; /* will be the case at least the first time, because we don't know the initial sequence number*/
if (late<0) late=0;
loss_rate=(float)lost/(float)recvcnt;
......
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