Commit 5957051e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Few changes to improve configuration of video bandwidth estimator from outside oRTP

parent b1e6b986
......@@ -52,7 +52,7 @@ struct _OrtpEventData{
OrtpSocketType socket_type;
uint32_t received_rtt_character;
bool_t congestion_detected;
int video_bandwidth_available;
float video_bandwidth_available;
} info;
};
......
......@@ -449,6 +449,16 @@ struct _RtpSession
bool_t video_bandwidth_estimator_enabled;
};
/**
* Structure describing the video bandwidth estimator parameters
**/
typedef struct _OrtpVideoBandwidthEstimatorParams {
int enabled; /**<Whether estimator is enabled or off.*/
unsigned int packet_count_min; /** minimum number of packets with the same sent timestamp to be processed continuously before being used */
unsigned int packets_size_max; /** number of packets needed to compute the available video bandwidth */
unsigned int trust_percentage; /** percentage for which the chosen bandwidth value in all available will be inferior */
} OrtpVideoBandwidthEstimatorParams;
......@@ -685,7 +695,7 @@ ORTP_PUBLIC float rtp_session_get_round_trip_propagation(RtpSession *session);
ORTP_PUBLIC void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetworkSimulatorParams *params);
ORTP_PUBLIC void rtp_session_enable_congestion_detection(RtpSession *session, bool_t enabled);
ORTP_PUBLIC void rtp_session_enable_video_bandwidth_estimator(RtpSession *session, bool_t enabled);
ORTP_PUBLIC void rtp_session_enable_video_bandwidth_estimator(RtpSession *session, const OrtpVideoBandwidthEstimatorParams *params);
ORTP_PUBLIC void rtp_session_rtcp_set_lost_packet_value( RtpSession *session, const int value );
ORTP_PUBLIC void rtp_session_rtcp_set_jitter_value(RtpSession *session, const unsigned int value );
......
......@@ -285,6 +285,11 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
jitter_control_new_packet(&session->rtp.jittctl,rtp->timestamp,local_str_ts);
if (session->video_bandwidth_estimator_enabled && session->rtp.video_bw_estimator) {
int overhead = ortp_stream_is_ipv6(&session->rtp.gs) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
ortp_video_bandwidth_estimator_process_packet(session->rtp.video_bw_estimator, rtp->timestamp, &mp->timestamp, msgsize + overhead, rtp->markbit == 1);
}
if (session->congestion_detector_enabled && session->rtp.congdetect){
if (ortp_congestion_detector_record(session->rtp.congdetect,rtp->timestamp,local_str_ts)) {
OrtpEvent *ev=ortp_event_new(ORTP_EVENT_CONGESTION_STATE_CHANGED);
......@@ -293,11 +298,6 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
rtp_session_dispatch_event(session,ev);
}
}
if (session->video_bandwidth_estimator_enabled && session->rtp.video_bw_estimator) {
int overhead = ortp_stream_is_ipv6(&session->rtp.gs) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
ortp_video_bandwidth_estimator_process_packet(session->rtp.video_bw_estimator, rtp->timestamp, &mp->timestamp, msgsize + overhead, rtp->markbit == 1);
}
update_rtcp_xr_stat_summary(session, mp, local_str_ts);
......
......@@ -327,15 +327,17 @@ void rtp_session_enable_congestion_detection(RtpSession *session, bool_t enabled
session->congestion_detector_enabled = enabled;
}
void rtp_session_enable_video_bandwidth_estimator(RtpSession *session, bool_t enabled){
if (enabled){
if (!session->rtp.video_bw_estimator){
void rtp_session_enable_video_bandwidth_estimator(RtpSession *session, const OrtpVideoBandwidthEstimatorParams *params) {
if (params->enabled) {
if (!session->rtp.video_bw_estimator) {
session->rtp.video_bw_estimator = ortp_video_bandwidth_estimator_new(session);
}else{
if (!session->video_bandwidth_estimator_enabled) ortp_video_bandwidth_estimator_reset(session->rtp.video_bw_estimator);
}
if (params->packet_count_min > 0) session->rtp.video_bw_estimator->packet_count_min = params->packet_count_min;
if (params->packets_size_max > 0) session->rtp.video_bw_estimator->packets_size_max = params->packets_size_max;
if (params->trust_percentage > 0) session->rtp.video_bw_estimator->trust_percentage = params->trust_percentage;
if (!session->video_bandwidth_estimator_enabled) ortp_video_bandwidth_estimator_reset(session->rtp.video_bw_estimator);
}
session->video_bandwidth_estimator_enabled = enabled;
session->video_bandwidth_estimator_enabled = params->enabled;
}
void jb_parameters_init(JBParameters *jbp) {
......
......@@ -25,8 +25,8 @@
OrtpVideoBandwidthEstimator * ortp_video_bandwidth_estimator_new(RtpSession *session) {
OrtpVideoBandwidthEstimator *vbe = (OrtpVideoBandwidthEstimator*)ortp_malloc0(sizeof(OrtpVideoBandwidthEstimator));
vbe->session = session;
vbe->packet_count_min = 7;
vbe->packets_size_max = 30;
vbe->packet_count_min = 5;
vbe->packets_size_max = 3;
vbe->trust_percentage = 90;
vbe->nb_packets_computed = 0;
vbe->packets = NULL;
......@@ -76,7 +76,7 @@ static int compare_float(const float *v1, const float *v2) {
return -1;
}
int ortp_video_bandwidth_estimator_get_estimated_available_bandwidth(OrtpVideoBandwidthEstimator *vbe) {
float ortp_video_bandwidth_estimator_get_estimated_available_bandwidth(OrtpVideoBandwidthEstimator *vbe) {
bctbx_list_t *bitrate_sorted = NULL;
bctbx_list_t *elem;
float *result = NULL;
......@@ -87,7 +87,7 @@ int ortp_video_bandwidth_estimator_get_estimated_available_bandwidth(OrtpVideoBa
}
result = (float *)bctbx_list_nth_data(bitrate_sorted, index);
bctbx_list_free(bitrate_sorted);
return (int)*result;
return (float)*result;
}
static void compute_bitrate_add_to_list_and_remove_oldest_value(OrtpVideoBandwidthEstimator *vbe, OrtpVideoBandwidthEstimatorPacket *packet) {
......
......@@ -91,6 +91,6 @@ unsigned int ortp_video_bandwidth_estimator_get_trust(OrtpVideoBandwidthEstimato
void ortp_video_bandwidth_estimator_process_packet(OrtpVideoBandwidthEstimator *vbe, uint32_t sent_timestamp, const struct timeval *recv_timestamp, int msgsize, bool_t is_last);
int ortp_video_bandwidth_estimator_get_estimated_available_bandwidth(OrtpVideoBandwidthEstimator *vbe);
float ortp_video_bandwidth_estimator_get_estimated_available_bandwidth(OrtpVideoBandwidthEstimator *vbe);
#endif
\ No newline at end of file
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