Commit ec031d72 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

Store analyser type (simple/stateful) in generic QoSanalyser struct

parent 11b0bec6
...@@ -100,6 +100,11 @@ struct _MSQosAnalyserDesc{ ...@@ -100,6 +100,11 @@ struct _MSQosAnalyserDesc{
struct _MSQosAnalyser{ struct _MSQosAnalyser{
MSQosAnalyserDesc *desc; MSQosAnalyserDesc *desc;
int refcnt; int refcnt;
enum {
Simple,
Stateful,
} type;
}; };
...@@ -185,6 +190,7 @@ MSBitrateController *ms_audio_bitrate_controller_new(RtpSession *session, MSFilt ...@@ -185,6 +190,7 @@ MSBitrateController *ms_audio_bitrate_controller_new(RtpSession *session, MSFilt
**/ **/
MSBitrateController *ms_av_bitrate_controller_new(RtpSession *asession, MSFilter *aenc, RtpSession *vsession, MSFilter *venc); MSBitrateController *ms_av_bitrate_controller_new(RtpSession *asession, MSFilter *aenc, RtpSession *vsession, MSFilter *venc);
MSBitrateController *ms_bandwidth_bitrate_controller_new(RtpSession *asession, MSFilter *aenc, RtpSession *vsession, MSFilter *venc);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -130,7 +130,7 @@ struct _MediaStream { ...@@ -130,7 +130,7 @@ struct _MediaStream {
bool_t use_rc; bool_t use_rc;
bool_t is_beginning; bool_t is_beginning;
bool_t owns_sessions; bool_t owns_sessions;
bool_t pad[1]; bool_t pad;
/** /**
* defines encoder target network bit rate, uses #media_stream_set_target_network_bitrate() setter. * defines encoder target network bit rate, uses #media_stream_set_target_network_bitrate() setter.
* */ * */
......
...@@ -192,6 +192,7 @@ set(VOIP_SOURCE_FILES ...@@ -192,6 +192,7 @@ set(VOIP_SOURCE_FILES
voip/msvoip.c voip/msvoip.c
voip/private.h voip/private.h
voip/qosanalyzer.c voip/qosanalyzer.c
voip/qosanalyzer.h
voip/qualityindicator.c voip/qualityindicator.c
voip/ringstream.c voip/ringstream.c
) )
......
...@@ -65,7 +65,7 @@ libmediastreamer_voip_la_SOURCES+= voip/private.h \ ...@@ -65,7 +65,7 @@ libmediastreamer_voip_la_SOURCES+= voip/private.h \
voip/qualityindicator.c \ voip/qualityindicator.c \
voip/audioconference.c \ voip/audioconference.c \
voip/bitratedriver.c \ voip/bitratedriver.c \
voip/qosanalyzer.c \ voip/qosanalyzer.c voip/qosanalyzer.h \
voip/bitratecontrol.c voip/bitratecontrol.c
else else
libmediastreamer_base_la_SOURCES+= ortp-deps/logging.c \ libmediastreamer_base_la_SOURCES+= ortp-deps/logging.c \
......
...@@ -147,4 +147,9 @@ MSBitrateController *ms_av_bitrate_controller_new(RtpSession *asession, MSFilter ...@@ -147,4 +147,9 @@ MSBitrateController *ms_av_bitrate_controller_new(RtpSession *asession, MSFilter
ms_av_bitrate_driver_new(asession, aenc, vsession, venc)); ms_av_bitrate_driver_new(asession, aenc, vsession, venc));
} }
MSBitrateController *ms_bandwidth_bitrate_controller_new(RtpSession *asession, MSFilter *aenc, RtpSession *vsession, MSFilter *venc){
return ms_bitrate_controller_new(
ms_stateful_qos_analyser_new(vsession),
ms_bandwidth_bitrate_driver_new(aenc,venc));
}
...@@ -191,6 +191,7 @@ MSQosAnalyser * ms_simple_qos_analyser_new(RtpSession *session){ ...@@ -191,6 +191,7 @@ MSQosAnalyser * ms_simple_qos_analyser_new(RtpSession *session){
MSSimpleQosAnalyser *obj=ms_new0(MSSimpleQosAnalyser,1); MSSimpleQosAnalyser *obj=ms_new0(MSSimpleQosAnalyser,1);
obj->session=session; obj->session=session;
obj->parent.desc=&simple_analyser_desc; obj->parent.desc=&simple_analyser_desc;
obj->parent.type=Simple;
return (MSQosAnalyser*)obj; return (MSQosAnalyser*)obj;
} }
...@@ -359,7 +360,10 @@ static float compute_available_bw(MSStatefulQosAnalyser *obj){ ...@@ -359,7 +360,10 @@ static float compute_available_bw(MSStatefulQosAnalyser *obj){
} }
} }
if (obj->network_state == MSQosAnalyserNetworkFine){ if (obj->network_state == MSQosAnalyserNetworkFine){
lossy_network |= (y_mean > .1 && obj->points[last][1] > y_mean / 2.);
if (lossy_network) { if (lossy_network) {
/*since congestion may loss a high number of packets, stay in congested network while /*since congestion may loss a high number of packets, stay in congested network while
this is not a bit more stable*/ this is not a bit more stable*/
...@@ -469,15 +473,6 @@ static bool_t stateful_analyser_has_improved(MSQosAnalyser *objbase){ ...@@ -469,15 +473,6 @@ static bool_t stateful_analyser_has_improved(MSQosAnalyser *objbase){
return FALSE; return FALSE;
} }
MSQosAnalyserNetworkState ms_qos_analyser_get_network_state(const MSQosAnalyser *objbase){
if (objbase && sizeof(*objbase) == sizeof(MSStatefulQosAnalyser)){
MSStatefulQosAnalyser *obj=(MSStatefulQosAnalyser*)objbase;
return obj->network_state;
}else{
return MSQosAnalyserNetworkFine;
}
}
static MSQosAnalyserDesc stateful_analyser_desc={ static MSQosAnalyserDesc stateful_analyser_desc={
stateful_analyser_process_rtcp, stateful_analyser_process_rtcp,
stateful_analyser_suggest_action, stateful_analyser_suggest_action,
...@@ -488,6 +483,7 @@ MSQosAnalyser * ms_stateful_qos_analyser_new(RtpSession *session){ ...@@ -488,6 +483,7 @@ MSQosAnalyser * ms_stateful_qos_analyser_new(RtpSession *session){
MSStatefulQosAnalyser *obj=ms_new0(MSStatefulQosAnalyser,1); MSStatefulQosAnalyser *obj=ms_new0(MSStatefulQosAnalyser,1);
obj->session=session; obj->session=session;
obj->parent.desc=&stateful_analyser_desc; obj->parent.desc=&stateful_analyser_desc;
obj->parent.type=Stateful;
return (MSQosAnalyser*)obj; return (MSQosAnalyser*)obj;
} }
......
...@@ -64,8 +64,6 @@ extern "C" { ...@@ -64,8 +64,6 @@ extern "C" {
MSQosAnalyserNetworkState network_state; MSQosAnalyserNetworkState network_state;
double points[150][3]; double points[150][3];
}MSStatefulQosAnalyser; }MSStatefulQosAnalyser;
MSQosAnalyserNetworkState ms_qos_analyser_get_network_state(const MSQosAnalyser *objbase);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -380,7 +380,7 @@ static void configure_video_source(VideoStream *stream){ ...@@ -380,7 +380,7 @@ static void configure_video_source(VideoStream *stream){
stream->ms.rc=NULL; stream->ms.rc=NULL;
} }
if (stream->ms.use_rc){ if (stream->ms.use_rc){
stream->ms.rc=ms_av_bitrate_controller_new(NULL,NULL,stream->ms.sessions.rtp_session,stream->ms.encoder); stream->ms.rc=ms_bandwidth_bitrate_controller_new(NULL,NULL,stream->ms.sessions.rtp_session,stream->ms.encoder);
} }
} }
......
...@@ -75,7 +75,7 @@ typedef struct _video_stream_manager_t { ...@@ -75,7 +75,7 @@ typedef struct _video_stream_manager_t {
struct { struct {
float loss; float loss;
float rtt; float rtt;
uint8_t network_state; MSQosAnalyserNetworkState network_state;
} latest_stats; } latest_stats;
} video_stream_manager_t ; } video_stream_manager_t ;
static video_stream_manager_t * video_stream_manager_new() { static video_stream_manager_t * video_stream_manager_new() {
...@@ -129,10 +129,15 @@ static void handle_queue_events(video_stream_manager_t * stream_mgr, OrtpEvQueue ...@@ -129,10 +129,15 @@ static void handle_queue_events(video_stream_manager_t * stream_mgr, OrtpEvQueue
} }
if (rb) { if (rb) {
const MSQosAnalyser *analyser=ms_bitrate_controller_get_qos_analyser(stream_mgr->stream->ms.rc);
if (analyser->type==Stateful){
stream_mgr->latest_stats.network_state=
((const MSStatefulQosAnalyser*)analyser)->network_state;
}
stream_mgr->latest_stats.loss=100.0*(float)report_block_get_fraction_lost(rb)/256.0; stream_mgr->latest_stats.loss=100.0*(float)report_block_get_fraction_lost(rb)/256.0;
stream_mgr->latest_stats.rtt=rtp_session_get_round_trip_propagation(stream_mgr->stream->ms.sessions.rtp_session); stream_mgr->latest_stats.rtt=rtp_session_get_round_trip_propagation(stream_mgr->stream->ms.sessions.rtp_session);
stream_mgr->latest_stats.network_state=ms_qos_analyser_get_network_state(ms_bitrate_controller_get_qos_analyser(stream_mgr->stream->ms.rc));
ms_message("mediastreamer2_video_stream_tester: %s RTCP packet: loss=%f, RTT=%f, network_state=%d" ms_message("mediastreamer2_video_stream_tester: %s RTCP packet: loss=%f, RTT=%f, network_state=%d"
,(evt == ORTP_EVENT_RTCP_PACKET_RECEIVED) ? "RECEIVED" : "EMITTED" ,(evt == ORTP_EVENT_RTCP_PACKET_RECEIVED) ? "RECEIVED" : "EMITTED"
,stream_mgr->latest_stats.loss ,stream_mgr->latest_stats.loss
...@@ -241,7 +246,7 @@ static void stability_network_detection() { ...@@ -241,7 +246,7 @@ static void stability_network_detection() {
INIT(); INIT();
start_adaptive_video_stream(marielle, margaux, VP8_PAYLOAD_TYPE, 300000, 0, 15, 250, 10); start_adaptive_video_stream(marielle, margaux, VP8_PAYLOAD_TYPE, 300000, 0, 15, 250, 10);
CU_ASSERT_EQUAL(marielle->latest_stats.network_state, MSQosAnalyserNetworkUnstable); CU_ASSERT_EQUAL(marielle->latest_stats.network_state, MSQosAnalyserNetworkLossy);
DEINIT(); DEINIT();
} }
......
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