change around types for better c99 compliance, fixes windows srtp build and builds that do not default to 8 bit stuct alignment.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3797 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2006-12-22 19:02:10 +00:00
parent 47343dcb87
commit 8761a73997
3 changed files with 22 additions and 19 deletions

View File

@ -51,7 +51,6 @@ extern "C" {
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma pack(4)
#pragma warning(disable:4214) #pragma warning(disable:4214)
#endif #endif
@ -895,6 +894,10 @@ srtp_install_event_handler(srtp_event_handler_func_t func);
* is not identical) * is not identical)
*/ */
#ifdef _MSC_VER
#pragma pack(push, r1, 1)
#endif
#ifndef WORDS_BIGENDIAN #ifndef WORDS_BIGENDIAN
typedef struct { typedef struct {
@ -904,9 +907,9 @@ typedef struct {
unsigned version:2; /* protocol version */ unsigned version:2; /* protocol version */
unsigned pt:7; /* payload type */ unsigned pt:7; /* payload type */
unsigned m:1; /* marker bit */ unsigned m:1; /* marker bit */
uint16_t seq; /* sequence number */ unsigned seq:16; /* sequence number */
uint32_t ts; /* timestamp */ unsigned ts:32; /* timestamp */
uint32_t ssrc; /* synchronization source */ unsigned ssrc:32; /* synchronization source */
} srtp_hdr_t; } srtp_hdr_t;
#else /* BIG_ENDIAN */ #else /* BIG_ENDIAN */
@ -918,9 +921,9 @@ typedef struct {
unsigned cc:4; /* CSRC count */ unsigned cc:4; /* CSRC count */
unsigned m:1; /* marker bit */ unsigned m:1; /* marker bit */
unsigned pt:7; /* payload type */ unsigned pt:7; /* payload type */
uint16_t seq; /* sequence number */ unsigned seq:16; /* sequence number */
uint32_t ts; /* timestamp */ unsigned ts:32; /* timestamp */
uint32_t ssrc; /* synchronization source */ unsigned ssrc:32; /* synchronization source */
} srtp_hdr_t; } srtp_hdr_t;
#endif #endif
@ -945,8 +948,8 @@ typedef struct {
unsigned p:1; /* padding flag */ unsigned p:1; /* padding flag */
unsigned version:2; /* protocol version */ unsigned version:2; /* protocol version */
unsigned pt:8; /* payload type */ unsigned pt:8; /* payload type */
uint16_t len; /* length */ unsigned len:16; /* length */
uint32_t ssrc; /* synchronization source */ unsigned ssrc:32; /* synchronization source */
} srtcp_hdr_t; } srtcp_hdr_t;
typedef struct { typedef struct {
@ -964,8 +967,8 @@ typedef struct {
unsigned p:1; /* padding flag */ unsigned p:1; /* padding flag */
unsigned rc:5; /* reception report count */ unsigned rc:5; /* reception report count */
unsigned pt:8; /* payload type */ unsigned pt:8; /* payload type */
uint16_t len; /* length */ unsigned len:16; /* length */
uint32_t ssrc; /* synchronization source */ unsigned ssrc:32; /* synchronization source */
} srtcp_hdr_t; } srtcp_hdr_t;
typedef struct { typedef struct {
@ -973,7 +976,7 @@ typedef struct {
unsigned int p:1; /* padding flag */ unsigned int p:1; /* padding flag */
unsigned int count:5; /* varies by packet type */ unsigned int count:5; /* varies by packet type */
unsigned int pt:8; /* payload type */ unsigned int pt:8; /* payload type */
uint16_t length; /* len of uint32s of packet less header */ unsigned length:16; /* len of uint32s of packet less header */
} rtcp_common_t; } rtcp_common_t;
typedef struct { typedef struct {
@ -992,7 +995,7 @@ typedef struct {
#define SRTCP_INDEX_MASK 0x7fffffff #define SRTCP_INDEX_MASK 0x7fffffff
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma pack() #pragma pack(pop, r1)
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -684,7 +684,7 @@ srtp_stream_init(srtp_stream_ctx_t *srtp,
* estimate the packet index using the start of the replay window * estimate the packet index using the start of the replay window
* and the sequence number from the header * and the sequence number from the header
*/ */
delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs(hdr->seq)); delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs((uint16_t)hdr->seq));
status = rdbx_check(&stream->rtp_rdbx, delta); status = rdbx_check(&stream->rtp_rdbx, delta);
if (status) if (status)
return status; /* we've been asked to reuse an index */ return status; /* we've been asked to reuse an index */
@ -842,7 +842,7 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) {
est = (xtd_seq_num_t) make64(0,ntohs(hdr->seq)); est = (xtd_seq_num_t) make64(0,ntohs(hdr->seq));
delta = low32(est); delta = low32(est);
#else #else
est = (xtd_seq_num_t) ntohs(hdr->seq); est = (xtd_seq_num_t) ntohs((uint16_t)hdr->seq);
delta = (int)est; delta = (int)est;
#endif #endif
} else { } else {
@ -856,7 +856,7 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) {
} else { } else {
/* estimate packet index from seq. num. in header */ /* estimate packet index from seq. num. in header */
delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs(hdr->seq)); delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs((uint16_t)hdr->seq));
/* check replay database */ /* check replay database */
status = rdbx_check(&stream->rtp_rdbx, delta); status = rdbx_check(&stream->rtp_rdbx, delta);

View File

@ -467,7 +467,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
rtp_session->recv_msg.header.x = 0; rtp_session->recv_msg.header.x = 0;
rtp_session->recv_msg.header.cc = 0; rtp_session->recv_msg.header.cc = 0;
rtp_session->seq = rtp_session->send_msg.header.seq; rtp_session->seq = (uint16_t)rtp_session->send_msg.header.seq;
rtp_session->payload = payload; rtp_session->payload = payload;
rtp_session->ms_per_packet = ms_per_packet; rtp_session->ms_per_packet = ms_per_packet;
rtp_session->packet_size = packet_size; rtp_session->packet_size = packet_size;
@ -896,7 +896,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) { if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) {
rtp_session->recv_msg.header.pt = 97; rtp_session->recv_msg.header.pt = 97;
} }
rtp_session->rseq = ntohs(rtp_session->recv_msg.header.seq); rtp_session->rseq = ntohs((uint16_t)rtp_session->recv_msg.header.seq);
rtp_session->rpayload = (switch_payload_t)rtp_session->recv_msg.header.pt; rtp_session->rpayload = (switch_payload_t)rtp_session->recv_msg.header.pt;
} else { } else {
if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) { if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) {
@ -1296,7 +1296,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, void *data, uint32_t data
if (!rtp_session->mini && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_MINI)) { if (!rtp_session->mini && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_MINI)) {
rtp_session->mini++; rtp_session->mini++;
rtp_session->rpayload = (switch_payload_t)send_msg->header.pt; rtp_session->rpayload = (switch_payload_t)send_msg->header.pt;
rtp_session->rseq = ntohs(send_msg->header.seq); rtp_session->rseq = ntohs((uint16_t)send_msg->header.seq);
} }
} }