/** * Returns the default proxy configuration, that is the one used to determine the current identity. **/ int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config){ int pos=-1; if (config!=NULL) *config=lc->default_proxy; if (lc->default_proxy!=NULL){ pos=ms_list_position(lc->sip_conf.proxies,ms_list_find(lc->sip_conf.proxies,(void *)lc->default_proxy)); } return pos; }
static float compute_available_bw(MSStatefulQosAnalyzer *obj){ MSList *it; float constant_network_loss = 0.; float mean_bw = 0.; MSList *current = obj->rtcpstatspoint; MSList *last = current; int size = ms_list_size(obj->rtcpstatspoint); if (current == NULL){ ms_message("MSStatefulQosAnalyzer[%p]: no points available for estimation", obj); return -1; } while (last->next){ last = last->next; } if (size > 3){ smooth_values(obj); } /*suppose that first point is a reliable estimation of the constant network loss rate*/ constant_network_loss = ((rtcpstatspoint_t *)obj->rtcpstatspoint->data)->loss_percent; ms_message("MSStatefulQosAnalyzer[%p]:\tconstant_network_loss=%f", obj, constant_network_loss); #ifdef DEBUG for (it = obj->rtcpstatspoint; it != NULL; it=it->next){ rtcpstatspoint_t * point = (rtcpstatspoint_t *)it->data; (void)point; ms_message("MSStatefulQosAnalyzer[%p]:\t\tsorted values %d: %f %f", obj, ms_list_position(obj->rtcpstatspoint, it), point->bandwidth, point->loss_percent); } #endif if (size == 1){ rtcpstatspoint_t *p = (rtcpstatspoint_t *)current->data; ms_message("MSStatefulQosAnalyzer[%p]: one single point", obj); mean_bw = p->bandwidth * ((p->loss_percent>1e-5) ? (100-p->loss_percent)/100.f:2); }else{ while (current!=NULL && ((rtcpstatspoint_t*)current->data)->loss_percent<3+constant_network_loss){ ms_message("MSStatefulQosAnalyzer[%p]:\t%d is stable", obj, ms_list_position(obj->rtcpstatspoint, current)); for (it=last;it!=current;it=it->prev){ if (((rtcpstatspoint_t *)it->data)->loss_percent <= 3 + ((rtcpstatspoint_t*)current->data)->loss_percent){ ms_message("MSStatefulQosAnalyzer[%p]:\t%d is less than %d", obj, ms_list_position(obj->rtcpstatspoint, it), ms_list_position(obj->rtcpstatspoint, current)); current = it; break; } } current = current->next; } if (current == NULL){ /*constant loss rate - bad network conditions but no congestion*/ mean_bw = 2 * ((rtcpstatspoint_t*)last->data)->bandwidth; }else if (current->prev == obj->rtcpstatspoint){ /*only first packet is stable - might still be above real bandwidth*/ rtcpstatspoint_t *p = (rtcpstatspoint_t *)current->prev->data; mean_bw = p->bandwidth * (100 - p->loss_percent) / 100.f; }else{ /*there is some congestion*/ mean_bw = .5*(((rtcpstatspoint_t*)current->prev->data)->bandwidth+((rtcpstatspoint_t*)current->data)->bandwidth); } ms_message("MSStatefulQosAnalyzer[%p]: [0->%d] last stable is %d(%f;%f)" , obj , ms_list_position(obj->rtcpstatspoint, last) , ms_list_position(obj->rtcpstatspoint, (current ? current->prev : last)) , ((rtcpstatspoint_t*) (current ? current->prev->data : last->data))->bandwidth , ((rtcpstatspoint_t*) (current ? current->prev->data : last->data))->loss_percent); if (current!=NULL){ ms_message("MSStatefulQosAnalyzer[%p]: , first unstable is %d(%f;%f)" , obj , ms_list_position(obj->rtcpstatspoint, current) , ((rtcpstatspoint_t*) current->data)->bandwidth , ((rtcpstatspoint_t*) current->data)->loss_percent); } } ms_message("MSStatefulQosAnalyzer[%p]: --> estimated_available_bw=%f", obj, mean_bw); obj->network_loss_rate = constant_network_loss; obj->congestion_bandwidth = mean_bw; return mean_bw; }
static double compute_available_bw(MSStatefulQosAnalyzer *obj){ MSList *it; double constant_network_loss = 0.; double mean_bw = 0.; MSList *current = obj->rtcpstatspoint; MSList *last = current; int size = ms_list_size(obj->rtcpstatspoint); if (current == NULL){ ms_message("MSStatefulQosAnalyzer[%p]: no points available for estimation", obj); return -1; } while (last->next){ last = last->next; } if (size > 3){ smooth_values(obj); } /*suppose that first point is a reliable estimation of the constant network loss rate*/ constant_network_loss = ((rtcpstatspoint_t *)obj->rtcpstatspoint->data)->loss_percent; ms_message("MSStatefulQosAnalyzer[%p]:\tconstant_network_loss=%f", obj, constant_network_loss); #ifdef DEBUG for (it = obj->rtcpstatspoint; it != NULL; it=it->next){ rtcpstatspoint_t * point = (rtcpstatspoint_t *)it->data; (void)point; ms_message("MSStatefulQosAnalyzer[%p]:\t\tsorted values %d: %f %f", obj, ms_list_position(obj->rtcpstatspoint, it), point->bandwidth, point->loss_percent); } #endif if (size == 1){ rtcpstatspoint_t *p = (rtcpstatspoint_t *)current->data; ms_message("MSStatefulQosAnalyzer[%p]: one single point", obj); mean_bw = p->bandwidth * ((p->loss_percent>1e-5) ? (100-p->loss_percent)/100.f:2); }else{ while (current!=NULL && ((rtcpstatspoint_t*)current->data)->loss_percent<3+constant_network_loss){ ms_message("MSStatefulQosAnalyzer[%p]:\t%d is stable", obj, ms_list_position(obj->rtcpstatspoint, current)); /*find the last stable measure point, starting from highest bandwidth*/ for (it=last;it!=current;it=it->prev){ if (((rtcpstatspoint_t *)it->data)->loss_percent <= 3 + ((rtcpstatspoint_t*)current->data)->loss_percent){ ms_message("MSStatefulQosAnalyzer[%p]:\t%d is less than %d", obj, ms_list_position(obj->rtcpstatspoint, it), ms_list_position(obj->rtcpstatspoint, current)); current = it; break; } } /*current is the first unstable point, so taking the next one*/ current = current->next; } /*all points are below the constant loss rate threshold: there might be bad network conditions but no congestion*/ if (current == NULL){ mean_bw = 2 * ((rtcpstatspoint_t*)last->data)->bandwidth; /*only first packet is stable*/ }else if (current->prev == obj->rtcpstatspoint){ rtcpstatspoint_t *p = (rtcpstatspoint_t *)current->prev->data; mean_bw = p->bandwidth * (100 - p->loss_percent) / 100.; /*otherwise, there is a congestion detected starting at "current"*/ }else{ rtcpstatspoint_t *laststable = (rtcpstatspoint_t*)current->prev->data; rtcpstatspoint_t *firstunstable = (rtcpstatspoint_t*)current->data; mean_bw = .5*(laststable->bandwidth+firstunstable->bandwidth); } ms_message("MSStatefulQosAnalyzer[%p]: [0->%d] last stable is %d(%f;%f)" , obj , ms_list_position(obj->rtcpstatspoint, last) , ms_list_position(obj->rtcpstatspoint, (current ? current->prev : last)) , ((rtcpstatspoint_t*) (current ? current->prev->data : last->data))->bandwidth , ((rtcpstatspoint_t*) (current ? current->prev->data : last->data))->loss_percent); if (current!=NULL){ ms_message("MSStatefulQosAnalyzer[%p]: , first unstable is %d(%f;%f)" , obj , ms_list_position(obj->rtcpstatspoint, current) , ((rtcpstatspoint_t*) current->data)->bandwidth , ((rtcpstatspoint_t*) current->data)->loss_percent); } } ms_message("MSStatefulQosAnalyzer[%p]: --> estimated_available_bw=%f", obj, mean_bw); obj->network_loss_rate = constant_network_loss; obj->congestion_bandwidth = mean_bw; return mean_bw; }