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 committed 2006-12-22 19:02:10 +00:00
1 parent 47343dcb87
commit 8761a73997
3 files changed
+22 -19

No files matched your search

+16 -13
View File
@@ -51,7 +51,6 @@ extern "C" {
#endif
#ifdef _MSC_VER
#pragma pack(4)
#pragma warning(disable:4214)
#endif
@@ -895,6 +894,10 @@ srtp_install_event_handler(srtp_event_handler_func_t func);
* is not identical)
*/
#ifdef _MSC_VER
#pragma pack(push, r1, 1)
#endif
#ifndef WORDS_BIGENDIAN
typedef struct {
@@ -904,9 +907,9 @@ typedef struct {
unsigned version:2; /* protocol version */
unsigned pt:7; /* payload type */
unsigned m:1; /* marker bit */
uint16_t seq; /* sequence number */
uint32_t ts; /* timestamp */
uint32_t ssrc; /* synchronization source */
unsigned seq:16; /* sequence number */
unsigned ts:32; /* timestamp */
unsigned ssrc:32; /* synchronization source */
} srtp_hdr_t;
#else /* BIG_ENDIAN */
@@ -918,9 +921,9 @@ typedef struct {
unsigned cc:4; /* CSRC count */
unsigned m:1; /* marker bit */
unsigned pt:7; /* payload type */
uint16_t seq; /* sequence number */
uint32_t ts; /* timestamp */
uint32_t ssrc; /* synchronization source */
unsigned seq:16; /* sequence number */
unsigned ts:32; /* timestamp */
unsigned ssrc:32; /* synchronization source */
} srtp_hdr_t;
#endif
@@ -945,8 +948,8 @@ typedef struct {
unsigned p:1; /* padding flag */
unsigned version:2; /* protocol version */
unsigned pt:8; /* payload type */
uint16_t len; /* length */
uint32_t ssrc; /* synchronization source */
unsigned len:16; /* length */
unsigned ssrc:32; /* synchronization source */
} srtcp_hdr_t;
typedef struct {
@@ -964,8 +967,8 @@ typedef struct {
unsigned p:1; /* padding flag */
unsigned rc:5; /* reception report count */
unsigned pt:8; /* payload type */
uint16_t len; /* length */
uint32_t ssrc; /* synchronization source */
unsigned len:16; /* length */
unsigned ssrc:32; /* synchronization source */
} srtcp_hdr_t;
typedef struct {
@@ -973,7 +976,7 @@ typedef struct {
unsigned int p:1; /* padding flag */
unsigned int count:5; /* varies by packet 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;
typedef struct {
@@ -992,7 +995,7 @@ typedef struct {
#define SRTCP_INDEX_MASK 0x7fffffff
#ifdef _MSC_VER
#pragma pack()
#pragma pack(pop, r1)
#endif
#ifdef __cplusplus
+3 -3
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
* 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);
if (status)
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));
delta = low32(est);
#else
est = (xtd_seq_num_t) ntohs(hdr->seq);
est = (xtd_seq_num_t) ntohs((uint16_t)hdr->seq);
delta = (int)est;
#endif
} else {
@@ -856,7 +856,7 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) {
} else {
/* 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 */
status = rdbx_check(&stream->rtp_rdbx, delta);