[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/rtmp r9614: fix encodeHeader to work on a
From: |
rob |
Subject: |
[Gnash-commit] /srv/bzr/gnash/rtmp r9614: fix encodeHeader to work on a big endian 64 bit machine. |
Date: |
Wed, 27 Aug 2008 22:59:10 -0600 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9614
committer: address@hidden
branch nick: rtmp
timestamp: Wed 2008-08-27 22:59:10 -0600
message:
fix encodeHeader to work on a big endian 64 bit machine.
modified:
libnet/rtmp.cpp
=== modified file 'libnet/rtmp.cpp'
--- a/libnet/rtmp.cpp 2008-08-28 01:24:04 +0000
+++ b/libnet/rtmp.cpp 2008-08-28 04:59:10 +0000
@@ -25,6 +25,7 @@
#include <string>
#include <map>
#include <vector>
+#include <boost/detail/endian.hpp>
#if ! (defined(_WIN32) || defined(WIN32))
# include <netinet/in.h>
@@ -374,27 +375,22 @@
// Add the size of the message if the header size is 8 or more.
// and add the type of the object if the header size is 8 or more.
+ // length is a 3 byte field
if ((head_size == HEADER_8) || (head_size == HEADER_12)) {
- int length = total_size;
- Network::byte_t *lenptr = reinterpret_cast<Network::byte_t *>(&length);
-//#ifndef BOOST_BIG_ENDIAN
-// swapBytes(&length, 4);
- *ptr++ = *(lenptr + 2);
- *ptr++ = *(lenptr + 1);
- *ptr++ = *lenptr;
-// *(lenptr + 3) = *(lenptr);
-// memcpy(ptr, lenptr, 3);
-// #else
-// #ifdef BOOST_BIG_ENDIAN
-// memcpy(ptr, &length, 3);
+#ifdef BOOST_BIG_ENDIAN
+ boost::uint32_t length = total_size << 8;
+#else
+ boost::uint32_t length = (htonl(*reinterpret_cast<boost::uint32_t
*>(&total_size))) >> 8;
+#endif
+ memcpy(ptr, &length, 3);
// #else
// #error "No Endianess specified!"
// #endif
//#endif
-// swapBytes(&length, 4);
-// ptr += 3;
- *ptr = type;
- ptr++;
+ ptr += 3;
+ // The type is a one byte field
+ *ptr = type;
+ ptr++;
}
// Add the routing of the message if the header size is 12, the maximum.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/rtmp r9614: fix encodeHeader to work on a big endian 64 bit machine.,
rob <=