Commit 4bb4bf7a authored by Ghislain MARY's avatar Ghislain MARY

Fix compilation warnings when building for Windows 10.

parent 9e7f98c8
......@@ -123,6 +123,9 @@ unsigned long __ortp_thread_self(void);
#include <stdarg.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#ifdef _MSC_VER
#include <io.h>
#endif
#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
#define ORTP_WINDOWS_DESKTOP 1
......@@ -152,6 +155,7 @@ unsigned long __ortp_thread_self(void);
#endif
#define strtok_r strtok_s
#define close _close
typedef unsigned __int64 uint64_t;
typedef __int64 int64_t;
......
......@@ -76,7 +76,7 @@ char offset0[4] = {0x00, 0x00, 0x00, 0x00};
#define RECV_FMTP(val) (val)
#define SEND_FMTP(val) (val)
#define NO_AVPF {PAYLOAD_TYPE_AVPF_NONE, 0}
#define AVPF(feat, intv) {(feat), (intv)}
#define AVPF(feat, intv) {(feat), FALSE, (intv)}
#define FLAGS(val) (val)
#endif
......
......@@ -132,7 +132,7 @@ char *ortp_strdup_printf(const char *fmt,...){
char * ortp_strcat_vprintf(char* dst, const char *fmt, va_list ap){
char *ret;
unsigned long dstlen, retlen;
size_t dstlen, retlen;
ret=ortp_strdup_vprintf(fmt, ap);
dstlen = strlen(dst);
......@@ -268,7 +268,7 @@ static void __ortp_logv_out(OrtpLogLevel lev, const char *fmt, va_list args){
OutputDebugStringA("\r\n");
#else
{
int len=strlen(msg);
size_t len=strlen(msg);
wchar_t *tmp=(wchar_t*)ortp_malloc0((len+1)*sizeof(wchar_t));
mbstowcs(tmp,msg,len);
OutputDebugStringW(tmp);
......
......@@ -272,7 +272,7 @@ static mblk_t *simulate_bandwidth_limit_and_jitter(RtpSession *session, mblk_t *
/* queue the packet for sending*/
if (input){
putq(&sim->q,input);
bits=(msgdsize(input)+overhead)*8;
bits=((int)msgdsize(input)+overhead)*8;
sim->qsize+=bits;
}
/*flow control*/
......@@ -280,7 +280,7 @@ static mblk_t *simulate_bandwidth_limit_and_jitter(RtpSession *session, mblk_t *
// ortp_message("rtp_session_network_simulate(): discarding packets.");
output=getq(&sim->q);
if (output){
bits=(msgdsize(output)+overhead)*8;
bits=((int)msgdsize(output)+overhead)*8;
sim->qsize-=bits;
sim->drop_by_congestion++;
freemsg(output);
......@@ -293,7 +293,7 @@ static mblk_t *simulate_bandwidth_limit_and_jitter(RtpSession *session, mblk_t *
if (sim->bit_budget>=0){
output=getq(&sim->q);
if (output){
bits=(msgdsize(output)+overhead)*8;
bits=((int)msgdsize(output)+overhead)*8;
sim->bit_budget-=bits;
sim->qsize-=bits;
}
......
......@@ -189,7 +189,7 @@ bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, si
int copied;
const char *end=strchr(equal+1,';');
if (end==NULL) end=fmtp+strlen(fmtp); /*assuming this is the last param */
copied=MIN(result_len-1,end-(equal+1));
copied=MIN((int)(result_len-1),(int)(end-(equal+1)));
strncpy(result,equal+1,copied);
result[copied]='\0';
return TRUE;
......
......@@ -244,9 +244,9 @@ typedef struct thread_param{
static unsigned WINAPI thread_starter(void *data){
thread_param_t *params=(thread_param_t*)data;
void *ret=params->func(params->arg);
params->func(params->arg);
ortp_free(data);
return (DWORD)ret;
return 0;
}
#if defined _WIN32_WCE
......@@ -750,7 +750,7 @@ void _ortp_get_cur_time(ortpTimeSpec *ret, bool_t realtime){
}
void ortp_get_cur_time(ortpTimeSpec *ret){
return _ortp_get_cur_time(ret, FALSE);
_ortp_get_cur_time(ret, FALSE);
}
......@@ -796,7 +796,7 @@ void ortp_sleep_until(const ortpTimeSpec *ts){
diff.tv_sec-=1;
}
#ifdef _WIN32
ortp_sleep_ms((diff.tv_sec * 1000LL) + (diff.tv_nsec/1000000LL));
ortp_sleep_ms((int)((diff.tv_sec * 1000LL) + (diff.tv_nsec/1000000LL)));
#else
{
struct timespec dur,rem;
......
......@@ -175,12 +175,12 @@ void rtp_session_remove_contributing_source(RtpSession *session, uint32_t ssrc)
rtp_session_rtcp_send(session,tmp);
}
void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, int bytes_len){
void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, size_t bytes_len){
rtcp_common_header_set_version(ch,2);
rtcp_common_header_set_padbit(ch,0);
rtcp_common_header_set_packet_type(ch,type);
rtcp_common_header_set_rc(ch,rc); /* as we don't yet support multi source receiving */
rtcp_common_header_set_length(ch,(bytes_len/4)-1);
rtcp_common_header_set_length(ch,(unsigned short)((bytes_len/4)-1));
}
mblk_t* rtp_session_create_rtcp_sdes_packet(RtpSession *session, bool_t full) {
......@@ -491,9 +491,9 @@ void compute_rtcp_interval(RtpSession *session) {
if (rtp_session_avpf_enabled(session) == TRUE) {
session->rtcp.send_algo.T_rr_interval = rtp_session_get_avpf_rr_interval(session);
rtcp_min_time = session->rtcp.send_algo.Tmin;
rtcp_min_time = (float)session->rtcp.send_algo.Tmin;
} else {
rtcp_min_time = session->rtcp.send_algo.T_rr_interval;
rtcp_min_time = (float)session->rtcp.send_algo.T_rr_interval;
if (session->rtcp.send_algo.initial == TRUE) {
rtcp_min_time /= 2.;
}
......@@ -502,14 +502,14 @@ void compute_rtcp_interval(RtpSession *session) {
t = ((session->rtcp.send_algo.avg_rtcp_size * 8 * 2) / rtcp_bw) * 1000;
if (t < rtcp_min_time) t = rtcp_min_time;
t = rtcp_rand(t);
t = t / (2.71828 - 1.5); /* Compensation */
t = t / (2.71828f - 1.5f); /* Compensation */
session->rtcp.send_algo.T_rr = (uint32_t)t;
}
void update_avg_rtcp_size(RtpSession *session, int bytes) {
int overhead = (ortp_stream_is_ipv6(&session->rtcp.gs) == TRUE) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
int size = bytes + overhead;
session->rtcp.send_algo.avg_rtcp_size = ((size + (15 * session->rtcp.send_algo.avg_rtcp_size)) / 16.);
session->rtcp.send_algo.avg_rtcp_size = ((size + (15 * session->rtcp.send_algo.avg_rtcp_size)) / 16.f);
}
static void rtp_session_schedule_first_rtcp_send(RtpSession *session) {
......@@ -714,7 +714,7 @@ bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj,
/*if we are using duplicates, they will not be visible in 'diff' variable.
But since we are the emitter, we can retrieve the total count of packet we
sent and use this value to compute the loss rate instead.*/
obj->loss_rate=100.0*(1. - MAX(0, (diff_unique_outgoing - new_losses) * 1.f / diff_total_outgoing));
obj->loss_rate = 100.f * (1.f - MAX(0, (diff_unique_outgoing - new_losses) * 1.f / diff_total_outgoing));
/*update last values with current*/
got_value=TRUE;
......
......@@ -143,7 +143,7 @@ static int rtcp_xr_voip_metrics_init(uint8_t *buf, RtpSession *session) {
uint32_t lost_packets;
rtcp_xr_voip_metrics_report_block_t *block = (rtcp_xr_voip_metrics_report_block_t *)buf;
float rtt = rtp_session_get_round_trip_propagation(session);
uint16_t int_rtt = (rtt >= 0) ? (rtt * 1000) : 0;
uint16_t int_rtt = (uint16_t)((rtt >= 0) ? (rtt * 1000) : 0);
float qi = -1;
float lq_qi = -1;
......
......@@ -21,21 +21,19 @@
#include "ortp/ortp.h"
#include "utils.h"
static int rtcp_get_size(const mblk_t *m){
static size_t rtcp_get_size(const mblk_t *m){
const rtcp_common_header_t *ch=rtcp_get_common_header(m);
if (ch==NULL) return -1;
if (ch==NULL) return 0;
return (1+rtcp_common_header_get_length(ch))*4;
}
/*in case of coumpound packet, set read pointer of m to the beginning of the next RTCP
packet */
bool_t rtcp_next_packet(mblk_t *m){
int nextlen=rtcp_get_size(m);
if (nextlen>=0){
if (m->b_rptr+nextlen<m->b_wptr){
m->b_rptr+=nextlen;
return TRUE;
}
size_t nextlen=rtcp_get_size(m);
if (m->b_rptr+nextlen<m->b_wptr){
m->b_rptr+=nextlen;
return TRUE;
}
return FALSE;
}
......@@ -46,7 +44,7 @@ void rtcp_rewind(mblk_t *m){
/* get common header; this function will also check the sanity of the packet*/
const rtcp_common_header_t * rtcp_get_common_header(const mblk_t *m){
int size=msgdsize(m);
size_t size=msgdsize(m);
rtcp_common_header_t *ch;
if (m->b_cont!=NULL){
ortp_fatal("RTCP parser does not work on fragmented mblk_t. Use msgpullup() before to re-assemble the packet.");
......@@ -86,7 +84,7 @@ const sender_info_t * rtcp_SR_get_sender_info(const mblk_t *m){
const report_block_t * rtcp_SR_get_report_block(const mblk_t *m, int idx){
rtcp_sr_t *sr=(rtcp_sr_t*)m->b_rptr;
report_block_t *rb=&sr->rb[idx];
int size=rtcp_get_size(m);
size_t size=rtcp_get_size(m);
if ( ( (uint8_t*)rb)+sizeof(report_block_t) <= m->b_rptr + size ) {
return rb;
}else{
......@@ -118,7 +116,7 @@ uint32_t rtcp_RR_get_ssrc(const mblk_t *m){
const report_block_t * rtcp_RR_get_report_block(const mblk_t *m,int idx){
rtcp_rr_t *rr=(rtcp_rr_t*)m->b_rptr;
report_block_t *rb=&rr->rb[idx];
int size=rtcp_get_size(m);
size_t size=rtcp_get_size(m);
if ( ( (uint8_t*)rb)+sizeof(report_block_t) <= (m->b_rptr + size ) ){
return rb;
}else{
......@@ -169,7 +167,7 @@ void rtcp_sdes_parse(const mblk_t *m, SdesItemFoundCallback cb, void *user_data)
if (type==RTCP_SDES_END){
/* pad to next 32bit boundary*/
rptr=(uint8_t*)(((unsigned long)rptr+4) & ~0x3);
rptr=(uint8_t *)((intptr_t)(rptr+4) & ~0x3);
nchunk++;
if (nchunk<rtcp_common_header_get_rc(ch)){
chunk_start=TRUE;
......@@ -243,7 +241,7 @@ bool_t rtcp_BYE_get_reason(const mblk_t *m, const char **reason, int *reason_len
/*APP accessors */
bool_t rtcp_is_APP(const mblk_t *m){
const rtcp_common_header_t *ch=rtcp_get_common_header(m);
int size=rtcp_get_size(m);
size_t size=rtcp_get_size(m);
if (ch!=NULL && rtcp_common_header_get_packet_type(ch)==RTCP_APP){
if (msgdsize(m)<size){
ortp_warning("Too short RTCP APP packet.");
......@@ -274,7 +272,7 @@ void rtcp_APP_get_name(const mblk_t *m, char *name){
}
/* retrieve the data. when returning, data points directly into the mblk_t */
void rtcp_APP_get_data(const mblk_t *m, uint8_t **data, int *len){
int datalen=rtcp_get_size(m)-sizeof(rtcp_app_t);
int datalen=(int)rtcp_get_size(m)-sizeof(rtcp_app_t);
if (datalen>0){
*data=(uint8_t*)m->b_rptr+sizeof(rtcp_app_t);
*len=datalen;
......@@ -543,8 +541,8 @@ uint32_t rtcp_RTPFB_get_media_source_ssrc(const mblk_t *m) {
}
rtcp_fb_generic_nack_fci_t * rtcp_RTPFB_generic_nack_get_fci(const mblk_t *m) {
unsigned int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_generic_nack_fci_t);
unsigned int rtcp_size = rtcp_get_size(m);
size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_generic_nack_fci_t);
size_t rtcp_size = rtcp_get_size(m);
if (size > rtcp_size) {
return NULL;
}
......@@ -552,8 +550,8 @@ rtcp_fb_generic_nack_fci_t * rtcp_RTPFB_generic_nack_get_fci(const mblk_t *m) {
}
rtcp_fb_tmmbr_fci_t * rtcp_RTPFB_tmmbr_get_fci(const mblk_t *m) {
unsigned int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_tmmbr_fci_t);
unsigned int rtcp_size = rtcp_get_size(m);
size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_tmmbr_fci_t);
size_t rtcp_size = rtcp_get_size(m);
if (size > rtcp_size) {
return NULL;
}
......@@ -596,8 +594,8 @@ uint32_t rtcp_PSFB_get_media_source_ssrc(const mblk_t *m) {
}
rtcp_fb_fir_fci_t * rtcp_PSFB_fir_get_fci(const mblk_t *m, unsigned int idx) {
unsigned int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_fir_fci_t));
unsigned int rtcp_size = rtcp_get_size(m);
size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_fir_fci_t));
size_t rtcp_size = rtcp_get_size(m);
if (size > rtcp_size) {
return NULL;
}
......@@ -605,8 +603,8 @@ rtcp_fb_fir_fci_t * rtcp_PSFB_fir_get_fci(const mblk_t *m, unsigned int idx) {
}
rtcp_fb_sli_fci_t * rtcp_PSFB_sli_get_fci(const mblk_t *m, unsigned int idx) {
unsigned int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_sli_fci_t));
unsigned int rtcp_size = rtcp_get_size(m);
size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_sli_fci_t));
size_t rtcp_size = rtcp_get_size(m);
if (size > rtcp_size) {
return NULL;
}
......@@ -619,6 +617,6 @@ rtcp_fb_rpsi_fci_t * rtcp_PSFB_rpsi_get_fci(const mblk_t *m) {
uint16_t rtcp_PSFB_rpsi_get_fci_bit_string_len(const mblk_t *m) {
rtcp_fb_rpsi_fci_t *fci = rtcp_PSFB_rpsi_get_fci(m);
uint16_t bit_string_len_in_bytes = rtcp_get_size(m) - (sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + 2);
uint16_t bit_string_len_in_bytes = (uint16_t)(rtcp_get_size(m) - (sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + 2));
return ((bit_string_len_in_bytes * 8) - fci->pb);
}
......@@ -132,7 +132,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
RtpStream *rtpstream=&session->rtp;
rtp_stats_t *stats=&rtpstream->stats;
msgsize=mp->b_wptr-mp->b_rptr;
msgsize=(int)(mp->b_wptr-mp->b_rptr);
if (msgsize<RTP_FIXED_HEADER_SIZE){
ortp_warning("Packet too small to be a rtp packet (%i)!",msgsize);
......
......@@ -894,7 +894,7 @@ __rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_t
rtp_header_t *rtp;
uint32_t packet_time;
int error = 0;
int packsize;
size_t packsize;
RtpScheduler *sched=session->sched;
RtpStream *stream=&session->rtp;
......@@ -957,7 +957,7 @@ __rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_t
}
session->rtp.snd_last_ts = packet_ts;
stream->sent_payload_bytes+=packsize-RTP_FIXED_HEADER_SIZE;
stream->sent_payload_bytes+=(uint32_t)(packsize-RTP_FIXED_HEADER_SIZE);
ortp_global_stats.sent += (1+(int)session->duplication_left) * packsize;
stream->stats.sent += (1+(int)session->duplication_left) * packsize;
......@@ -1156,7 +1156,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
/* check for telephone event first */
mp=getq(&session->rtp.tev_rq);
if (mp!=NULL){
int msgsize=msgdsize(mp);
size_t msgsize=msgdsize(mp);
ortp_global_stats.recv += msgsize;
stream->stats.recv += msgsize;
rtp_signal_table_emit2(&session->on_telephone_event_packet,mp);
......@@ -1204,7 +1204,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
end:
if (mp != NULL)
{
int msgsize = msgdsize (mp); /* evaluate how much bytes (including header) is received by app */
size_t msgsize = msgdsize(mp); /* evaluate how much bytes (including header) is received by app */
uint32_t packet_ts;
ortp_global_stats.recv += msgsize;
stream->stats.recv += msgsize;
......@@ -1320,7 +1320,7 @@ int rtp_session_recv_with_ts (RtpSession * session, uint8_t * buffer,
if (mp!=NULL) rtp_get_payload(mp,&mp->b_rptr);
}
if (mp){
plen=mp->b_wptr-mp->b_rptr;
plen=(int)(mp->b_wptr-mp->b_rptr);
if (plen<=len){
memcpy(buffer,mp->b_rptr,plen);
buffer+=plen;
......@@ -1763,9 +1763,9 @@ static float compute_bw(struct timeval *orig, unsigned int bytes, const struct t
float bw;
float time;
time=(float)(current->tv_sec - orig->tv_sec) +
((float)(current->tv_usec - orig->tv_usec)*1e-6);
bw=((float)bytes)*8/(time+0.0001);
time=(float)((double)(current->tv_sec - orig->tv_sec) +
((double)(current->tv_usec - orig->tv_usec)*1e-6));
bw=((float)bytes)*8/(time+0.0001f);
/*+0.0001 avoids a division by zero without changing the results significatively*/
*orig=*current;
return bw;
......@@ -1904,7 +1904,7 @@ int rtp_get_payload(mblk_t *packet, unsigned char **start){
tmp=packet->b_cont->b_rptr+(header_len- (packet->b_wptr-packet->b_rptr));
if (tmp<=packet->b_cont->b_wptr){
*start=tmp;
return packet->b_cont->b_wptr-tmp;
return (int)(packet->b_cont->b_wptr-tmp);
}
}
ortp_warning("Invalid RTP packet");
......@@ -1917,7 +1917,7 @@ int rtp_get_payload(mblk_t *packet, unsigned char **start){
}
}
*start=tmp;
return packet->b_wptr-tmp;
return (int)(packet->b_wptr-tmp);
}
/**
......@@ -2063,7 +2063,8 @@ void meta_rtp_set_session(RtpSession *s,MetaRtpTransportImpl *m){
}
int meta_rtp_transport_sendto(RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen) {
int prev_ret,ret;
size_t prev_ret;
int ret;
OList *elem;
MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
......@@ -2116,7 +2117,8 @@ int meta_rtp_transport_modifier_inject_packet(const RtpTransport *t, RtpTranspor
* allow a modifier to inject a packet wich will be treated by successive modifiers
*/
int meta_rtp_transport_modifier_inject_packet_to(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags,const struct sockaddr *to, socklen_t tolen) {
int prev_ret,ret;
size_t prev_ret;
int ret;
OList *elem;
bool_t packetInjected = tpm?FALSE:TRUE; /*if no modifier, start from the begening*/
MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
......
......@@ -53,15 +53,29 @@
#ifndef WSAID_WSARECVMSG
/* http://source.winehq.org/git/wine.git/blob/HEAD:/include/mswsock.h */
#define WSAID_WSARECVMSG {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}
#ifndef MAX_NATURAL_ALIGNMENT
#define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
#endif
#ifndef TYPE_ALIGNMENT
#define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; },test)
#endif
typedef WSACMSGHDR *LPWSACMSGHDR;
#ifndef WSA_CMSGHDR_ALIGN
#define WSA_CMSGHDR_ALIGN(length) (((length) + TYPE_ALIGNMENT(WSACMSGHDR)-1) & (~(TYPE_ALIGNMENT(WSACMSGHDR)-1)))
#endif
#ifndef WSA_CMSGDATA_ALIGN
#define WSA_CMSGDATA_ALIGN(length) (((length) + MAX_NATURAL_ALIGNMENT-1) & (~(MAX_NATURAL_ALIGNMENT-1)))
#endif
#ifndef WSA_CMSG_FIRSTHDR
#define WSA_CMSG_FIRSTHDR(msg) (((msg)->Control.len >= sizeof(WSACMSGHDR)) ? (LPWSACMSGHDR)(msg)->Control.buf : (LPWSACMSGHDR)NULL)
#endif
#ifndef WSA_CMSG_NXTHDR
#define WSA_CMSG_NXTHDR(msg,cmsg) ((!(cmsg)) ? WSA_CMSG_FIRSTHDR(msg) : ((((u_char *)(cmsg) + WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len) + sizeof(WSACMSGHDR)) > (u_char *)((msg)->Control.buf) + (msg)->Control.len) ? (LPWSACMSGHDR)NULL : (LPWSACMSGHDR)((u_char *)(cmsg) + WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len))))
#endif
#ifndef WSA_CMSG_DATA
#define WSA_CMSG_DATA(cmsg) ((u_char *)(cmsg) + WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR)))
#endif
#endif
#undef CMSG_FIRSTHDR
#define CMSG_FIRSTHDR WSA_CMSG_FIRSTHDR
#undef CMSG_NXTHDR
......@@ -93,7 +107,7 @@ static LPFN_WSARECVMSG ortp_WSARecvMsg = NULL;
static int
_rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, int rtp_port, const char * rtcp_addr, int rtcp_port, bool_t is_aux);
static bool_t try_connect(int fd, const struct sockaddr *dest, socklen_t addrlen){
static bool_t try_connect(ortp_socket_t fd, const struct sockaddr *dest, socklen_t addrlen){
if (connect(fd,dest,addrlen)<0){
ortp_warning("Could not connect() socket: %s",getSocketError());
return FALSE;
......@@ -234,7 +248,7 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
}
*sock_family=res->ai_family;
err = bind (sock, res->ai_addr, res->ai_addrlen);
err = bind(sock, res->ai_addr, (int)res->ai_addrlen);
if (err != 0){
ortp_error ("Fail to bind rtp socket to (addr=%s port=%i) : %s.", addr, *port, getSocketError());
close_socket (sock);
......@@ -246,7 +260,7 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
break;
}
memcpy(bound_addr,res0->ai_addr,res0->ai_addrlen);
*bound_addr_len=res0->ai_addrlen;
*bound_addr_len=(socklen_t)res0->ai_addrlen;
freeaddrinfo(res0);
......@@ -268,13 +282,13 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
err=getsockname(sock,(struct sockaddr*)&saddr,&slen);
if (err==-1){
ortp_error("getsockname(): %s",getSocketError());
close(sock);
close((int)sock);
return (ortp_socket_t)-1;
}
err=getnameinfo((struct sockaddr*)&saddr, slen, NULL, 0, num, sizeof(num), NI_NUMERICHOST | NI_NUMERICSERV);
if (err!=0){
ortp_error("getnameinfo(): %s",gai_strerror(err));
close(sock);
close((int)sock);
return (ortp_socket_t)-1;
}
*port=atoi(num);
......@@ -284,7 +298,7 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
return sock;
}
static void set_socket_sizes(int sock, unsigned int sndbufsz, unsigned int rcvbufsz){
static void set_socket_sizes(ortp_socket_t sock, unsigned int sndbufsz, unsigned int rcvbufsz){
int err;
bool_t done=FALSE;
if (sndbufsz>0){
......@@ -599,7 +613,7 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
int tos;
int proto;
int value_type;
#if (_WIN32_WINNT >= 0x0600)
#if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP)
OSVERSIONINFOEX ovi;
#endif
......@@ -828,7 +842,7 @@ _rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr,
/* set a destination address that has the same type as the local address */
if (res->ai_family==session->rtp.gs.sockfamily ) {
memcpy(rtp_saddr, res->ai_addr, res->ai_addrlen);
*rtp_saddr_len=res->ai_addrlen;
*rtp_saddr_len=(socklen_t)res->ai_addrlen;
err=0;
break;
}
......@@ -858,7 +872,7 @@ _rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr,
if (res->ai_family==session->rtp.gs.sockfamily ) {
err=0;
memcpy(rtcp_saddr, res->ai_addr, res->ai_addrlen);
*rtcp_saddr_len=res->ai_addrlen;
*rtcp_saddr_len=(socklen_t)res->ai_addrlen;
break;
}
}
......@@ -1027,7 +1041,7 @@ int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags
if (session->net_sim_ctx && (session->net_sim_ctx->params.mode==OrtpNetworkSimulatorOutbound
|| session->net_sim_ctx->params.mode==OrtpNetworkSimulatorOutboundControlled)){
ret=msgdsize(m);
ret=(int)msgdsize(m);
m=dupmsg(m);
memcpy(&m->net_addr,destaddr,destlen);
m->net_addrlen=destlen;
......@@ -1302,7 +1316,7 @@ static void compute_rtt(RtpSession *session, const struct timeval *now, uint32_t
if (rtt_frac>=0){
rtt_frac/=65536.0;
session->rtt=rtt_frac;
session->rtt=(float)rtt_frac;
/*ortp_message("rtt estimated to %f s",session->rtt);*/
}else ortp_warning("Negative RTT computation, maybe due to clock adjustments.");
}
......@@ -1410,7 +1424,7 @@ static int process_rtcp_packet( RtpSession *session, mblk_t *block, struct socka
return 0;
}
update_recv_bytes(&session->rtcp.gs, block->b_wptr - block->b_rptr);
update_recv_bytes(&session->rtcp.gs, (int)(block->b_wptr - block->b_rptr));
/* compound rtcp packet can be composed by more than one rtcp message */
do{
......@@ -1490,7 +1504,7 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
}
}
/* then parse the message and put on jitter buffer queue */
update_recv_bytes(&session->rtp.gs, mp->b_wptr - mp->b_rptr);
update_recv_bytes(&session->rtp.gs, (int)(mp->b_wptr - mp->b_rptr));
rtp_session_rtp_parse(session, mp, user_ts, remaddr,addrlen);
/*for bandwidth measurements:*/
}else {
......
......@@ -66,7 +66,7 @@ void update_avg_rtcp_size(RtpSession *session, int bytes);
mblk_t * rtp_session_network_simulate(RtpSession *session, mblk_t *input, bool_t *is_rtp_packet);
void ortp_network_simulator_destroy(OrtpNetworkSimulatorCtx *sim);
void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, int bytes_len);
void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, size_t bytes_len);
mblk_t * make_xr_rcvr_rtt(RtpSession *session);
mblk_t * make_xr_dlrr(RtpSession *session);
......
......@@ -242,15 +242,15 @@ void msgpullup(mblk_t *mp,size_t len)
{
mblk_t *firstm=mp;
dblk_t *db;
int wlen=0;
size_t wlen=0;
if (mp->b_cont==NULL && len==-1) return; /*nothing to do, message is not fragmented */
if (len==-1) len=msgdsize(mp);
db=datab_alloc(len);
while(wlen<len && mp!=NULL){
int remain=len-wlen;
int mlen=mp->b_wptr-mp->b_rptr;
int remain=(int)(len-wlen);
int mlen=(int)(mp->b_wptr-mp->b_rptr);
if (mlen<=remain){
memcpy(&db->db_base[wlen],mp->b_rptr,mlen);
wlen+=mlen;
......@@ -298,7 +298,7 @@ mblk_t * appendb(mblk_t *mp, const char *data, size_t size, bool_t pad){
size_t padcnt=0;
size_t i;
if (pad){
padcnt= (size_t)(4L-( (long)(((long)mp->b_wptr)+size) % 4L)) % 4L;
padcnt = (size_t)(4 - ((((intptr_t)mp->b_wptr) + size) % 4)) % 4;
}
if ((mp->b_wptr + size +padcnt) > mp->b_datap->db_lim){
/* buffer is not large enough: append a new block (with the same size ?)*/
......@@ -337,7 +337,7 @@ mblk_t *msgb_allocator_alloc(msgb_allocator_t *a, size_t size){
/*lookup for an unused msgb (data block with ref count ==1)*/
for(m=qbegin(q);!qend(q,m);m=qnext(q,m)){
if (m->b_datap->db_ref==1 && m->b_datap->db_lim-m->b_datap->db_base>=size){
if ((m->b_datap->db_ref == 1) && ((size_t)(m->b_datap->db_lim - m->b_datap->db_base) >= size)){
found=m;
break;
}
......
......@@ -46,8 +46,8 @@ OList * o_list_free(OList *elem);
OList *o_list_remove_link(OList *list, OList *elem);
#define ORTP_POINTER_TO_INT(p) ((int)(long)(p))
#define ORTP_INT_TO_POINTER(i) ((void *)(long)(i))
#define ORTP_POINTER_TO_INT(p) ((int)(intptr_t)(p))
#define ORTP_INT_TO_POINTER(i) ((void *)(intptr_t)(i))
typedef struct _dwsplit_t{
......
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