aboutsummaryrefslogtreecommitdiffstats
path: root/rtp.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-29 04:49:24 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-29 04:49:24 +0000
commitde060dd25bf45b1ca8cb18b26bd9c59d144686c7 (patch)
tree4c7e9cead02cc96ac8467cf7fcce545de722fe75 /rtp.c
parentf2529d4563eea317dcbb7bdbefcfd198da83936f (diff)
Simplify endianness and fix for unaligned reads (bug #3867)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5295 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-xrtp.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/rtp.c b/rtp.c
index 80484fc41..d5c6b99bc 100755
--- a/rtp.c
+++ b/rtp.c
@@ -37,6 +37,7 @@
#include <asterisk/lock.h>
#include <asterisk/utils.h>
#include <asterisk/cli.h>
+#include <asterisk/unaligned.h>
#define MAX_TIMESTAMP_SKEW 640
@@ -1173,18 +1174,6 @@ int ast_rtp_sendcng(struct ast_rtp *rtp, int level)
return 0;
}
-#if defined(SOLARIS) && defined(__sparc__)
-static void put_uint32(unsigned char *buf, int i)
-{
- buf[0] = (i>>24) & 0xff;
- buf[1] = (i>>16) & 0xff;
- buf[2] = (i>>8) & 0xff;
- buf[3] = i & 0xff;
-}
-#else
-#define put_uint32(p,v) ((*((unsigned int *)(p))) = (v))
-#endif
-
static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec)
{
unsigned char *rtpheader;
@@ -1270,9 +1259,9 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
/* Get a pointer to the header */
rtpheader = (unsigned char *)(f->data - hdrlen);
- put_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (rtp->seqno) | (mark << 23)));
- put_uint32(rtpheader + 4, htonl(rtp->lastts));
- put_uint32(rtpheader + 8, htonl(rtp->ssrc));
+ put_unaligned_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (rtp->seqno) | (mark << 23)));
+ put_unaligned_uint32(rtpheader + 4, htonl(rtp->lastts));
+ put_unaligned_uint32(rtpheader + 8, htonl(rtp->ssrc));
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));