Commit ebfc3026 authored by Ghislain MARY's avatar Ghislain MARY

Fix build on Windows.

parent bdba57a1
......@@ -308,8 +308,8 @@ rtp_session_init (RtpSession * session, int mode)
}
session->tev_send_pt = -1; /*check in rtp profile when needed*/
ortp_bw_estimator_init(&session->rtp.gs.recv_bw_estimator, 0.95, 0.01);
ortp_bw_estimator_init(&session->rtcp.gs.recv_bw_estimator, 0.95, 0.01);
ortp_bw_estimator_init(&session->rtp.gs.recv_bw_estimator, 0.95f, 0.01f);
ortp_bw_estimator_init(&session->rtcp.gs.recv_bw_estimator, 0.95f, 0.01f);
}
void rtp_session_enable_congestion_detection(RtpSession *session, bool_t enabled){
......
......@@ -209,6 +209,7 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
}
}
#ifdef SO_TIMESTAMP
optval=1;
err = setsockopt (sock, SOL_SOCKET, SO_TIMESTAMP,
(SOCKET_OPTION_VALUE)&optval, sizeof (optval));
......@@ -216,18 +217,19 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
{
ortp_warning ("Fail to set rtp timestamp: %s.",getSocketError());
}
#endif
err = 0;
optval=1;
switch (res->ai_family) {
default:
case AF_INET:
#ifdef IP_RECVTTL
err = setsockopt(sock, IPPROTO_IP, IP_RECVTTL, &optval, sizeof(optval));
err = setsockopt(sock, IPPROTO_IP, IP_RECVTTL, (SOCKET_OPTION_VALUE)&optval, sizeof(optval));
#endif
break;
case AF_INET6:
#ifdef IPV6_RECVHOPLIMIT
err = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &optval, sizeof(optval));
err = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, (SOCKET_OPTION_VALUE)&optval, sizeof(optval));
#endif
break;
}
......@@ -1334,9 +1336,11 @@ int rtp_session_rtp_recv_abstract(ortp_socket_t socket, mblk_t *msg, int flags,
ret = bytes_received;
#endif
for (cmsghdr = CMSG_FIRSTHDR(&msghdr); cmsghdr != NULL ; cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr)) {
#ifdef SO_TIMESTAMP
if (cmsghdr->cmsg_level == SOL_SOCKET && cmsghdr->cmsg_type == SCM_TIMESTAMP) {
memcpy(&msg->timestamp, (struct timeval *)CMSG_DATA(cmsghdr), sizeof(struct timeval));
}
#endif
#ifdef IP_PKTINFO
if ((cmsghdr->cmsg_level == IPPROTO_IP) && (cmsghdr->cmsg_type == IP_PKTINFO)) {
struct in_pktinfo *pi = (struct in_pktinfo *)CMSG_DATA(cmsghdr);
......
......@@ -34,7 +34,7 @@ uint64_t ortp_timeval_to_ntp(const struct timeval *tv){
void ortp_bw_estimator_init(OrtpBwEstimator *obj, float alpha, float step){
obj->one_minus_alpha = 1.0f - alpha;
obj->inv_step = 1.0/step;
obj->inv_step = 1.0f/step;
obj->exp_constant = logf(alpha) * obj->inv_step;
obj->last_packet_recv.tv_sec = 0;
obj->last_packet_recv.tv_usec = 0;
......@@ -45,10 +45,10 @@ void ortp_bw_estimator_packet_received (OrtpBwEstimator *obj, size_t bytes, cons
float diff_time;
if (obj->last_packet_recv.tv_sec == 0){
diff_time = 1.0/obj->inv_step;
diff_time = 1.0f/obj->inv_step;
ortp_message("First estimation");
}else{
diff_time = (float)(recv_time->tv_sec - obj->last_packet_recv.tv_sec) + 1e-6*(recv_time->tv_usec - obj->last_packet_recv.tv_usec);
diff_time = (float)(recv_time->tv_sec - obj->last_packet_recv.tv_sec) + 1e-6f*(recv_time->tv_usec - obj->last_packet_recv.tv_usec);
}
obj->value = ((float)bytes * obj->one_minus_alpha) + expf(diff_time * obj->exp_constant)*obj->value;
obj->last_packet_recv = *recv_time;
......@@ -58,6 +58,6 @@ float ortp_bw_estimator_get_value(OrtpBwEstimator *obj){
struct timeval current;
bctbx_gettimeofday(&current, NULL);
ortp_bw_estimator_packet_received(obj, 0, &current);
return obj->value * 8.0 * obj->inv_step;
return obj->value * 8.0f * obj->inv_step;
}
......@@ -92,7 +92,7 @@ float ortp_video_bandwidth_estimator_get_estimated_available_bandwidth(OrtpVideo
static void compute_bitrate_add_to_list_and_remove_oldest_value(OrtpVideoBandwidthEstimator *vbe, OrtpVideoBandwidthEstimatorPacket *packet) {
float difftime = (float)(packet->recv_last_timestamp.tv_sec - packet->recv_first_timestamp.tv_sec)
+ 1e-6*(packet->recv_last_timestamp.tv_usec - packet->recv_first_timestamp.tv_usec);
+ 1e-6f*(packet->recv_last_timestamp.tv_usec - packet->recv_first_timestamp.tv_usec);
packet->bitrate = (packet->bytes * 8 / difftime);
ortp_debug("[VBE] Bitrate is %f kbits/s computed using %f timedif and %u size", packet->bitrate / 1000, difftime, packet->bytes);
......
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