Commit 1cdbfc4d authored by Simon Morlat's avatar Simon Morlat

better bandwidth computations

parent 13d0cee3
......@@ -125,9 +125,6 @@ struct _MediaStream {
* */
int target_bitrate;
media_stream_process_rtcp process_rtcp;
float up_bw; /*computed upload bw*/
float down_bw; /*computed upload bw*/
time_t last_bw_sampling_time;
};
......
......@@ -346,7 +346,6 @@ static void _sender_process(MSFilter * f)
{
SenderData *d = (SenderData *) f->data;
RtpSession *s = d->session;
mblk_t *im;
uint32_t timestamp;
......@@ -398,7 +397,8 @@ static void _sender_process(MSFilter * f)
send_stun_packet(s);
}
}
/*every second, compute output bandwidth*/
if (f->ticker->time % 1000 == 0) rtp_session_compute_send_bandwidth(d->session);
ms_filter_unlock(f);
}
......@@ -588,6 +588,8 @@ static void receiver_process(MSFilter * f)
rtp_get_payload(m,&m->b_rptr);
ms_queue_put(f->outputs[0], m);
}
/*every second compute recv bandwidth*/
if (f->ticker->time % 1000 == 0) rtp_session_compute_recv_bandwidth(d->session);
}
static MSFilterMethod receiver_methods[] = {
......
......@@ -469,12 +469,7 @@ void media_stream_iterate(MediaStream *stream){
rtp_session_set_rtcp_report_interval(stream->sessions.rtp_session,5000);
stream->is_beginning=FALSE;
}
if ((curtime-stream->last_bw_sampling_time)>=1) {
/*update bandwidth stat every second more or less*/
stream->up_bw=rtp_session_compute_send_bandwidth(stream->sessions.rtp_session);
stream->down_bw=rtp_session_compute_recv_bandwidth(stream->sessions.rtp_session);
stream->last_bw_sampling_time=curtime;
}
if (stream->ice_check_list) ice_check_list_process(stream->ice_check_list,stream->sessions.rtp_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);
......@@ -536,11 +531,11 @@ int media_stream_get_target_network_bitrate(const MediaStream *stream) {
}
float media_stream_get_up_bw(const MediaStream *stream) {
return stream->up_bw;
return rtp_session_get_send_bandwidth(stream->sessions.rtp_session);
}
float media_stream_get_down_bw(const MediaStream *stream) {
return stream->down_bw;
return rtp_session_get_recv_bandwidth(stream->sessions.rtp_session);
}
void media_stream_reclaim_sessions(MediaStream *stream, MSMediaStreamSessions *sessions){
......
......@@ -871,10 +871,10 @@ void mediastream_run_loop(MediastreamDatas* args) {
rtp_stats_display(rtp_session_get_stats(args->session),"RTP stats");
if (args->session){
ms_message("Bandwidth usage: download=%f kbits/sec, upload=%f kbits/sec\n",
rtp_session_compute_recv_bandwidth(args->session)*1e-3,
rtp_session_compute_send_bandwidth(args->session)*1e-3);
rtp_session_get_recv_bandwidth(args->session)*1e-3,
rtp_session_get_send_bandwidth(args->session)*1e-3);
parse_events(args->session,args->q);
ms_message("Quality indicator : %f\n",args->audio ? audio_stream_get_quality_rating(args->audio) : -1);
ms_message("Quality indicator : %f\n",args->audio ? audio_stream_get_quality_rating(args->audio) : media_stream_get_quality_rating((MediaStream*)args->video));
}
}
}
......
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