[Freeswitch-trunk] [commit] r3797 - in freeswitch/trunk: libs/srtp/include libs/srtp/srtp src

Freeswitch SVN mikej at freeswitch.org
Fri Dec 22 14:02:11 EST 2006


Author: mikej
Date: Fri Dec 22 14:02:10 2006
New Revision: 3797

Modified:
   freeswitch/trunk/libs/srtp/include/srtp.h
   freeswitch/trunk/libs/srtp/srtp/srtp.c
   freeswitch/trunk/src/switch_rtp.c

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

Modified: freeswitch/trunk/libs/srtp/include/srtp.h
==============================================================================
--- freeswitch/trunk/libs/srtp/include/srtp.h	(original)
+++ freeswitch/trunk/libs/srtp/include/srtp.h	Fri Dec 22 14:02:10 2006
@@ -51,7 +51,6 @@
 #endif
 
 #ifdef _MSC_VER
-#pragma pack(4)
 #pragma warning(disable:4214)
 #endif
 
@@ -895,6 +894,10 @@
  * is not identical)
  */
  
+#ifdef _MSC_VER
+#pragma pack(push, r1, 1)
+#endif
+
 #ifndef WORDS_BIGENDIAN
 
 typedef struct {
@@ -904,9 +907,9 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
 #define SRTCP_INDEX_MASK 0x7fffffff
 
 #ifdef _MSC_VER
-#pragma pack()
+#pragma pack(pop, r1)
 #endif
 
 #ifdef __cplusplus

Modified: freeswitch/trunk/libs/srtp/srtp/srtp.c
==============================================================================
--- freeswitch/trunk/libs/srtp/srtp/srtp.c	(original)
+++ freeswitch/trunk/libs/srtp/srtp/srtp.c	Fri Dec 22 14:02:10 2006
@@ -684,7 +684,7 @@
     * 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 @@
       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 @@
   } 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);

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Fri Dec 22 14:02:10 2006
@@ -467,7 +467,7 @@
 	rtp_session->recv_msg.header.x       = 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->ms_per_packet = ms_per_packet;
 	rtp_session->packet_size = packet_size;
@@ -896,7 +896,7 @@
 			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->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;
 		} else {
 			if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) {
@@ -1296,7 +1296,7 @@
 		if (!rtp_session->mini && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_MINI)) {
 			rtp_session->mini++;
 			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);
 		}
 
 	}



More information about the Freeswitch-trunk mailing list