1 http://lists.apple.com/archives/streaming-server-dev/2008/May/msg00050.html
2 http://www.abrahamsson.com/dss-6.0.3-x86_64.patch
4 diff -ur DarwinStreamingSrvr6.0.3-Source/APICommonCode/QTSSModuleUtils.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APICommonCode/QTSSModuleUtils.cpp
5 --- DarwinStreamingSrvr6.0.3-Source/APICommonCode/QTSSModuleUtils.cpp 2008-05-06 01:28:57.000000000 +0200
6 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APICommonCode/QTSSModuleUtils.cpp 2008-05-30 23:30:13.000000000 +0200
11 +#include <byteswap.h>
12 #include "QTSSModuleUtils.h"
13 #include "QTSS_Private.h"
16 RTPMetaInfoPacket::FieldName* theFieldName = (RTPMetaInfoPacket::FieldName*)theHeader.Ptr;
17 ::memcpy (&fieldNameValue, theFieldName, sizeof(UInt16));
19 - RTPMetaInfoPacket::FieldIndex theFieldIndex = RTPMetaInfoPacket::GetFieldIndexForName(ntohs(fieldNameValue));
20 + RTPMetaInfoPacket::FieldIndex theFieldIndex = RTPMetaInfoPacket::GetFieldIndexForName(bswap_16(fieldNameValue));
23 // This field is not supported (not in the field ID array), so
24 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSAdminModule/AdminElementNode.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSAdminModule/AdminElementNode.cpp
25 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSAdminModule/AdminElementNode.cpp 2008-05-06 01:28:58.000000000 +0200
26 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSAdminModule/AdminElementNode.cpp 2008-05-30 23:06:56.000000000 +0200
28 fFieldOSRefPtrs[index] = NEW OSRef(); Assert(fFieldOSRefPtrs[index] != NULL); ElementNode_InsertPtr(fFieldOSRefPtrs[index],"ElementNode::GetOSRef NEW OSRef() fFieldOSRefPtrs ");
29 GetNameSPL(index,&theName); Assert(theName.Len != 0);
30 //qtss_printf("ElementNode::GetOSRef index = %"_S32BITARG_" name = %s \n", index, theName.Ptr);
31 - fFieldOSRefPtrs[index]->Set(theName,(void *) index);
32 + fFieldOSRefPtrs[index]->Set(theName,(void *)intptr_t(index));
33 if (0 != theName.Len && NULL != theName.Ptr) //return the ptr else NULL
34 resultPtr = fFieldOSRefPtrs[index];
36 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSFileModule/QTSSFileModule.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSFileModule/QTSSFileModule.cpp
37 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSFileModule/QTSSFileModule.cpp 2008-05-06 01:28:58.000000000 +0200
38 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSFileModule/QTSSFileModule.cpp 2008-05-30 23:30:28.000000000 +0200
43 +#include <byteswap.h>
46 #include "QTSSFileModule.h"
49 inline UInt16 GetPacketSequenceNumber(void * packetDataPtr)
51 - return ntohs( ((UInt16*)packetDataPtr)[1]);
52 + return bswap_16( ((UInt16*)packetDataPtr)[1]);
55 inline UInt16 GetLastPacketSeqNum(QTSS_Object stream)
58 inline void SetPacketSequenceNumber(UInt16 newSequenceNumber, void * packetDataPtr)
60 - ((UInt16*)packetDataPtr)[1] = htons(newSequenceNumber);
61 + ((UInt16*)packetDataPtr)[1] = bswap_16(newSequenceNumber);
65 inline UInt32 GetPacketTimeStamp(void * packetDataPtr)
67 - return ntohl( ((UInt32*)packetDataPtr)[1]);
68 + return bswap_32( ((UInt32*)packetDataPtr)[1]);
71 inline void SetPacketTimeStamp(UInt32 newTimeStamp, void * packetDataPtr)
73 - ((UInt32*)packetDataPtr)[1] = htonl(newTimeStamp);
74 + ((UInt32*)packetDataPtr)[1] = bswap_32(newTimeStamp);
77 inline UInt32 CalculatePauseTimeStamp(UInt32 timescale, SInt64 totalPauseTime, UInt32 currentTimeStamp)
78 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSHttpFileModule/QTSSHttpFileModule.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSHttpFileModule/QTSSHttpFileModule.cpp
79 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSHttpFileModule/QTSSHttpFileModule.cpp 2008-05-06 01:28:58.000000000 +0200
80 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSHttpFileModule/QTSSHttpFileModule.cpp 2008-05-30 23:31:23.000000000 +0200
85 +#include <byteswap.h>
93 - rmraLen = htonl(rmraLen);
94 + rmraLen = bswap_32(rmraLen);
96 ::memcpy(&rmra[0], &rmraLen, 4);
97 ::memcpy(&rmra[1], "rmra", 4);
98 @@ -1076,20 +1077,20 @@
102 - *moovLen = ntohl(rmraLen) + 8;
103 + *moovLen = bswap_32(rmraLen) + 8;
104 moov = NEW UInt32[*moovLen];
108 - *moovLen = htonl(*moovLen);
109 + *moovLen = bswap_32(*moovLen);
111 ::memcpy(&moov[0], moovLen, 4);
112 ::memcpy(&moov[1], "moov", 4);
113 - ::memcpy((char *)moov + 8, rmra, ntohl(rmraLen));
114 + ::memcpy((char *)moov + 8, rmra, bswap_32(rmraLen));
118 - *moovLen = ntohl(*moovLen);
119 + *moovLen = bswap_32(*moovLen);
121 // moov needs to be deleted by the calling function
123 @@ -1099,8 +1100,8 @@
125 UInt32 *rdrf, rdrfLen, *rmdr, rmdrLen, *rmda, zero, size;
127 - zero = htonl(0); // Okay, this is silly ???
128 - rate = htonl(rate);
129 + zero = bswap_32(0); // Okay, this is silly ???
130 + rate = bswap_32(rate);
133 size = ::strlen(url) + 1;
134 @@ -1109,8 +1110,8 @@
138 - rdrfLen = htonl(rdrfLen);
139 - size = htonl(size);
140 + rdrfLen = bswap_32(rdrfLen);
141 + size = bswap_32(size);
143 ::memcpy(&rdrf[0], &rdrfLen, 4);
144 ::memcpy(&rdrf[1], "rdrf", 4);
145 @@ -1125,7 +1126,7 @@
149 - rmdrLen = htonl(rmdrLen);
150 + rmdrLen = bswap_32(rmdrLen);
152 ::memcpy(&rmdr[0], &rmdrLen, 4);
153 ::memcpy(&rmdr[1], "rmdr", 4);
154 @@ -1134,22 +1135,22 @@
158 - *rmdaLen = ntohl(rdrfLen) + ntohl(rmdrLen) + 8;
159 + *rmdaLen = bswap_32(rdrfLen) + bswap_32(rmdrLen) + 8;
160 rmda = NEW UInt32[*rmdaLen];
164 - *rmdaLen = htonl(*rmdaLen);
165 + *rmdaLen = bswap_32(*rmdaLen);
167 ::memcpy(&rmda[0], rmdaLen, 4);
168 ::memcpy(&rmda[1], "rmda", 4);
169 - ::memcpy((char *)rmda + 8, rmdr, ntohl(rmdrLen));
170 - ::memcpy((char *)rmda + 8 + ntohl(rmdrLen), rdrf, ntohl(rdrfLen));
171 + ::memcpy((char *)rmda + 8, rmdr, bswap_32(rmdrLen));
172 + ::memcpy((char *)rmda + 8 + bswap_32(rmdrLen), rdrf, bswap_32(rdrfLen));
177 - *rmdaLen = ntohl(*rmdaLen);
178 + *rmdaLen = bswap_32(*rmdaLen);
180 // rmda needs to be deleted by the calling function
182 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSProxyModule/QTSSProxyModule.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSProxyModule/QTSSProxyModule.cpp
183 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSProxyModule/QTSSProxyModule.cpp 2008-05-06 01:28:58.000000000 +0200
184 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSProxyModule/QTSSProxyModule.cpp 2008-05-30 23:31:46.000000000 +0200
189 +#include <byteswap.h>
195 UInt32 theIPAddr = 0;
196 if (theHostent != NULL)
197 - theIPAddr = ntohl(*(UInt32*)(theHostent->h_addr_list[0]));
198 + theIPAddr = bswap_32(*(UInt32*)(theHostent->h_addr_list[0]));
200 theIPAddr = SocketUtils::ConvertStringToAddr(theDNSName);
202 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/QTSSReflectorModule.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/QTSSReflectorModule.cpp
203 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/QTSSReflectorModule.cpp 2008-05-06 01:28:58.000000000 +0200
204 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/QTSSReflectorModule.cpp 2008-05-30 23:32:02.000000000 +0200
209 +#include <byteswap.h>
210 #include "QTSSReflectorModule.h"
211 #include "QTSSModuleUtils.h"
212 #include "ReflectorSession.h"
215 UInt16 packetDataLen;
216 memcpy(&packetDataLen,&packetData[2],2);
217 - packetDataLen = ntohs(packetDataLen);
218 + packetDataLen = bswap_16(packetDataLen);
220 char* rtpPacket = &packetData[4];
222 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/ReflectorSession.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/ReflectorSession.cpp
223 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/ReflectorSession.cpp 2008-05-06 01:28:58.000000000 +0200
224 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/ReflectorSession.cpp 2008-05-30 23:32:26.000000000 +0200
229 +#include <byteswap.h>
230 #include "ReflectorSession.h"
231 #include "RTCPPacket.h"
232 #include "SocketUtils.h"
234 char theIPAddrBuf[20];
235 StrPtrLen theIPAddr(theIPAddrBuf, 20);
236 struct in_addr theAddr;
237 - theAddr.s_addr = htonl(fSourceInfo->GetStreamInfo(0)->fSrcIPAddr);
238 + theAddr.s_addr = bswap_32(fSourceInfo->GetStreamInfo(0)->fSrcIPAddr);
239 SocketUtils::ConvertAddrToString(theAddr, &theIPAddr);
240 fFormatter.Put(theIPAddr);
242 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/ReflectorStream.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/ReflectorStream.cpp
243 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/ReflectorStream.cpp 2008-05-06 01:28:58.000000000 +0200
244 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/ReflectorStream.cpp 2008-05-30 23:32:33.000000000 +0200
249 +#include <byteswap.h>
250 #include "ReflectorStream.h"
251 #include "QTSSModuleUtils.h"
252 #include "OSMemory.h"
253 @@ -162,31 +163,31 @@
255 //write the RR (just header + ssrc)
256 UInt32* theRRWriter = (UInt32*)&fReceiverReportBuffer[0];
257 - *theRRWriter = htonl(0x80c90001);
258 + *theRRWriter = bswap_32(0x80c90001);
260 - *theRRWriter = htonl(theSsrc);
261 + *theRRWriter = bswap_32(theSsrc);
264 //SDES length is the length of the CName, plus 2 32bit words, minus 1
265 - *theRRWriter = htonl(0x81ca0000 + (cNameLen >> 2) + 1);
266 + *theRRWriter = bswap_32(0x81ca0000 + (cNameLen >> 2) + 1);
268 - *theRRWriter = htonl(theSsrc);
269 + *theRRWriter = bswap_32(theSsrc);
271 ::memcpy(theRRWriter, theTempCName, cNameLen);
272 theRRWriter += cNameLen >> 2;
274 //APP packet format, QTSS specific stuff
275 - *theRRWriter = htonl(0x80cc0008);
276 + *theRRWriter = bswap_32(0x80cc0008);
278 - *theRRWriter = htonl(theSsrc);
279 + *theRRWriter = bswap_32(theSsrc);
281 - *theRRWriter = htonl(FOUR_CHARS_TO_INT('Q','T','S','S'));
282 + *theRRWriter = bswap_32(FOUR_CHARS_TO_INT('Q','T','S','S'));
284 - *theRRWriter = htonl(0);
285 + *theRRWriter = bswap_32(0);
287 - *theRRWriter = htonl(0x00000004);
288 + *theRRWriter = bswap_32(0x00000004);
290 - *theRRWriter = htonl(0x6579000c);
291 + *theRRWriter = bswap_32(0x6579000c);
294 fEyeLocation = theRRWriter;
295 @@ -474,11 +475,11 @@
297 UInt32 theEyeCount = this->GetEyeCount();
298 UInt32* theEyeWriter = fEyeLocation;
299 - *theEyeWriter = htonl(theEyeCount) & 0x7fffffff;//no idea why we do this!
300 + *theEyeWriter = bswap_32(theEyeCount) & 0x7fffffff;//no idea why we do this!
302 - *theEyeWriter = htonl(theEyeCount) & 0x7fffffff;
303 + *theEyeWriter = bswap_32(theEyeCount) & 0x7fffffff;
305 - *theEyeWriter = htonl(0) & 0x7fffffff;
306 + *theEyeWriter = bswap_32(0) & 0x7fffffff;
308 //send the packet to the multicast RTCP addr & port for this stream
309 (void)fSockets->GetSocketB()->SendTo(fDestRTCPAddr, fDestRTCPPort, fReceiverReportBuffer, fReceiverReportSize);
312 //The RTP seq number is the second short of the packet
313 UInt16* seqNumPtr = (UInt16*)inPacket->Ptr;
314 - return ntohs(seqNumPtr[1]);
315 + return bswap_16(seqNumPtr[1]);
319 @@ -1460,7 +1461,7 @@
320 if (theSender == NULL)
322 //UInt16* theSeqNumberP = (UInt16*)thePacket->fPacketPtr.Ptr;
323 - //qtss_printf("ReflectorSocket::ProcessPacket no sender found for packet! sequence number=%d\n",ntohs(theSeqNumberP[1]));
324 + //qtss_printf("ReflectorSocket::ProcessPacket no sender found for packet! sequence number=%d\n",bswap_16(theSeqNumberP[1]));
325 fFreeQueue.EnQueue(&thePacket->fQueueElem); // don't process the packet
328 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/ReflectorStream.h DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/ReflectorStream.h
329 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/ReflectorStream.h 2008-05-06 01:28:58.000000000 +0200
330 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/ReflectorStream.h 2008-05-30 23:32:36.000000000 +0200
332 #ifndef _REFLECTOR_STREAM_H_
333 #define _REFLECTOR_STREAM_H_
335 +#include <byteswap.h>
338 #include "IdleTask.h"
339 @@ -121,12 +122,12 @@
341 UInt32* theSsrcPtr = (UInt32*)fPacketPtr.Ptr;
343 - return ntohl(theSsrcPtr[1]);
344 + return bswap_32(theSsrcPtr[1]);
346 if (fPacketPtr.Len < 12)
349 - return ntohl(theSsrcPtr[2]); // RTP SSRC
350 + return bswap_32(theSsrcPtr[2]); // RTP SSRC
353 UInt32 ReflectorPacket::GetPacketRTPTime()
354 @@ -138,13 +139,13 @@
355 //The RTP timestamp number is the second long of the packet
356 if (fPacketPtr.Ptr == NULL || fPacketPtr.Len < 8)
358 - timestamp = ntohl( ((UInt32*)fPacketPtr.Ptr)[1]);
359 + timestamp = bswap_32( ((UInt32*)fPacketPtr.Ptr)[1]);
363 if (fPacketPtr.Ptr == NULL || fPacketPtr.Len < 20)
365 - timestamp = ntohl( ((UInt32*)fPacketPtr.Ptr)[4]);
366 + timestamp = bswap_32( ((UInt32*)fPacketPtr.Ptr)[4]);
371 if (fPacketPtr.Ptr == NULL || fPacketPtr.Len < 4 || fIsRTCP)
374 - UInt16 sequence = ntohs( ((UInt16*)fPacketPtr.Ptr)[1]); //The RTP sequenc number is the second short of the packet
375 + UInt16 sequence = bswap_16( ((UInt16*)fPacketPtr.Ptr)[1]); //The RTP sequenc number is the second short of the packet
379 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RelayOutput.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RelayOutput.cpp
380 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RelayOutput.cpp 2008-05-06 01:28:58.000000000 +0200
381 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RelayOutput.cpp 2008-05-30 23:32:47.000000000 +0200
386 +#include <byteswap.h>
387 #include "RelayOutput.h"
389 #include "OSMemory.h"
391 char theIPAddrBuf[20];
392 StrPtrLen theIPAddr(theIPAddrBuf, 20);
393 struct in_addr theAddr;
394 - theAddr.s_addr = htonl(fOutputInfo.fDestAddr);
395 + theAddr.s_addr = bswap_32(fOutputInfo.fDestAddr);
396 SocketUtils::ConvertAddrToString(theAddr, &theIPAddr);
398 // Begin writing the HTML
399 @@ -538,14 +539,14 @@
400 StrPtrLen theIPAddr(theIPAddrBuf, 20);
402 struct in_addr theDestAddr; // output destination address
403 - theDestAddr.s_addr = htonl(fOutputInfo.fDestAddr);
404 + theDestAddr.s_addr = bswap_32(fOutputInfo.fDestAddr);
405 SocketUtils::ConvertAddrToString(theDestAddr, &theIPAddr);
407 theErr = QTSS_SetValue (fRelayOutputObject, sOutputDestAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len);
408 Assert(theErr == QTSS_NoErr);
410 struct in_addr theLocalAddr; // output local address
411 - theLocalAddr.s_addr = htonl(fOutputInfo.fLocalAddr);
412 + theLocalAddr.s_addr = bswap_32(fOutputInfo.fLocalAddr);
413 SocketUtils::ConvertAddrToString(theLocalAddr, &theIPAddr);
415 theErr = QTSS_SetValue (fRelayOutputObject, sOutputLocalAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len);
416 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RelaySession.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RelaySession.cpp
417 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RelaySession.cpp 2008-05-06 01:28:58.000000000 +0200
418 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RelaySession.cpp 2008-05-30 23:33:05.000000000 +0200
423 +#include <byteswap.h>
424 #include "RelaySession.h"
425 #include "QTSSModuleUtils.h"
426 #include "SocketUtils.h"
427 @@ -189,14 +190,14 @@
428 StrPtrLen theIPAddr(theIPAddrBuf, 20);
430 struct in_addr theSrcAddr; // source ip address
431 - theSrcAddr.s_addr = htonl(inInfo->GetStreamInfo(0)->fSrcIPAddr);
432 + theSrcAddr.s_addr = bswap_32(inInfo->GetStreamInfo(0)->fSrcIPAddr);
433 SocketUtils::ConvertAddrToString(theSrcAddr, &theIPAddr);
435 theErr = QTSS_SetValue (fRelaySessionObject, sSourceIPAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len);
436 Assert(theErr == QTSS_NoErr);
438 struct in_addr theDestAddr; // dest (of source) ip address
439 - theDestAddr.s_addr = htonl(inInfo->GetStreamInfo(0)->fDestIPAddr);
440 + theDestAddr.s_addr = bswap_32(inInfo->GetStreamInfo(0)->fDestIPAddr);
441 SocketUtils::ConvertAddrToString(theDestAddr, &theIPAddr);
443 theErr = QTSS_SetValue (fRelaySessionObject, sSourceInIPAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len);
444 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RTPSessionOutput.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RTPSessionOutput.cpp
445 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RTPSessionOutput.cpp 2008-05-06 01:28:58.000000000 +0200
446 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RTPSessionOutput.cpp 2008-05-30 23:34:26.000000000 +0200
451 +#include <byteswap.h>
452 +#include <byteswap.h>
453 #include "RTPSessionOutput.h"
454 #include "ReflectorStream.h"
456 @@ -442,18 +444,18 @@
457 //printf("rtptime offset time =%f in scale =%"_U32BITARG_"\n", rtpTimeFromStart, rtpTimeFromStartInScale );
459 theReport += 2; // point to the rtp time stamp of "now" synched and scaled in stream time
460 - *theReport = htonl(baseTimeStamp + rtpTimeFromStartInScale);
461 + *theReport = bswap_32(baseTimeStamp + rtpTimeFromStartInScale);
463 theLen = sizeof(UInt32);
464 UInt32 packetCount = 0;
465 (void) QTSS_GetValue(*theStreamPtr, sStreamPacketCountAttr, 0, &packetCount,&theLen);
466 theReport += 1; // point to the rtp packets sent
467 - *theReport = htonl(ntohl(*theReport) * 2);
468 + *theReport = bswap_32(bswap_32(*theReport) * 2);
470 UInt32 byteCount = 0;
471 (void) QTSS_GetValue(*theStreamPtr, sStreamByteCountAttr, 0, &byteCount,&theLen);
472 theReport += 1; // point to the rtp payload bytes sent
473 - *theReport = htonl(ntohl(*theReport) * 2);
474 + *theReport = bswap_32(bswap_32(*theReport) * 2);
480 //The RTP seq number is the second short of the packet
481 UInt16* seqNumPtr = (UInt16*)inPacket->Ptr;
482 - return ntohs(seqNumPtr[1]);
483 + return bswap_16(seqNumPtr[1]);
486 void RTPSessionOutput::SetPacketSeqNumber(StrPtrLen* inPacket, UInt16 inSeqNumber)
489 //The RTP seq number is the second short of the packet
490 UInt16* seqNumPtr = (UInt16*)inPacket->Ptr;
491 - seqNumPtr[1] = htons(inSeqNumber);
492 + seqNumPtr[1] = bswap_16(inSeqNumber);
495 // this routine is not used
496 diff -ur DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RTSPSourceInfo.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RTSPSourceInfo.cpp
497 --- DarwinStreamingSrvr6.0.3-Source/APIModules/QTSSReflectorModule/RTSPSourceInfo.cpp 2008-05-06 01:28:58.000000000 +0200
498 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/APIModules/QTSSReflectorModule/RTSPSourceInfo.cpp 2008-05-30 23:34:07.000000000 +0200
503 +#include <byteswap.h>
504 #include "RTSPSourceInfo.h"
505 #include "StringParser.h"
506 #include "SDPSourceInfo.h"
508 StrPtrLen temp(buff);
510 struct in_addr theIPAddr;
511 - theIPAddr.s_addr = htonl(ipAddr);
512 + theIPAddr.s_addr = bswap_32(ipAddr);
513 SocketUtils::ConvertAddrToString(theIPAddr, &temp);
515 qtss_sprintf(ipStr, "c=IN IP4 %s", buff);
516 diff -ur DarwinStreamingSrvr6.0.3-Source/Buildit DarwinStreamingSrvr6.0.3-Source.x86_64/Buildit
517 --- DarwinStreamingSrvr6.0.3-Source/Buildit 2008-03-26 01:42:48.000000000 +0100
518 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Buildit 2008-05-31 10:40:58.000000000 +0200
523 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
524 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
530 COMPILER_FLAGS="-D_REENTRANT -D__USE_POSIX -D__linuxppc__ -pipe"
531 - INCLUDE_FLAG="-include"
532 + INCLUDE_FLAG="-include"
534 CORE_LINK_LIBS="-lpthread -ldl -lstdc++ -lm -lcrypt"
544 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
545 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
551 COMPILER_FLAGS="-D_REENTRANT -D__USE_POSIX -D__linux__ -pipe"
552 - INCLUDE_FLAG="-include"
553 + INCLUDE_FLAG="-include"
555 + CORE_LINK_LIBS="-lpthread -ldl -lstdc++ -lm -lcrypt"
560 + if [ -f /usr/include/socketbits.h ]; then
562 + export NEED_SOCKETBITS
567 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
573 + COMPILER_FLAGS="-D_REENTRANT -D__USE_POSIX -D__linux__ -pipe -fPIC"
574 + INCLUDE_FLAG="-include"
576 CORE_LINK_LIBS="-lpthread -ldl -lstdc++ -lm -lcrypt"
578 @@ -108,14 +131,14 @@
582 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
583 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
589 COMPILER_FLAGS="-D_REENTRANT -D__linux__ -Wno-multichar -pipe"
590 - INCLUDE_FLAG="-include"
591 + INCLUDE_FLAG="-include"
593 CORE_LINK_LIBS="-lpthread -ldl -lm -lcrypt"
595 @@ -129,14 +152,14 @@
599 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
600 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
607 - INCLUDE_FLAG="-include"
608 + INCLUDE_FLAG="-include"
610 CORE_LINK_LIBS="-pthread -lm -lcrypt"
612 @@ -147,14 +170,14 @@
616 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
617 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
623 COMPILER_FLAGS="-D__solaris__ -D_REENTRANT -DFD_SETSIZE=65536 -L/usr/local/lib -R/usr/local/lib"
624 - INCLUDE_FLAG="-include"
625 + INCLUDE_FLAG="-include"
627 CORE_LINK_LIBS="-lpthread -ldl -lsocket -lnsl -lresolv -lm -lcrypt -lstdc++"
633 -# IRIX with MipsPro compiler
634 -# Change all references of Makefile.POSIX below to Makefile.IRIX
635 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" SGI platform"
636 + # IRIX with MipsPro compiler
637 + # Change all references of Makefile.POSIX below to Makefile.IRIX
638 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" SGI platform"
642 @@ -179,31 +202,31 @@
647 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
653 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform"
659 - COMPILER_FLAGS="-D__hpux__ -g -fPIC"
660 - INCLUDE_FLAG="-include"
661 + COMPILER_FLAGS="-D__hpux__ -g -fPIC"
662 + INCLUDE_FLAG="-include"
664 - CORE_LINK_LIBS="-lpthread -lnsl -lm -lcrypt -lstdc++"
665 + CORE_LINK_LIBS="-lpthread -lnsl -lm -lcrypt -lstdc++"
668 - MODULE_LIBS="-lgcc -lstdc++"
671 + MODULE_LIBS="-lgcc -lstdc++"
675 - echo "Configuring for the "$OSNAME" "$HARDWARENAME" Tru64 UNIX platform"
676 + echo "Configuring for the "$OSNAME" "$HARDWARENAME" Tru64 UNIX platform"
677 CPLUS=`pwd`/my_tru64_cxx
678 CCOMP=`pwd`/my_tru64_cc
680 MAKE=/usr/local/bin/make
682 COMPILER_FLAGS="-D__osf__ -DTRUCLUSTER -pthread"
686 CORE_LINK_LIBS="-lpthread -lclu -lm"
691 "Darwin.Power Macintosh")
692 - echo "Configuring for "$OSNAME" on "$HARDWARENAME". This is an OS X build of the QuickTimeStreamingServer."
693 + echo "Configuring for "$OSNAME" on "$HARDWARENAME". This is an OS X build of the QuickTimeStreamingServer."
700 COMPILER_FLAGS=-D__linux__
701 - INCLUDE_FLAG="-include"
702 + INCLUDE_FLAG="-include"
704 CORE_LINK_LIBS="-lpthread -ldl -lm -lcrypt"
707 echo Building StreamingServer for $PLAT with $CPLUS
710 - $MAKE -f Makefile.POSIX $*
711 + if [ "$*" = "clean" ] ; then
712 + $MAKE -B -f Makefile.POSIX $*
714 + $MAKE -f Makefile.POSIX $*
717 echo Building RefMovieModule for $PLAT with $CPLUS
718 cd APIModules/QTSSRefMovieModule/
719 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/OSHeaders.h DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/OSHeaders.h
720 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/OSHeaders.h 2008-05-24 02:05:15.000000000 +0200
721 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/OSHeaders.h 2008-05-31 10:30:15.000000000 +0200
722 @@ -122,16 +122,16 @@
723 #elif __linux__ || __linuxppc__ || __FreeBSD__
725 #define _64BITARG_ "q"
726 - #define _S64BITARG_ "lld"
727 - #define _U64BITARG_ "llu"
728 + #define _S32BITARG_ "d"
729 + #define _U32BITARG_ "u"
731 - #define _S32BITARG_ "d"
732 - #define _U32BITARG_ "u"
733 + #define _S64BITARG_ "ld"
734 + #define _U64BITARG_ "lu"
735 #define _SPOINTERSIZEARG_ _S64BITARG_
736 #define _UPOINTERSIZEARG_ _U64BITARG_
738 - #define _S32BITARG_ "d"
739 - #define _U32BITARG_ "u"
740 + #define _S64BITARG_ "lld"
741 + #define _U64BITARG_ "llu"
742 #define _SPOINTERSIZEARG_ _S32BITARG_
743 #define _UPOINTERSIZEARG_ _U32BITARG_
745 @@ -181,14 +181,14 @@
747 #define TW0_CHARS_TO_INT( c1, c2 ) ( c1 << 8 | c2 )
749 - #define kSInt16_Max USHRT_MAX
750 - #define kUInt16_Max USHRT_MAX
751 + #define kSInt16_Max (SInt16) SHRT_MAX
752 + #define kUInt16_Max (UInt16) USHRT_MAX
754 - #define kSInt32_Max LONG_MAX
755 - #define kUInt32_Max ULONG_MAX
756 + #define kSInt32_Max (SInt32) LONG_MAX
757 + #define kUInt32_Max (UInt32) ULONG_MAX
759 - #define kSInt64_Max LONG_LONG_MAX
760 - #define kUInt64_Max ULONG_LONG_MAX
761 + #define kSInt64_Max (SInt64) LONG_LONG_MAX
762 + #define kUInt64_Max (UInt64) ULONG_LONG_MAX
766 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/Socket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/Socket.cpp
767 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/Socket.cpp 2008-05-06 01:28:59.000000000 +0200
768 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/Socket.cpp 2008-05-30 23:35:40.000000000 +0200
773 +#include <byteswap.h>
778 socklen_t len = sizeof(fLocalAddr);
779 ::memset(&fLocalAddr, 0, sizeof(fLocalAddr));
780 fLocalAddr.sin_family = AF_INET;
781 - fLocalAddr.sin_port = htons(port);
782 - fLocalAddr.sin_addr.s_addr = htonl(addr);
783 + fLocalAddr.sin_port = bswap_16(port);
784 + fLocalAddr.sin_addr.s_addr = bswap_32(addr);
790 for (UInt32 x = 0; x < SocketUtils::GetNumIPAddrs(); x++)
792 - if (SocketUtils::GetIPAddr(x) == ntohl(fLocalAddr.sin_addr.s_addr))
793 + if (SocketUtils::GetIPAddr(x) == bswap_32(fLocalAddr.sin_addr.s_addr))
795 fLocalAddrStrPtr = SocketUtils::GetIPAddrStr(x);
798 fLocalAddrBuffer[0]=0;
799 fLocalAddrStrPtr = &fLocalAddrStr;
800 struct in_addr theAddr;
801 - theAddr.s_addr =ntohl(fLocalAddr.sin_addr.s_addr);
802 + theAddr.s_addr =bswap_32(fLocalAddr.sin_addr.s_addr);
803 SocketUtils::ConvertAddrToString(theAddr, &fLocalAddrStr);
805 printf("Socket::GetLocalAddrStr Search IPs failed, numIPs=%d\n",SocketUtils::GetNumIPAddrs());
808 for (UInt32 x = 0; x < SocketUtils::GetNumIPAddrs(); x++)
810 - if (SocketUtils::GetIPAddr(x) == ntohl(fLocalAddr.sin_addr.s_addr))
811 + if (SocketUtils::GetIPAddr(x) == bswap_32(fLocalAddr.sin_addr.s_addr))
813 fLocalDNSStrPtr = SocketUtils::GetDNSNameStr(x);
817 if (fPortStr.Len == kPortBufSizeInBytes)
819 - int temp = ntohs(fLocalAddr.sin_port);
820 + int temp = bswap_16(fLocalAddr.sin_port);
821 qtss_sprintf(fPortBuffer, "%d", temp);
822 fPortStr.Len = ::strlen(fPortBuffer);
824 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/Socket.h DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/Socket.h
825 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/Socket.h 2008-05-06 01:28:59.000000000 +0200
826 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/Socket.h 2008-05-30 23:35:35.000000000 +0200
831 +#include <byteswap.h>
832 #include <netinet/in.h>
836 Bool16 IsBound() { return (Bool16) (fState & kBound); }
838 //If the socket is bound, you may find out to which addr it is bound
839 - UInt32 GetLocalAddr() { return ntohl(fLocalAddr.sin_addr.s_addr); }
840 - UInt16 GetLocalPort() { return ntohs(fLocalAddr.sin_port); }
841 + UInt32 GetLocalAddr() { return bswap_32(fLocalAddr.sin_addr.s_addr); }
842 + UInt16 GetLocalPort() { return bswap_16(fLocalAddr.sin_port); }
844 StrPtrLen* GetLocalAddrStr();
845 StrPtrLen* GetLocalPortStr();
846 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/SocketUtils.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/SocketUtils.cpp
847 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/SocketUtils.cpp 2008-05-06 01:28:59.000000000 +0200
848 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/SocketUtils.cpp 2008-05-30 23:34:48.000000000 +0200
853 +#include <byteswap.h>
858 char* theAddrStr = ::inet_ntoa(sockaddr->sin_addr);
861 - sIPAddrInfoArray[addrArrayIndex].fIPAddr = ntohl(sockaddr->sin_addr.s_addr);
862 + sIPAddrInfoArray[addrArrayIndex].fIPAddr = bswap_32(sockaddr->sin_addr.s_addr);
864 //store the IP addr as a string
865 sIPAddrInfoArray[addrArrayIndex].fIPAddrStr.Len = ::strlen(theAddrStr);
867 char* theAddrStr = ::inet_ntoa(theAddr->sin_addr);
870 - sIPAddrInfoArray[currentIndex].fIPAddr = ntohl(theAddr->sin_addr.s_addr);
871 + sIPAddrInfoArray[currentIndex].fIPAddr = bswap_32(theAddr->sin_addr.s_addr);
873 //store the IP addr as a string
874 sIPAddrInfoArray[currentIndex].fIPAddrStr.Len = ::strlen(theAddrStr);
876 char* theAddrStr = ::inet_ntoa(sin.sin_addr);
879 - sIPAddrInfoArray[currentIndex].fIPAddr = ntohl(sin.sin_addr.s_addr);
880 + sIPAddrInfoArray[currentIndex].fIPAddr = bswap_32(sin.sin_addr.s_addr);
882 //store the IP addr as a string
883 sIPAddrInfoArray[currentIndex].fIPAddrStr.Len = ::strlen(theAddrStr);
885 char* theAddrStr = ::inet_ntoa(addrPtr->sin_addr);
888 - sIPAddrInfoArray[currentIndex].fIPAddr = ntohl(addrPtr->sin_addr.s_addr);
889 + sIPAddrInfoArray[currentIndex].fIPAddr = bswap_32(addrPtr->sin_addr.s_addr);
891 //store the IP addr as a string
892 sIPAddrInfoArray[currentIndex].fIPAddrStr.Len = ::strlen(theAddrStr);
894 if (inAddrStr == NULL)
897 - return ntohl(::inet_addr(inAddrStr));
898 + return bswap_32(::inet_addr(inAddrStr));
901 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/SocketUtils.h DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/SocketUtils.h
902 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/SocketUtils.h 2008-05-06 01:28:59.000000000 +0200
903 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/SocketUtils.h 2008-05-30 23:34:42.000000000 +0200
905 #define __SOCKETUTILS_H__
908 +#include <byteswap.h>
909 #include <sys/socket.h>
910 #include <netinet/in.h>
912 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/TCPSocket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/TCPSocket.cpp
913 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/TCPSocket.cpp 2008-05-06 01:28:59.000000000 +0200
914 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/TCPSocket.cpp 2008-05-30 23:35:46.000000000 +0200
919 +#include <byteswap.h>
920 #include <sys/types.h>
921 #include <sys/socket.h>
922 #include <arpa/inet.h>
925 ::memset(&fRemoteAddr, 0, sizeof(fRemoteAddr));
926 fRemoteAddr.sin_family = AF_INET; /* host byte order */
927 - fRemoteAddr.sin_port = htons(inRemotePort); /* short, network byte order */
928 - fRemoteAddr.sin_addr.s_addr = htonl(inRemoteAddr);
929 + fRemoteAddr.sin_port = bswap_16(inRemotePort); /* short, network byte order */
930 + fRemoteAddr.sin_addr.s_addr = bswap_32(inRemoteAddr);
932 /* don't forget to error check the connect()! */
933 int err = ::connect(fFileDesc, (sockaddr *)&fRemoteAddr, sizeof(fRemoteAddr));
934 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/TCPSocket.h DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/TCPSocket.h
935 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/TCPSocket.h 2008-05-06 01:28:59.000000000 +0200
936 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/TCPSocket.h 2008-05-30 23:35:51.000000000 +0200
938 #ifndef __TCPSOCKET_H__
939 #define __TCPSOCKET_H__
941 +#include <byteswap.h>
944 #include "SafeStdLib.h"
947 //Returns NULL if not currently available.
949 - UInt32 GetRemoteAddr() { return ntohl(fRemoteAddr.sin_addr.s_addr); }
950 - UInt16 GetRemotePort() { return ntohs(fRemoteAddr.sin_port); }
951 + UInt32 GetRemoteAddr() { return bswap_32(fRemoteAddr.sin_addr.s_addr); }
952 + UInt16 GetRemotePort() { return bswap_16(fRemoteAddr.sin_port); }
953 //This function is NOT thread safe!
954 StrPtrLen* GetRemoteAddrStr();
956 diff -ur DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/UDPSocket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/UDPSocket.cpp
957 --- DarwinStreamingSrvr6.0.3-Source/CommonUtilitiesLib/UDPSocket.cpp 2008-05-06 01:28:59.000000000 +0200
958 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/CommonUtilitiesLib/UDPSocket.cpp 2008-05-30 23:36:06.000000000 +0200
963 +#include <byteswap.h>
964 #include <sys/types.h>
965 #include <sys/socket.h>
969 struct sockaddr_in theRemoteAddr;
970 theRemoteAddr.sin_family = AF_INET;
971 - theRemoteAddr.sin_port = htons(inRemotePort);
972 - theRemoteAddr.sin_addr.s_addr = htonl(inRemoteAddr);
973 + theRemoteAddr.sin_port = bswap_16(inRemotePort);
974 + theRemoteAddr.sin_addr.s_addr = bswap_32(inRemoteAddr);
977 int theErr = ::sendto(fFileDesc, inBuffer, inLength, 0, (sockaddr*)&theRemoteAddr, sizeof(theRemoteAddr));
979 if (theRecvLen == -1)
980 return (OS_Error)OSThread::GetErrno();
982 - *outRemoteAddr = ntohl(fMsgAddr.sin_addr.s_addr);
983 - *outRemotePort = ntohs(fMsgAddr.sin_port);
984 + *outRemoteAddr = bswap_32(fMsgAddr.sin_addr.s_addr);
985 + *outRemotePort = bswap_16(fMsgAddr.sin_port);
986 Assert(theRecvLen >= 0);
987 *outRecvLen = (UInt32)theRecvLen;
989 @@ -125,10 +126,10 @@
990 UInt32 localAddr = fLocalAddr.sin_addr.s_addr; // Already in network byte order
993 - if( localAddr == htonl(INADDR_ANY) )
994 - localAddr = htonl(SocketUtils::GetIPAddr(0));
995 + if( localAddr == bswap_32(INADDR_ANY) )
996 + localAddr = bswap_32(SocketUtils::GetIPAddr(0));
998 - theMulti.imr_multiaddr.s_addr = htonl(inRemoteAddr);
999 + theMulti.imr_multiaddr.s_addr = bswap_32(inRemoteAddr);
1000 theMulti.imr_interface.s_addr = localAddr;
1001 int err = setsockopt(fFileDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&theMulti, sizeof(theMulti));
1002 //AssertV(err == 0, OSThread::GetErrno());
1004 OS_Error UDPSocket::LeaveMulticast(UInt32 inRemoteAddr)
1006 struct ip_mreq theMulti;
1007 - theMulti.imr_multiaddr.s_addr = htonl(inRemoteAddr);
1008 - theMulti.imr_interface.s_addr = htonl(fLocalAddr.sin_addr.s_addr);
1009 + theMulti.imr_multiaddr.s_addr = bswap_32(inRemoteAddr);
1010 + theMulti.imr_interface.s_addr = bswap_32(fLocalAddr.sin_addr.s_addr);
1011 int err = setsockopt(fFileDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char*)&theMulti, sizeof(theMulti));
1013 return (OS_Error)OSThread::GetErrno();
1015 diff -ur DarwinStreamingSrvr6.0.3-Source/Makefile.POSIX DarwinStreamingSrvr6.0.3-Source.x86_64/Makefile.POSIX
1016 --- DarwinStreamingSrvr6.0.3-Source/Makefile.POSIX 2008-05-24 07:19:34.000000000 +0200
1017 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Makefile.POSIX 2008-05-31 11:17:29.000000000 +0200
1021 rm -f $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
1022 + rm -f DarwinStreamingServer
1024 .SUFFIXES: .cpp .c .o
1026 diff -ur DarwinStreamingSrvr6.0.3-Source/MP3Broadcaster/BroadcasterMain.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/MP3Broadcaster/BroadcasterMain.cpp
1027 --- DarwinStreamingSrvr6.0.3-Source/MP3Broadcaster/BroadcasterMain.cpp 2008-05-06 01:28:57.000000000 +0200
1028 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/MP3Broadcaster/BroadcasterMain.cpp 2008-05-30 23:00:30.000000000 +0200
1031 struct sigaction act;
1033 -#if defined(sun) || defined(i386) || defined(__MacOSX__) || defined(__sgi__) || defined(__osf__) || defined(__hpux__) || defined(__linuxppc__)
1034 +#if defined(sun) || defined(i386) || defined(__MacOSX__) || defined(__sgi__) || defined(__osf__) || defined(__hpux__) || defined(__linuxppc__) || defined(__linux__)
1035 sigemptyset(&act.sa_mask);
1037 act.sa_handler = (void(*)(int))&SignalEventHandler;
1038 diff -ur DarwinStreamingSrvr6.0.3-Source/MP3Broadcaster/MP3Broadcaster.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/MP3Broadcaster/MP3Broadcaster.cpp
1039 --- DarwinStreamingSrvr6.0.3-Source/MP3Broadcaster/MP3Broadcaster.cpp 2008-05-06 01:28:57.000000000 +0200
1040 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/MP3Broadcaster/MP3Broadcaster.cpp 2008-05-30 23:36:26.000000000 +0200
1045 +#include <byteswap.h>
1046 #include "MP3Broadcaster.h"
1047 #include "MP3MetaInfoUpdater.h"
1048 #include "StringTranslator.h"
1051 struct hostent* theHostent = ::gethostbyname(mIPAddr);
1052 if (theHostent != NULL)
1053 - addr = ntohl(*(UInt32*)(theHostent->h_addr_list[0]));
1054 + addr = bswap_32(*(UInt32*)(theHostent->h_addr_list[0]));
1056 qtss_printf("Couldn't resolve address %s\n", mIPAddr);
1058 diff -ur DarwinStreamingSrvr6.0.3-Source/MP3Broadcaster/MP3FileBroadcaster.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/MP3Broadcaster/MP3FileBroadcaster.cpp
1059 --- DarwinStreamingSrvr6.0.3-Source/MP3Broadcaster/MP3FileBroadcaster.cpp 2008-05-06 01:28:57.000000000 +0200
1060 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/MP3Broadcaster/MP3FileBroadcaster.cpp 2008-05-30 23:36:33.000000000 +0200
1065 +#include <byteswap.h>
1066 #include "MP3FileBroadcaster.h"
1068 //#include <unistd.h>
1072 // next three bytes are length, so go two bytes, copy 4 and mask off one
1073 - int fieldLen = ntohl(OS::GetUInt32FromMemory((UInt32*)(ptr+2))) & 0x00ffffff;
1074 + int fieldLen = bswap_32(OS::GetUInt32FromMemory((UInt32*)(ptr+2))) & 0x00ffffff;
1076 if (!strncmp(ptr, "TP1", 3)) // Artist
1082 - int fieldLen = ntohl(OS::GetUInt32FromMemory((UInt32*)(ptr+4)));
1083 + int fieldLen = bswap_32(OS::GetUInt32FromMemory((UInt32*)(ptr+4)));
1085 // should check compression and encryption flags for these fields, but I
1086 // wouldn't really expect them to be set for title or artist
1087 diff -ur DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/BroadcasterSession.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/BroadcasterSession.cpp
1088 --- DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/BroadcasterSession.cpp 2008-05-06 01:29:00.000000000 +0200
1089 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/BroadcasterSession.cpp 2008-05-30 23:37:53.000000000 +0200
1094 +#include <byteswap.h>
1095 #include "BroadcasterSession.h"
1096 #include "OSMemory.h"
1097 #include "StrPtrLen.h"
1098 @@ -835,10 +836,10 @@
1101 UInt16* theSeqNumP = (UInt16*)inPacket;
1102 - UInt16 theSeqNum = ntohs(theSeqNumP[1]);
1103 + UInt16 theSeqNum = bswap_16(theSeqNumP[1]);
1105 // UInt32* theSsrcP = (UInt32*)inPacket;
1106 -// UInt32 theSSRC = ntohl(theSsrcP[2]);
1107 +// UInt32 theSSRC = bswap_32(theSsrcP[2]);
1109 for (UInt32 x = 0; x < fSDPParser.GetNumStreams(); x++)
1111 @@ -940,11 +941,11 @@
1112 UInt32 *theWriter = (UInt32*)theRRBuffer;
1114 // APP PACKET - QoS info
1115 - *(theWriter++) = htonl(0x80CC0000);
1116 - //*(ia++) = htonl(trk[i].TrackSSRC);
1117 - *(theWriter++) = htonl(0);
1118 - *(theWriter++) = htonl('ack ');
1119 - *(theWriter++) = htonl(0);
1120 + *(theWriter++) = bswap_32(0x80CC0000);
1121 + //*(ia++) = bswap_32(trk[i].TrackSSRC);
1122 + *(theWriter++) = bswap_32(0);
1123 + *(theWriter++) = bswap_32('ack ');
1124 + *(theWriter++) = bswap_32(0);
1126 SInt16 theSeqNumDifference = inCurSeqNum - fStats[inTrackIndex].fHighestSeqNum;
1130 if (theSeqNumDifference > 0)
1132 - *(theWriter++) = htonl(fStats[inTrackIndex].fLastAckedSeqNum + 1);
1133 + *(theWriter++) = bswap_32(fStats[inTrackIndex].fLastAckedSeqNum + 1);
1134 #if BROADCAST_SESSION_DEBUG
1135 qtss_printf("TrackID: %d Acking: %d\n", fSDPParser.GetStreamInfo(inTrackIndex)->fTrackID, fStats[inTrackIndex].fLastAckedSeqNum + 1);
1137 @@ -997,20 +998,20 @@
1140 // We have 1 completed mask. Add it to the packet
1141 - *(theWriter++) = htonl(mask);
1142 + *(theWriter++) = bswap_32(mask);
1144 fStats[inTrackIndex].fLastAckedSeqNum = inCurSeqNum;
1148 // Just ack cur seq num, this is an out of order packet
1149 - *(theWriter++) = htonl(inCurSeqNum);
1150 + *(theWriter++) = bswap_32(inCurSeqNum);
1154 // Set the packet length
1155 UInt16* lenP = (UInt16*)theRRBuffer;
1156 - lenP[1] = htons((theWriter - theWriterStart) - 1); //length in octets - 1
1157 + lenP[1] = bswap_16((theWriter - theWriterStart) - 1); //length in octets - 1
1160 Assert(fStats[inTrackIndex].fDestRTCPPort != 0);
1161 @@ -1037,11 +1038,11 @@
1162 UInt32 *theWriter = (UInt32*)theRRBuffer;
1165 - *(theWriter++) = htonl(0x81c90007); // 1 src RR packet
1166 - //*(theWriter++) = htonl(trk[i].rcvrSSRC);
1167 - *(theWriter++) = htonl(0);
1168 - //*(theWriter++) = htonl(trk[i].TrackSSRC);
1169 - *(theWriter++) = htonl(0);
1170 + *(theWriter++) = bswap_32(0x81c90007); // 1 src RR packet
1171 + //*(theWriter++) = bswap_32(trk[i].rcvrSSRC);
1172 + *(theWriter++) = bswap_32(0);
1173 + //*(theWriter++) = bswap_32(trk[i].TrackSSRC);
1174 + *(theWriter++) = bswap_32(0);
1175 //if (trk[i].rtp_num_received > 0)
1176 // t = ((float)trk[i].rtp_num_lost / (float)trk[i].rtp_num_received) * 256;
1178 @@ -1049,28 +1050,28 @@
1180 //temp = (temp & 0xff) << 24;
1181 //temp |= (trk[i].rtp_num_received & 0x00ffffff);
1182 - *(theWriter++) = htonl(0);
1183 + *(theWriter++) = bswap_32(0);
1184 //temp = (trk[i].seq_num_cycles & 0xffff0000) | (trk[i].last_seq_num & 0x0000ffff);
1185 //*(ia++) = toBigEndian_ulong(temp);
1186 - *(theWriter++) = htonl(0);
1187 + *(theWriter++) = bswap_32(0);
1188 *(theWriter++) = 0; // don't do jitter yet.
1189 *(theWriter++) = 0; // don't do last SR timestamp
1190 *(theWriter++) = 0; // don't do delay since last SR
1192 // APP PACKET - QoS info
1193 - *(theWriter++) = htonl(0x80CC000C);
1194 - //*(ia++) = htonl(trk[i].TrackSSRC);
1195 - *(theWriter++) = htonl(0);
1196 + *(theWriter++) = bswap_32(0x80CC000C);
1197 + //*(ia++) = bswap_32(trk[i].TrackSSRC);
1198 + *(theWriter++) = bswap_32(0);
1199 // this QTSS changes after beta to 'qtss'
1200 - *(theWriter++) = htonl('QTSS');
1201 + *(theWriter++) = bswap_32('QTSS');
1202 //*(ia++) = toBigEndian_ulong(trk[i].rcvrSSRC);
1203 - *(theWriter++) = htonl(0);
1204 - *(theWriter++) = htonl(8); // eight 4-byte quants below
1205 + *(theWriter++) = bswap_32(0);
1206 + *(theWriter++) = bswap_32(8); // eight 4-byte quants below
1207 #define RR 0x72720004
1208 #define PR 0x70720004
1209 #define PD 0x70640002
1210 #define PL 0x706C0004
1211 - *(theWriter++) = htonl(RR);
1212 + *(theWriter++) = bswap_32(RR);
1213 //unsigned int now, secs;
1214 //now = microseconds();
1215 //secs = now - trk[i].last_rtcp_packet_sent_us / USEC_PER_SEC;
1216 @@ -1078,16 +1079,16 @@
1217 // temp = trk[i].bytes_received_since_last_rtcp / secs;
1220 - //*(ia++) = htonl(temp);
1221 - *(theWriter++) = htonl(0);
1222 - *(theWriter++) = htonl(PR);
1223 - //*(ia++) = htonl(trk[i].rtp_num_received);
1224 - *(theWriter++) = htonl(0);
1225 - *(theWriter++) = htonl(PL);
1226 - //*(ia++) = htonl(trk[i].rtp_num_lost);
1227 - *(theWriter++) = htonl(0);
1228 - *(theWriter++) = htonl(PD);
1229 - *(theWriter++) = htonl(0); // should be a short, but we need to pad to a long for the entire RTCP app packet
1230 + //*(ia++) = bswap_32(temp);
1231 + *(theWriter++) = bswap_32(0);
1232 + *(theWriter++) = bswap_32(PR);
1233 + //*(ia++) = bswap_32(trk[i].rtp_num_received);
1234 + *(theWriter++) = bswap_32(0);
1235 + *(theWriter++) = bswap_32(PL);
1236 + //*(ia++) = bswap_32(trk[i].rtp_num_lost);
1237 + *(theWriter++) = bswap_32(0);
1238 + *(theWriter++) = bswap_32(PD);
1239 + *(theWriter++) = bswap_32(0); // should be a short, but we need to pad to a long for the entire RTCP app packet
1241 #if BROADCAST_SESSION_DEBUG
1242 qtss_printf("Sending receiver reports.\n");
1243 diff -ur DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/PlaylistBroadcaster.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/PlaylistBroadcaster.cpp
1244 --- DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/PlaylistBroadcaster.cpp 2008-05-06 01:29:00.000000000 +0200
1245 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/PlaylistBroadcaster.cpp 2008-05-30 23:38:11.000000000 +0200
1250 +#include <byteswap.h>
1253 #include "SafeStdLib.h"
1256 // if the address is a multicast address then we can't announce the broadcast.
1258 - if(SocketUtils::IsMulticastIPAddr(ntohl(inet_addr(broadcastParms->mDestAddress)))) {
1259 + if(SocketUtils::IsMulticastIPAddr(bswap_32(inet_addr(broadcastParms->mDestAddress)))) {
1260 sAnnounceBroadcast = false;
1263 @@ -2082,7 +2083,7 @@
1265 struct sigaction act;
1267 -#if defined(sun) || defined(i386) || defined(__MacOSX__) || defined(__powerpc__) || defined (__sgi_cc__) || defined(__osf__) || defined(__hpux__)
1268 +#if defined(sun) || defined(i386) || defined(__MacOSX__) || defined(__powerpc__) || defined (__sgi_cc__) || defined(__osf__) || defined(__hpux__) || defined(__linux__)
1269 sigemptyset(&act.sa_mask);
1271 act.sa_handler = (void(*)(int))&SignalEventHandler;
1272 diff -ur DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/playlist_elements.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/playlist_elements.cpp
1273 --- DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/playlist_elements.cpp 2008-05-06 01:29:00.000000000 +0200
1274 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/playlist_elements.cpp 2008-05-30 23:38:32.000000000 +0200
1279 +#include <byteswap.h>
1280 #include "playlist_elements.h"
1281 #include "playlist_utils.h"
1284 fData.fSavedSoundDescSize = descSize;
1285 fData.fSavedDataRefIndex ++ ; // it is different than saved so change the index
1287 - packetSDPtr->dataRefIndex = htons(fData.fSavedDataRefIndex);
1288 + packetSDPtr->dataRefIndex = bswap_16(fData.fSavedDataRefIndex);
1292 @@ -168,10 +169,10 @@
1294 //write the SR & SDES headers
1295 UInt32* theSRWriter = (UInt32*)&fData.fSenderReportBuffer;
1296 - *theSRWriter = htonl(0x80c80006);
1297 + *theSRWriter = bswap_32(0x80c80006);
1299 //SDES length is the length of the CName, plus 2 32bit words
1300 - *theSRWriter = htonl(0x81ca0000 + (cNameLen >> 2) + 1);
1301 + *theSRWriter = bswap_32(0x81ca0000 + (cNameLen >> 2) + 1);
1302 ::memcpy(&fData.fSenderReportBuffer[kSenderReportSizeInBytes], theTempCName, cNameLen);
1303 fData.fSenderReportSize = kSenderReportSizeInBytes + cNameLen;
1306 UInt32* theReport = (UInt32*) fData.fSenderReportBuffer;
1309 - *theReport = htonl(fData.fSsrc);
1310 + *theReport = bswap_32(fData.fSsrc);
1313 SInt64* theNTPTimestampP = (SInt64*)theReport;
1315 PlayListUtils::TimeMilli_To_Fixed64Secs(theTime - fData.fStreamStartTime));
1318 - *theReport = htonl(fData.fTimeStamp);
1319 + *theReport = bswap_32(fData.fTimeStamp);
1321 Float64 curTimeInScale = (Float64) (SInt64) PlayListUtils::Milliseconds() / (Float64) PlayListUtils::eMilli; // convert to float seconds
1322 curTimeInScale = curTimeInScale * (Float64) fData.fMovieMediaTypePtr->fTimeScale; // curTime in media time scale
1323 @@ -361,18 +362,18 @@
1324 curTimeInScale = (UInt32) ( (UInt64) curTimeInScale & (UInt64) 0xFFFFFFFF );
1326 //qtss_printf("MediaStream::UpdateSenderReport RTCP timestamp = %"_U32BITARG_"\n",(UInt32) curTimeInScale);
1327 - *theReport = htonl((UInt32) curTimeInScale);
1328 + *theReport = bswap_32((UInt32) curTimeInScale);
1331 fData.fPacketCount = (UInt32) fData.fPacketsSent;
1332 - *theReport = htonl(fData.fPacketCount);
1333 + *theReport = bswap_32(fData.fPacketCount);
1336 fData.fByteCount = (UInt32) fData.fBytesSent;
1337 - *theReport = htonl(fData.fByteCount);
1338 + *theReport = bswap_32(fData.fByteCount);
1341 - *theReport = htonl(fData.fSsrc);
1342 + *theReport = bswap_32(fData.fSsrc);
1344 LogStr("Sender Report\n");
1345 LogUInt("NTP ",(UInt32) ((*theNTPTimestampP) >> 32)," ");
1346 @@ -463,23 +464,23 @@
1348 ::memset(&fLocalAddrRTp, 0, sizeof(fLocalAddrRTp));
1349 fLocalAddrRTp.sin_family = PF_INET;
1350 - fLocalAddrRTp.sin_port = htons(0);
1351 - fLocalAddrRTp.sin_addr.s_addr = htonl(addr);
1352 + fLocalAddrRTp.sin_port = bswap_16(0);
1353 + fLocalAddrRTp.sin_addr.s_addr = bswap_32(addr);
1355 ::memset(&fLocalAddrRTCp, 0, sizeof(fLocalAddrRTCp));
1356 fLocalAddrRTCp.sin_family = PF_INET;
1357 - fLocalAddrRTCp.sin_port = htons(0);
1358 - fLocalAddrRTCp.sin_addr.s_addr = htonl(addr);
1359 + fLocalAddrRTCp.sin_port = bswap_16(0);
1360 + fLocalAddrRTCp.sin_addr.s_addr = bswap_32(addr);
1362 ::memset(&fDestAddrRTp, 0, sizeof(fDestAddrRTp));
1363 fDestAddrRTp.sin_family = PF_INET;
1364 - fDestAddrRTp.sin_port = htons(0);
1365 - fDestAddrRTp.sin_addr.s_addr = htonl(addr);
1366 + fDestAddrRTp.sin_port = bswap_16(0);
1367 + fDestAddrRTp.sin_addr.s_addr = bswap_32(addr);
1369 ::memset(&fDestAddrRTCp, 0, sizeof(fDestAddrRTCp));
1370 fDestAddrRTCp.sin_family = PF_INET;
1371 - fDestAddrRTCp.sin_port = htons(0);
1372 - fDestAddrRTCp.sin_addr.s_addr = htonl(addr);
1373 + fDestAddrRTCp.sin_port = bswap_16(0);
1374 + fDestAddrRTCp.sin_addr.s_addr = bswap_32(addr);
1377 SInt16 UDPSocketPair::Bind(UInt32 addr)
1380 Assert( (PortRTCp & 1) == 1);// must be odd and one more than rtp port
1382 - fLocalAddrRTp.sin_port = htons( (UInt16) PortRTp);
1383 - fLocalAddrRTCp.sin_port = htons( (UInt16) PortRTCp);
1384 + fLocalAddrRTp.sin_port = bswap_16( (UInt16) PortRTp);
1385 + fLocalAddrRTCp.sin_port = bswap_16( (UInt16) PortRTCp);
1387 //qtss_printf("Attempting to bind to rtp port %d \n",PortRTp);
1390 if (destAddrPtr == NULL) break;
1391 if (socket == kInvalidSocket) break;
1393 - //qtss_printf("Sending data to %d. Addr = %d inLength = %d\n", ntohs(theAddr->sin_port), ntohl(theAddr->sin_addr.s_addr), inLength);
1394 + //qtss_printf("Sending data to %d. Addr = %d inLength = %d\n", bswap_16(theAddr->sin_port), bswap_32(theAddr->sin_addr.s_addr), inLength);
1395 ::sendto(socket, inBuffer, inLength, 0, destAddrPtr, sizeof(sockaddr));
1398 @@ -585,14 +586,14 @@
1399 { UInt32 netAddress = inet_addr(destAddress);
1401 fDestAddrRTp = fLocalAddrRTp;
1402 - fDestAddrRTp.sin_port = htons(destPortRTp);
1403 + fDestAddrRTp.sin_port = bswap_16(destPortRTp);
1404 fDestAddrRTp.sin_addr.s_addr = netAddress;
1406 fDestAddrRTCp = fLocalAddrRTCp;
1407 - fDestAddrRTCp.sin_port = htons(destPortRTCp);
1408 + fDestAddrRTCp.sin_port = bswap_16(destPortRTCp);
1409 fDestAddrRTCp.sin_addr.s_addr = netAddress;
1411 - fIsMultiCast = SocketUtils::IsMulticastIPAddr(ntohl(netAddress));
1412 + fIsMultiCast = SocketUtils::IsMulticastIPAddr(bswap_32(netAddress));
1417 UInt32 localAddr = fLocalAddrRTp.sin_addr.s_addr; // Already in network byte order
1420 - if( localAddr == htonl(INADDR_ANY) )
1421 - localAddr = htonl(SocketUtils::GetIPAddr(0));
1422 + if( localAddr == bswap_32(INADDR_ANY) )
1423 + localAddr = bswap_32(SocketUtils::GetIPAddr(0));
1426 struct ip_mreq theMulti;
1428 UInt32 localAddr = fLocalAddrRTp.sin_addr.s_addr; // Already in network byte order
1431 - if( localAddr == htonl(INADDR_ANY) )
1432 - localAddr = htonl(SocketUtils::GetIPAddr(0));
1433 + if( localAddr == bswap_32(INADDR_ANY) )
1434 + localAddr = bswap_32(SocketUtils::GetIPAddr(0));
1437 struct ip_mreq theMulti;
1440 char *offsetPtr = fThePacket + kRTpHeaderSize + sizeof(SoundHeader);
1441 *soundDescriptionPtr = (SoundDescription *) offsetPtr;
1442 - SInt32 descSize = ntohl( (**soundDescriptionPtr).descSize);
1443 + SInt32 descSize = bswap_32( (**soundDescriptionPtr).descSize);
1444 fSoundDescriptionLen = descSize;
1448 if (fThePacket && timeStampPtr && sequencePtr && SSRCPtr && payloadTypeAndMarkPtr)
1450 *payloadTypeAndMarkPtr = header8Ptr[cPayloadType];
1451 - *sequencePtr = ntohs(header16Ptr[cSequenceNumber]);
1452 - *timeStampPtr = ntohl(header32Ptr[cTimeStamp]);
1453 - *SSRCPtr = ntohl(header32Ptr[cSSRC]);
1454 + *sequencePtr = bswap_16(header16Ptr[cSequenceNumber]);
1455 + *timeStampPtr = bswap_32(header32Ptr[cTimeStamp]);
1456 + *SSRCPtr = bswap_32(header32Ptr[cSSRC]);
1461 LogUInt("ssrc = ", SSRC, "\n");
1463 header8Ptr[cPayloadType] = payloadTypeAndMark;
1464 - header16Ptr[cSequenceNumber] = htons(sequence);
1465 - header32Ptr[cTimeStamp] = htonl(timeStamp);
1466 - header32Ptr[cSSRC] = htonl(SSRC);
1467 + header16Ptr[cSequenceNumber] = bswap_16(sequence);
1468 + header32Ptr[cTimeStamp] = bswap_32(timeStamp);
1469 + header32Ptr[cSSRC] = bswap_32(SSRC);
1473 diff -ur DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/playlist_SDPGen.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/playlist_SDPGen.cpp
1474 --- DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/playlist_SDPGen.cpp 2008-05-06 01:29:00.000000000 +0200
1475 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/playlist_SDPGen.cpp 2008-05-30 23:38:54.000000000 +0200
1477 * @APPLE_LICENSE_HEADER_END@
1480 +#include <byteswap.h>
1481 #include "playlist_utils.h"
1482 #include "playlist_SDPGen.h"
1483 #include "playlist_broadcaster.h"
1485 // c=IN IP4 (destinatin ip address)
1488 - if (SocketUtils::IsMulticastIPAddr(ntohl(inet_addr(ipAddress))))
1489 + if (SocketUtils::IsMulticastIPAddr(bswap_32(inet_addr(ipAddress))))
1490 qtss_sprintf(sdpLine, "c=IN IP4 %s/%s\r\n", ipAddress,ttl);
1492 qtss_sprintf(sdpLine, "c=IN IP4 %s\r\n", ipAddress);
1493 diff -ur DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/PLBroadcastDef.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/PLBroadcastDef.cpp
1494 --- DarwinStreamingSrvr6.0.3-Source/PlaylistBroadcaster.tproj/PLBroadcastDef.cpp 2008-05-06 01:29:00.000000000 +0200
1495 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/PlaylistBroadcaster.tproj/PLBroadcastDef.cpp 2008-05-30 23:39:09.000000000 +0200
1497 8.2.99 - rt updated ShowSettings() to display user names for fields instead of C++ member names.
1500 +#include <byteswap.h>
1501 #include "PLBroadcastDef.h"
1502 #include "MyAssert.h"
1503 #include "SocketUtils.h"
1505 struct hostent* theHostent = ::gethostbyname(mDestAddress);
1506 if (theHostent != NULL)
1508 - inAddr = ntohl(*(UInt32*)(theHostent->h_addr_list[0]));
1509 + inAddr = bswap_32(*(UInt32*)(theHostent->h_addr_list[0]));
1511 struct in_addr inAddrStruct;
1513 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom.cpp
1514 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom.cpp 2008-05-06 01:28:59.000000000 +0200
1515 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom.cpp 2008-05-30 23:39:44.000000000 +0200
1517 // -------------------------------------
1520 +#include <byteswap.h>
1523 #include "SafeStdLib.h"
1525 if( !ReadBytes(Offset, (char *)&tempDatum, 2) )
1528 - *Datum = ntohs(tempDatum);
1529 + *Datum = bswap_16(tempDatum);
1534 if( !ReadBytes(Offset, (char *)&tempDatum, 4) )
1537 - *Datum = ntohl(tempDatum);
1538 + *Datum = bswap_32(tempDatum);
1543 if( !ReadBytes(Offset, (char *)&tempDatum, 4) )
1546 - tempDatum = ntohl(tempDatum);
1547 + tempDatum = bswap_32(tempDatum);
1548 *Datum = (UInt64) tempDatum;
1552 if( !ReadBytes(Offset, (char *)&tempDatum, 4) )
1555 - tempDatum = ntohl(tempDatum);
1556 + tempDatum = bswap_32(tempDatum);
1557 *Datum = (SInt64) (SInt32) tempDatum;
1561 if( !ReadSubAtomBytes(AtomPath, (char *)&tempDatum, 2) )
1564 - *Datum = ntohs(tempDatum);
1565 + *Datum = bswap_16(tempDatum);
1570 if( !ReadSubAtomBytes(AtomPath, (char *)&tempDatum, 4) )
1573 - *Datum = ntohl(tempDatum);
1574 + *Datum = bswap_32(tempDatum);
1578 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_dref.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_dref.cpp
1579 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_dref.cpp 2008-05-06 01:28:59.000000000 +0200
1580 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_dref.cpp 2008-05-30 23:39:52.000000000 +0200
1582 // -------------------------------------
1585 +#include <byteswap.h>
1588 #include "SafeStdLib.h"
1589 @@ -345,23 +346,23 @@
1590 for( int loopCount = kMaxMark - 1; loopCount >= 0; loopCount--) {
1592 // Break out of the loop if this is a match/the end of the alias.
1593 - if( ((short)ntohs(AliasVarInfo->what) == kAbsPath) || ((short)ntohs(AliasVarInfo->what) == kEndMark) )
1594 + if( ((short)bswap_16(AliasVarInfo->what) == kAbsPath) || ((short)bswap_16(AliasVarInfo->what) == kEndMark) )
1598 // Otherwise we need to move to the next data unit.
1599 - AliasVarInfo = (varInfo *)((char *)AliasVarInfo + ((ntohs(AliasVarInfo->len) + 1) & ~1) + 4 /* header size */);
1600 + AliasVarInfo = (varInfo *)((char *)AliasVarInfo + ((bswap_16(AliasVarInfo->len) + 1) & ~1) + 4 /* header size */);
1605 // Now that we have the path, we need to strip off the absolute portions
1606 // of it so that we can get at it from our current (relative) root.
1607 - AliasVarInfo->data[ntohs(AliasVarInfo->len)] = '\0';
1608 + AliasVarInfo->data[bswap_16(AliasVarInfo->len)] = '\0';
1610 pathStart = path = AliasVarInfo->data;
1611 - path += ntohs(AliasVarInfo->len);
1612 - int i = ntohs(Alias->nlvlTo);
1613 + path += bswap_16(AliasVarInfo->len);
1614 + int i = bswap_16(Alias->nlvlTo);
1616 while( i && (path > pathStart) ) {
1617 if( *path-- == ':' )
1618 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stco.h DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stco.h
1619 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stco.h 2008-05-06 01:28:59.000000000 +0200
1620 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stco.h 2008-05-30 23:40:44.000000000 +0200
1625 +#include <byteswap.h>
1626 #include <netinet/in.h>
1630 if (Offset && ChunkNumber && (ChunkNumber<=fNumEntries))
1632 if (4 == fOffSetSize)
1633 - *Offset = (UInt64) ntohl( ( (UInt32 *) fTable)[ChunkNumber-1]);
1634 + *Offset = (UInt64) bswap_32( ( (UInt32 *) fTable)[ChunkNumber-1]);
1636 *Offset = (UInt64) QTAtom::NTOH64( ( (UInt64 *) fTable)[ChunkNumber-1]);
1638 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsc.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsc.cpp
1639 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsc.cpp 2008-05-06 01:28:59.000000000 +0200
1640 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsc.cpp 2008-05-30 23:40:51.000000000 +0200
1642 // -------------------------------------
1645 +#include <byteswap.h>
1648 #include "SafeStdLib.h"
1650 if (fNumEntries == 1)
1652 memcpy(&samplesPerChunk, fSampleToChunkTable + (STCB->fCurEntry_GetChunkFirstLastSample * 12) + 4, 4);
1653 - samplesPerChunk = ntohl(samplesPerChunk);
1654 + samplesPerChunk = bswap_32(samplesPerChunk);
1656 prevSamplesPerChunk = ((chunkNumber -1 ) * samplesPerChunk);
1657 totalSamples = chunkNumber * samplesPerChunk;
1659 prevFirstChunk = thisFirstChunk;
1661 memcpy(&thisFirstChunk, fSampleToChunkTable + (STCB->fCurEntry_GetChunkFirstLastSample * 12) + 0, 4);
1662 - thisFirstChunk = ntohl(thisFirstChunk);
1663 + thisFirstChunk = bswap_32(thisFirstChunk);
1664 memcpy(&samplesPerChunk, fSampleToChunkTable + (STCB->fCurEntry_GetChunkFirstLastSample * 12) + 4, 4);
1665 - samplesPerChunk = ntohl(samplesPerChunk);
1666 + samplesPerChunk = bswap_32(samplesPerChunk);
1668 if (prevSamplesPerChunk == 0)
1669 prevSamplesPerChunk = samplesPerChunk;
1670 @@ -347,11 +348,11 @@
1671 prevFirstChunk = thisFirstChunk;
1673 memcpy(&thisFirstChunk, fSampleToChunkTable + (STCB->fCurEntry * 12) + 0, 4);
1674 - thisFirstChunk = ntohl(thisFirstChunk);
1675 + thisFirstChunk = bswap_32(thisFirstChunk);
1676 memcpy(&samplesPerChunk, fSampleToChunkTable + (STCB->fCurEntry * 12) + 4, 4);
1677 - samplesPerChunk = ntohl(samplesPerChunk);
1678 + samplesPerChunk = bswap_32(samplesPerChunk);
1679 memcpy(&sampleDescription, fSampleToChunkTable + (STCB->fCurEntry * 12) + 8, 4);
1680 - sampleDescription = ntohl(sampleDescription);
1681 + sampleDescription = bswap_32(sampleDescription);
1683 thisChunk = thisFirstChunk;
1684 numChunks = thisFirstChunk - prevFirstChunk;
1685 @@ -488,11 +489,11 @@
1687 // Copy this entry's fields.
1688 memcpy(&FirstChunk, fSampleToChunkTable + (STCB->fCurEntry_SampleToChunkInfo * 12) + 0, 4);
1689 - FirstChunk = ntohl(FirstChunk);
1690 + FirstChunk = bswap_32(FirstChunk);
1691 memcpy(&SamplesPerChunk, fSampleToChunkTable + (STCB->fCurEntry_SampleToChunkInfo * 12) + 4, 4);
1692 - SamplesPerChunk = ntohl(SamplesPerChunk);
1693 + SamplesPerChunk = bswap_32(SamplesPerChunk);
1694 memcpy(&SampleDescription, fSampleToChunkTable + (STCB->fCurEntry_SampleToChunkInfo * 12) + 8, 4);
1695 - SampleDescription = ntohl(SampleDescription);
1696 + SampleDescription = bswap_32(SampleDescription);
1699 // Check to see if the sample was actually in the last chunk and
1700 @@ -605,11 +606,11 @@
1702 // Copy this entry's fields.
1703 memcpy(&FirstChunk, fSampleToChunkTable + (CurEntry * 12) + 0, 4);
1704 - FirstChunk = ntohl(FirstChunk);
1705 + FirstChunk = bswap_32(FirstChunk);
1706 memcpy(&SamplesPerChunk, fSampleToChunkTable + (CurEntry * 12) + 4, 4);
1707 - SamplesPerChunk = ntohl(SamplesPerChunk);
1708 + SamplesPerChunk = bswap_32(SamplesPerChunk);
1709 memcpy(&SampleDescription, fSampleToChunkTable + (CurEntry * 12) + 8, 4);
1710 - SampleDescription = ntohl(SampleDescription);
1711 + SampleDescription = bswap_32(SampleDescription);
1714 // Print out a listing.
1715 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsd.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsd.cpp
1716 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsd.cpp 2008-05-06 01:28:59.000000000 +0200
1717 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsd.cpp 2008-05-30 23:41:13.000000000 +0200
1719 // -------------------------------------
1722 +#include <byteswap.h>
1725 #include "SafeStdLib.h"
1728 // Skip over this mini-atom.
1729 memcpy(&tempInt32, pSampleDescriptionTable, 4);
1730 - pSampleDescriptionTable += ntohl(tempInt32);
1731 + pSampleDescriptionTable += bswap_32(tempInt32);
1732 if (pSampleDescriptionTable > maxSampleDescriptionPtr)
1737 // Get this entry's data format.
1738 memcpy(&tempInt32, fTable[CurDesc] + stsdDescPos_DataFormat, 4);
1739 - tempInt32 = ntohl(tempInt32);
1740 + tempInt32 = bswap_32(tempInt32);
1743 // Skip this entry if it does not match.
1745 *Buffer = fTable[CurDesc];
1747 memcpy(&tempInt32, fTable[CurDesc] + stsdDescPos_Size, 4);
1748 - *Length = ntohl(tempInt32);
1749 + *Length = bswap_32(tempInt32);
1755 // Find and return the given sample's data reference index.
1756 memcpy(&tempInt16, fTable[SampleDescriptionID - 1] + stsdDescPos_Index, 2);
1757 - return ntohs(tempInt16);
1758 + return bswap_16(tempInt16);
1762 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stss.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stss.cpp
1763 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stss.cpp 2008-05-06 01:28:59.000000000 +0200
1764 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stss.cpp 2008-05-30 23:41:18.000000000 +0200
1766 // -------------------------------------
1769 +#include <byteswap.h>
1772 #include "SafeStdLib.h"
1775 for ( sampleIndex = 0; sampleIndex < fNumEntries; sampleIndex++ )
1777 - fTable[sampleIndex] = ntohl( fTable[sampleIndex] );
1778 + fTable[sampleIndex] = bswap_32( fTable[sampleIndex] );
1782 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsz.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsz.cpp
1783 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsz.cpp 2008-05-06 01:28:59.000000000 +0200
1784 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsz.cpp 2008-05-30 23:41:26.000000000 +0200
1786 // -------------------------------------
1789 +#include <byteswap.h>
1792 #include "SafeStdLib.h"
1796 for (UInt32 sampleNumber = firstSampleNumber; sampleNumber <= lastSampleNumber; sampleNumber++ )
1797 - *sizePtr += ntohl(fTable[sampleNumber-1]);
1798 + *sizePtr += bswap_32(fTable[sampleNumber-1]);
1802 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsz.h DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsz.h
1803 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stsz.h 2008-05-06 01:28:59.000000000 +0200
1804 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stsz.h 2008-05-30 23:43:15.000000000 +0200
1809 +#include <byteswap.h>
1815 } else if(SampleNumber && (SampleNumber<=fNumEntries)) { \
1816 if( Size != NULL ) \
1817 - *Size = ntohl(fTable[SampleNumber-1]); \
1818 + *Size = bswap_32(fTable[SampleNumber-1]); \
1822 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stts.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stts.cpp
1823 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_stts.cpp 2008-05-06 01:28:59.000000000 +0200
1824 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_stts.cpp 2008-05-30 23:41:31.000000000 +0200
1826 // -------------------------------------
1829 +#include <byteswap.h>
1832 #include "SafeStdLib.h"
1835 // Copy this sample count and duration.
1836 memcpy(&SampleCount, fTimeToSampleTable + (STCB->fMTtSN_CurEntry * 8), 4);
1837 - SampleCount = ntohl(SampleCount);
1838 + SampleCount = bswap_32(SampleCount);
1839 memcpy(&SampleDuration, fTimeToSampleTable + (STCB->fMTtSN_CurEntry * 8) + 4, 4);
1840 - SampleDuration = ntohl(SampleDuration);
1841 + SampleDuration = bswap_32(SampleDuration);
1844 // Can we skip over this entry?
1847 // Copy this sample count and duration.
1848 memcpy(&SampleCount, fTimeToSampleTable + (STCB->fSNtMT_CurEntry * 8), 4);
1849 - SampleCount = ntohl(SampleCount);
1850 + SampleCount = bswap_32(SampleCount);
1851 memcpy(&SampleDuration, fTimeToSampleTable + (STCB->fSNtMT_CurEntry * 8) + 4, 4);
1852 - SampleDuration = ntohl(SampleDuration);
1853 + SampleDuration = bswap_32(SampleDuration);
1856 // Can we skip over this entry?
1859 // Copy this sample count and duration.
1860 memcpy(&SampleCount, fTimeToSampleTable + (CurEntry * 8), 4);
1861 - SampleCount = ntohl(SampleCount);
1862 + SampleCount = bswap_32(SampleCount);
1863 memcpy(&SampleDuration, fTimeToSampleTable + (CurEntry* 8) + 4, 4);
1864 - SampleDuration = ntohl(SampleDuration);
1865 + SampleDuration = bswap_32(SampleDuration);
1867 // Print out a listing.
1868 qtss_printf(" %10"_U32BITARG_" : %10"_U32BITARG_" %10"_U32BITARG_"\n", CurEntry, SampleCount, SampleDuration);
1871 // Copy this sample count and duration.
1872 memcpy(&SampleCount, fTimeToSampleTable + (STCB->fMTtSN_CurEntry * 8), 4);
1873 - SampleCount = ntohl(SampleCount);
1874 + SampleCount = bswap_32(SampleCount);
1875 memcpy(&SampleDuration, fTimeToSampleTable + (STCB->fMTtSN_CurEntry * 8) + 4, 4);
1876 - SampleDuration = ntohl(SampleDuration);
1877 + SampleDuration = bswap_32(SampleDuration);
1880 // Can we skip over this entry?
1883 // Copy this sample count and duration.
1884 memcpy(&SampleCount, fTimeToSampleTable + (STCB->fSNtMT_CurEntry * 8), 4);
1885 - SampleCount = ntohl(SampleCount);
1886 + SampleCount = bswap_32(SampleCount);
1887 memcpy(&SampleOffset, fTimeToSampleTable + (STCB->fSNtMT_CurEntry * 8) + 4, 4);
1888 - SampleOffset = ntohl(SampleOffset);
1889 + SampleOffset = bswap_32(SampleOffset);
1892 // Can we skip over this entry?
1895 // Copy this sample count and duration.
1896 memcpy(&SampleCount, fTimeToSampleTable + (CurEntry * 8), 4);
1897 - SampleCount = ntohl(SampleCount);
1898 + SampleCount = bswap_32(SampleCount);
1899 memcpy(&SampleOffset, fTimeToSampleTable + (CurEntry* 8) + 4, 4);
1900 - SampleOffset = ntohl(SampleOffset);
1901 + SampleOffset = bswap_32(SampleOffset);
1903 // Print out a listing.
1904 qtss_printf(" %10"_U32BITARG_" : %10"_U32BITARG_" %10"_U32BITARG_"\n", CurEntry, SampleCount, SampleOffset);
1905 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_tref.h DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_tref.h
1906 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTAtom_tref.h 2008-05-06 01:28:59.000000000 +0200
1907 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTAtom_tref.h 2008-05-30 23:43:53.000000000 +0200
1912 +#include <byteswap.h>
1913 #include <netinet/in.h>
1917 inline Bool16 TrackReferenceToTrackID(UInt32 TrackReference, UInt32 * TrackID = NULL) \
1918 { if(TrackReference < fNumEntries) { \
1919 if( TrackID != NULL ) \
1920 - *TrackID = ntohl(fTable[TrackReference]); \
1921 + *TrackID = bswap_32(fTable[TrackReference]); \
1925 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTFile.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTFile.cpp
1926 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTFile.cpp 2008-05-06 01:28:59.000000000 +0200
1927 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTFile.cpp 2008-05-30 23:44:05.000000000 +0200
1932 +#include <byteswap.h>
1938 // Swap the AtomLength for little-endian machines.
1940 - atomLength = ntohl(atomLength);
1941 + atomLength = bswap_32(atomLength);
1942 BigAtomLength = (UInt64) atomLength;
1945 @@ -691,12 +692,12 @@
1946 if( !Read(CurPos, (char *)&atomLength, 4) )
1949 - BigAtomLength = (UInt64) ntohl(atomLength);
1950 + BigAtomLength = (UInt64) bswap_32(atomLength);
1952 if( !Read(CurPos, (char *)&AtomType, 4) )
1955 - AtomType = ntohl(AtomType);
1956 + AtomType = bswap_32(AtomType);
1959 // Skip over the rest of the fields.
1963 CurAtomHeaderSize = 4 + 4; // AtomLength + AtomType
1964 - AtomType = ntohl(AtomType);
1965 + AtomType = bswap_32(AtomType);
1967 if ( atomLength == 1 ) //large size atom
1970 NewTOCEntry->TOCID = fNextTOCID++;
1972 NewTOCEntry->AtomType = AtomType;
1973 - NewTOCEntry->beAtomType = htonl(AtomType);
1974 + NewTOCEntry->beAtomType = bswap_32(AtomType);
1976 NewTOCEntry->AtomDataPos = CurPos;
1977 NewTOCEntry->AtomDataLength = BigAtomLength - CurAtomHeaderSize;
1978 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTHintTrack.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTHintTrack.cpp
1979 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTHintTrack.cpp 2008-05-06 01:28:59.000000000 +0200
1980 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTHintTrack.cpp 2008-05-30 23:44:14.000000000 +0200
1982 // -------------------------------------
1985 +#include <byteswap.h>
1988 #include "SafeStdLib.h"
1990 return errInvalidQuickTimeFile;
1992 ::memcpy(&fMaxPacketSize, sampleDescription + 20, 4);
1993 - fMaxPacketSize = ntohl(fMaxPacketSize);
1994 + fMaxPacketSize = bswap_32(fMaxPacketSize);
1996 for( pSampleDescription = (sampleDescription + 24);
1997 pSampleDescription < (sampleDescription + sampleDescriptionLength);
1998 @@ -248,27 +249,27 @@
2000 // Get the entry length and data type of this entry.
2001 ::memcpy( &entryLength, pSampleDescription + 0, 4);
2002 - entryLength = ntohl(entryLength);
2003 + entryLength = bswap_32(entryLength);
2005 ::memcpy( &dataType, pSampleDescription + 4, 4);
2006 - dataType = ntohl(dataType);
2007 + dataType = bswap_32(dataType);
2010 // Process this data type.
2011 switch( dataType ) {
2012 case FOUR_CHARS_TO_INT('t', 'i', 'm', 's'): // tims RTP timescale
2013 ::memcpy(&fRTPTimescale, pSampleDescription + 8, 4);
2014 - fRTPTimescale = ntohl(fRTPTimescale);
2015 + fRTPTimescale = bswap_32(fRTPTimescale);
2018 case FOUR_CHARS_TO_INT('t', 's', 'r', 'o'): // tsro Timestamp random offset
2019 ::memcpy(&fTimestampRandomOffset, pSampleDescription + 8, 4);
2020 - fTimestampRandomOffset = ntohl(fTimestampRandomOffset);
2021 + fTimestampRandomOffset = bswap_32(fTimestampRandomOffset);
2024 case FOUR_CHARS_TO_INT('s', 'n', 'r', 'o'): // snro Sequence number random offset
2025 ::memcpy(&fSequenceNumberRandomOffset, pSampleDescription + 8, 2);
2026 - fSequenceNumberRandomOffset = ntohs(fSequenceNumberRandomOffset);
2027 + fSequenceNumberRandomOffset = bswap_16(fSequenceNumberRandomOffset);
2031 @@ -431,17 +432,17 @@
2032 // need to acquire the header info on every pass
2034 MOVE_WORD( hdrData.hintFlags, samplePacketPtr + 8);
2035 - hdrData.hintFlags = ntohs( hdrData.hintFlags );
2036 + hdrData.hintFlags = bswap_16( hdrData.hintFlags );
2038 MOVE_WORD( hdrData.dataEntryCount, samplePacketPtr + 10);
2039 - hdrData.dataEntryCount = ntohs(hdrData.dataEntryCount);
2040 + hdrData.dataEntryCount = bswap_16(hdrData.dataEntryCount);
2042 hdrData.tlvTimestampOffset = 0;
2044 Bool16 tlvOK = false; // reset tlvSize to 0 if the size value or the tlv flag is invalid
2045 if( hdrData.hintFlags & 0x4 ) do // Extra Information TLV is present
2047 - hdrData.tlvSize = ntohl( *(UInt32*) (samplePacketPtr + 12) );
2048 + hdrData.tlvSize = bswap_32( *(UInt32*) (samplePacketPtr + 12) );
2049 char* tlvParser = samplePacketPtr + 16; // start of tlv data
2050 char* tlvEnd = tlvParser + hdrData.tlvSize;// 1 past the end of tlv data
2053 // if there is a TLV, parse out the 1 field we currently know about, the 'rtpo' field
2054 while (tlvParser + 12 < tlvEnd) // test for the minimum tlv size (size+type+smallest data size)
2056 - UInt32 fieldSize = ntohl( *(UInt32*) tlvParser );
2057 - UInt32 theType = ntohl( *(UInt32*) (tlvParser + 4) );
2058 - UInt32 theData = ntohl( *(UInt32*) (tlvParser + 8) ); //data can't be smaller 4 and we only know about rtpo data
2059 + UInt32 fieldSize = bswap_32( *(UInt32*) tlvParser );
2060 + UInt32 theType = bswap_32( *(UInt32*) (tlvParser + 4) );
2061 + UInt32 theData = bswap_32( *(UInt32*) (tlvParser + 8) ); //data can't be smaller 4 and we only know about rtpo data
2063 if (theType == FOUR_CHARS_TO_INT( 'r', 't', 'p', 'o' )) //'rtpo'
2065 @@ -479,11 +480,11 @@
2068 MOVE_LONG_WORD( hdrData.relativePacketTransmissionTime, samplePacketPtr );
2069 - hdrData.relativePacketTransmissionTime = ntohl(hdrData.relativePacketTransmissionTime);
2070 + hdrData.relativePacketTransmissionTime = bswap_32(hdrData.relativePacketTransmissionTime);
2072 MOVE_WORD( hdrData.rtpHeaderBits, samplePacketPtr + 4);
2073 MOVE_WORD( hdrData.rtpSequenceNumber, samplePacketPtr + 6);
2074 - hdrData.rtpSequenceNumber = ntohs(hdrData.rtpSequenceNumber);
2075 + hdrData.rtpSequenceNumber = bswap_16(hdrData.rtpSequenceNumber);
2080 MOVE_WORD( entryCount, buf );
2081 //::memcpy(&entryCount, buf, 2);
2083 - *numPackets = ntohs(entryCount);
2084 + *numPackets = bswap_16(entryCount);
2088 @@ -729,21 +730,21 @@
2089 trackRefIndex = (SInt8)*(pBuf + 1);
2091 MOVE_WORD( readLength, pBuf + 2);
2092 - cacheHintSampleLen = hintMaxRead = readLength = ntohs(readLength);
2093 + cacheHintSampleLen = hintMaxRead = readLength = bswap_16(readLength);
2095 MOVE_LONG_WORD( mediaSampleNumber, pBuf + 4);
2096 - mediaSampleNumber = ntohl(mediaSampleNumber);
2097 + mediaSampleNumber = bswap_32(mediaSampleNumber);
2099 MOVE_LONG_WORD( readOffset, pBuf + 8);
2100 - readOffset = ntohl(readOffset);
2101 + readOffset = bswap_32(readOffset);
2103 MOVE_WORD( bytesPerCompressionBlock, pBuf + 12);
2104 - bytesPerCompressionBlock = ntohs(bytesPerCompressionBlock);
2105 + bytesPerCompressionBlock = bswap_16(bytesPerCompressionBlock);
2106 if( bytesPerCompressionBlock == 0 )
2107 bytesPerCompressionBlock = 1;
2109 MOVE_WORD( samplesPerCompressionBlock, pBuf + 14);
2110 - samplesPerCompressionBlock = ntohs(samplesPerCompressionBlock);
2111 + samplesPerCompressionBlock = bswap_16(samplesPerCompressionBlock);
2112 if( samplesPerCompressionBlock == 0 )
2113 samplesPerCompressionBlock = 1;
2115 @@ -1192,7 +1193,7 @@
2116 return errInvalidQuickTimeFile;
2118 MOVE_WORD( entryCount, (char *)buf + 0);
2119 - entryCount = ntohs(entryCount);
2120 + entryCount = bswap_16(entryCount);
2121 if( (packetNumber-1) > entryCount )
2122 return errInvalidQuickTimeFile;
2124 @@ -1257,24 +1258,24 @@
2127 // Add in the RTP header.
2128 - tempInt16 = hdrData.rtpHeaderBits | ntohs(0x8000) /* v2 RTP header */;
2129 + tempInt16 = hdrData.rtpHeaderBits | bswap_16(0x8000) /* v2 RTP header */;
2130 COPY_WORD(pPacketOutBuf, &tempInt16);
2132 //TEMP_PRINT_ONE( "QTHintTrack::GetPacket rtpHeaderBits %li.\n", (SInt32)rtpHeaderBits );
2135 - tempInt16 = htons(hdrData.rtpSequenceNumber);
2136 + tempInt16 = bswap_16(hdrData.rtpSequenceNumber);
2137 COPY_WORD(pPacketOutBuf, &tempInt16);
2140 tempInt32 = rtpTimestamp;
2141 tempInt32 += hdrData.tlvTimestampOffset; // rtpo tlv offset
2143 - tempInt32 = htonl(tempInt32);
2144 + tempInt32 = bswap_32(tempInt32);
2145 COPY_LONG_WORD(pPacketOutBuf, &tempInt32);
2148 - tempInt32 = htonl(ssrc);
2149 + tempInt32 = bswap_32(ssrc);
2150 COPY_LONG_WORD(pPacketOutBuf, &tempInt32);
2153 @@ -1321,7 +1322,7 @@
2155 theFrameType = RTPMetaInfoPacket::kPFrameType;
2157 - theFrameType = htons(theFrameType);
2158 + theFrameType = bswap_16(theFrameType);
2159 this->WriteMetaInfoField(RTPMetaInfoPacket::kFrameTypeField, htcb->fRTPMetaInfoFieldArray[fieldCount], &theFrameType, sizeof(theFrameType), &pPacketOutBuf);
2162 @@ -1333,7 +1334,7 @@
2164 case RTPMetaInfoPacket::kSeqNumField:
2166 - tempInt16 = htons(hdrData.rtpSequenceNumber);
2167 + tempInt16 = bswap_16(hdrData.rtpSequenceNumber);
2168 this->WriteMetaInfoField(RTPMetaInfoPacket::kSeqNumField, htcb->fRTPMetaInfoFieldArray[fieldCount], &tempInt16, sizeof(tempInt16), &pPacketOutBuf);
2171 @@ -1365,7 +1366,7 @@
2174 MOVE_WORD( tempInt16, pSampleBuffer + 2);
2175 - tempInt16 = ntohs(tempInt16);
2176 + tempInt16 = bswap_16(tempInt16);
2178 DEEP_DEBUG_PRINT (( "QTHintTrack::GetPacket - ....Sample entry found (size=%u)\n", tempInt16 ) );
2179 packetSize += tempInt16;
2180 @@ -1402,7 +1403,7 @@
2182 // Sample Description Data Mode
2183 MOVE_WORD( tempInt16, pSampleBuffer + 2);
2184 - tempInt16 = ntohs(tempInt16);
2185 + tempInt16 = bswap_16(tempInt16);
2187 DEEP_DEBUG_PRINT(("QTHintTrack::GetPacket - ....Sample Description entry found (size=%u)\n", tempInt16));
2188 packetSize += tempInt16;
2189 @@ -1451,7 +1452,7 @@
2192 // If we do have md, make sure to put the right length in the right place
2193 - thePacketDataLen = htons(thePacketDataLen);
2194 + thePacketDataLen = bswap_16(thePacketDataLen);
2195 COPY_WORD(endOfMetaInfo - 2, &thePacketDataLen);
2198 @@ -1469,10 +1470,10 @@
2201 // Write an uncompressed field
2202 - RTPMetaInfoPacket::FieldName theName = htons(RTPMetaInfoPacket::GetFieldNameForIndex(inFieldIndex));
2203 + RTPMetaInfoPacket::FieldName theName = bswap_16(RTPMetaInfoPacket::GetFieldNameForIndex(inFieldIndex));
2204 COPY_WORD(*ioBuffer, &theName);
2206 - UInt16 theLen = htons((UInt16)inFieldLen);
2207 + UInt16 theLen = bswap_16((UInt16)inFieldLen);
2208 COPY_WORD(*ioBuffer, &theLen);
2211 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTRTPFile.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTRTPFile.cpp
2212 --- DarwinStreamingSrvr6.0.3-Source/QTFileLib/QTRTPFile.cpp 2008-05-06 01:28:59.000000000 +0200
2213 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileLib/QTRTPFile.cpp 2008-05-30 23:57:06.000000000 +0200
2215 // -------------------------------------
2218 +#include <byteswap.h>
2219 +#include <byteswap.h>
2222 #include "SafeStdLib.h"
2224 // Verify that this is an SDP atom.
2225 fFile->Read(globalSDPTOCEntry->AtomDataPos, (char *)&tempAtomType, 4);
2227 - if ( ntohl(tempAtomType) == FOUR_CHARS_TO_INT('s', 'd', 'p', ' ') )
2228 + if ( bswap_32(tempAtomType) == FOUR_CHARS_TO_INT('s', 'd', 'p', ' ') )
2230 haveGlobalSDPAtom = true;
2231 fSDPFileLength += (UInt32) (globalSDPTOCEntry->AtomDataLength - 4);
2232 @@ -1178,7 +1180,7 @@
2233 if (trackEntry->CurPacket) // we have the packet
2235 timeStampP = (UInt32 *)((char *)trackEntry->CurPacket + 4);
2236 - rtpTimestamp = ntohl(*timeStampP);
2237 + rtpTimestamp = bswap_32(*timeStampP);
2241 @@ -1244,7 +1246,7 @@
2242 // Read the sequence number right out of the packet.
2243 ::memcpy(&rtpSequenceNumber, (char *)trackEntry->CurPacket + 2, 2);
2245 - return ntohs(rtpSequenceNumber);
2246 + return bswap_16(rtpSequenceNumber);
2249 Float64 QTRTPFile::GetNextPacket(char ** outPacket, int * outPacketLength)
2250 @@ -1297,7 +1299,7 @@
2253 // Remember the sequence number of this packet.
2254 - firstPacket->LastSequenceNumber = ntohs(*(UInt16 *)((char *)firstPacket->CurPacket + 2));
2255 + firstPacket->LastSequenceNumber = bswap_16(*(UInt16 *)((char *)firstPacket->CurPacket + 2));
2256 firstPacket->LastSequenceNumber -= (UInt16) (firstPacket->BaseSequenceNumberRandomOffset + firstPacket->FileSequenceNumberRandomOffset + firstPacket->SequenceNumberAdditive);
2259 @@ -1533,10 +1535,10 @@
2260 pTimestamp = (UInt32 *)((char *)trackEntry->CurPacket + 4);
2262 if( doSeek || (trackEntry->QualityLevel > kAllPackets) )
2263 - trackEntry->SequenceNumberAdditive += (trackEntry->LastSequenceNumber + 1) - ntohs(*pSequenceNumber);
2264 + trackEntry->SequenceNumberAdditive += (trackEntry->LastSequenceNumber + 1) - bswap_16(*pSequenceNumber);
2266 - *pSequenceNumber = htons( (SInt16) (((SInt32) ntohs(*pSequenceNumber)) + trackEntry->BaseSequenceNumberRandomOffset + trackEntry->FileSequenceNumberRandomOffset + trackEntry->SequenceNumberAdditive));
2267 - *pTimestamp = htonl(ntohl(*pTimestamp) + trackEntry->BaseTimestampRandomOffset + trackEntry->FileTimestampRandomOffset);
2268 + *pSequenceNumber = bswap_16( (SInt16) (((SInt32) bswap_16(*pSequenceNumber)) + trackEntry->BaseSequenceNumberRandomOffset + trackEntry->FileSequenceNumberRandomOffset + trackEntry->SequenceNumberAdditive));
2269 + *pTimestamp = bswap_32(bswap_32(*pTimestamp) + trackEntry->BaseTimestampRandomOffset + trackEntry->FileTimestampRandomOffset);
2272 // Return the packet.
2273 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileTools/QTBroadcaster.tproj/QTBroadcaster.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileTools/QTBroadcaster.tproj/QTBroadcaster.cpp
2274 --- DarwinStreamingSrvr6.0.3-Source/QTFileTools/QTBroadcaster.tproj/QTBroadcaster.cpp 2008-05-06 01:28:58.000000000 +0200
2275 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileTools/QTBroadcaster.tproj/QTBroadcaster.cpp 2008-05-30 23:44:47.000000000 +0200
2280 +#include <byteswap.h>
2283 #include "SafeStdLib.h"
2285 UInt32 value = RTPFile->GetLastPacketTrack()->Cookie2;
2287 in_port_t cookievalue = value;
2288 - sin.sin_port = htons( cookievalue );
2289 + sin.sin_port = bswap_16( cookievalue );
2290 sin.sin_addr.s_addr = inet_addr(IPAddress);
2291 sendto(s, Packet, PacketLength, 0, (struct sockaddr *)&sin, sizeof(struct sockaddr));
2293 diff -ur DarwinStreamingSrvr6.0.3-Source/QTFileTools/QTRTPFileTest.tproj/QTRTPFileTest.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileTools/QTRTPFileTest.tproj/QTRTPFileTest.cpp
2294 --- DarwinStreamingSrvr6.0.3-Source/QTFileTools/QTRTPFileTest.tproj/QTRTPFileTest.cpp 2008-05-06 01:28:58.000000000 +0200
2295 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/QTFileTools/QTRTPFileTest.tproj/QTRTPFileTest.cpp 2008-05-30 23:45:12.000000000 +0200
2300 +#include <byteswap.h>
2303 #include "SafeStdLib.h"
2308 - RTPFile->SetTrackCookies(hinttracks[trackcount], (char *)hinttracks[trackcount], 0);
2309 + RTPFile->SetTrackCookies(hinttracks[trackcount], (char *)intptr_t(hinttracks[trackcount]), 0);
2310 (void)RTPFile->GetSeekTimestamp(hinttracks[trackcount]);
2316 RTPFile->FindTrackEntry(atoi(*argv), &trackListEntry);
2317 - RTPFile->SetTrackCookies(atoi(*argv), (char *)atoi(*argv), 0);
2318 + RTPFile->SetTrackCookies(atoi(*argv), (char *)intptr_t(atoi(*argv)), 0);
2319 (void)RTPFile->GetSeekTimestamp(atoi(*argv));
2325 memcpy(&RTPSequenceNumber, Packet + 2, 2);
2326 - RTPSequenceNumber = ntohs(RTPSequenceNumber);
2327 + RTPSequenceNumber = bswap_16(RTPSequenceNumber);
2328 memcpy(&RTPTimestamp, Packet + 4, 4);
2329 - RTPTimestamp = ntohl(RTPTimestamp);
2330 + RTPTimestamp = bswap_32(RTPTimestamp);
2334 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAckPacket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAckPacket.cpp
2335 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAckPacket.cpp 2008-05-06 01:28:59.000000000 +0200
2336 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAckPacket.cpp 2008-05-30 23:45:39.000000000 +0200
2341 +#include <byteswap.h>
2342 #include "RTCPAckPacket.h"
2343 #include "RTCPPacket.h"
2344 #include "MyAssert.h"
2345 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAckPacketFmt.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAckPacketFmt.h
2346 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAckPacketFmt.h 2008-05-06 01:28:59.000000000 +0200
2347 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAckPacketFmt.h 2008-05-30 23:58:15.000000000 +0200
2349 #ifndef _RTCPACKPACKETFMT_H_
2350 #define _RTCPACKPACKETFMT_H_
2352 +#include <byteswap.h>
2354 #include <arpa/inet.h>
2355 #include "StrPtrLen.h"
2357 //fill in the header
2358 RTCPAckHeader &header = *reinterpret_cast<RTCPAckHeader *>(fBuf.Ptr);
2359 ::memset(&header, 0, sizeof(header));
2360 - header.ackheader = htons(0x80CC); //(RTP_VERSION << 14) + RTCP_APP;
2361 - header.length = htons(GetPacketLen() / 4 - 1);
2362 - header.name = htonl(FOUR_CHARS_TO_INT('q', 't', 'a', 'k'));
2363 + header.ackheader = bswap_16(0x80CC); //(RTP_VERSION << 14) + RTCP_APP;
2364 + header.length = bswap_16(GetPacketLen() / 4 - 1);
2365 + header.name = bswap_32(FOUR_CHARS_TO_INT('q', 't', 'a', 'k'));
2368 void SetSSRC(UInt32 SSRC)
2370 RTCPAckHeader &header = *reinterpret_cast<RTCPAckHeader *>(fBuf.Ptr);
2371 - header.SSRC = htonl(SSRC);
2372 + header.SSRC = bswap_32(SSRC);
2375 //Can handle duplicates
2377 ::qsort(AckList.begin(), AckList.size(), sizeof(UInt32), UInt32Compare);
2379 RTCPAckHeader &header = *reinterpret_cast<RTCPAckHeader *>(fBuf.Ptr);
2380 - header.SSRC1 = htonl(serverSSRC);
2381 - header.seqNum = htons(static_cast<UInt16>(AckList.front()));
2382 + header.SSRC1 = bswap_32(serverSSRC);
2383 + header.seqNum = bswap_16(static_cast<UInt16>(AckList.front()));
2386 if (AckList.front() == AckList.back()) //no mask is needed
2388 UInt32 slotsInMaskNeeded = AckList.back() - AckList.front();
2389 fBitMaskSize = slotsInMaskNeeded % 32 == 0 ? (slotsInMaskNeeded / 32) * 4 : (slotsInMaskNeeded / 32 + 1) * 4;
2391 - header.length = htons(GetPacketLen() / 4 - 1);
2392 + header.length = bswap_16(GetPacketLen() / 4 - 1);
2393 Assert(fBuf.Len >= GetPacketLen());
2395 UInt32 *mask = reinterpret_cast<UInt32 *>(fBuf.Ptr + sizeof(RTCPAckHeader));
2398 //restore big-endianess of the mask
2399 for(UInt32 i = 0; i < fBitMaskSize / 4; ++i)
2400 - mask[i] = htonl(mask[i]);
2401 + mask[i] = bswap_32(mask[i]);
2404 //The length of packet written out
2405 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAckPacket.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAckPacket.h
2406 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAckPacket.h 2008-05-06 01:28:59.000000000 +0200
2407 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAckPacket.h 2008-05-30 23:45:47.000000000 +0200
2409 #ifndef _RTCPACKPACKET_H_
2410 #define _RTCPACKPACKET_H_
2412 +#include <byteswap.h>
2413 #include "OSHeaders.h"
2414 #include "RTCPAPPPacket.h"
2416 @@ -116,12 +117,12 @@
2418 UInt16 RTCPAckPacket::GetAckSeqNum()
2420 - return (UInt16) (ntohl(*(UInt32*)&fRTCPAckBuffer[kAckSeqNumOffset]));
2421 + return (UInt16) (bswap_32(*(UInt32*)&fRTCPAckBuffer[kAckSeqNumOffset]));
2424 inline UInt16 RTCPAckPacket::GetPacketLength()
2426 - return (UInt16) ( ntohl(*(UInt32*)fRTCPAckBuffer) & kPacketLengthMask);
2427 + return (UInt16) ( bswap_32(*(UInt32*)fRTCPAckBuffer) & kPacketLengthMask);
2431 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPNADUPacket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPNADUPacket.cpp
2432 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPNADUPacket.cpp 2008-05-06 01:28:59.000000000 +0200
2433 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPNADUPacket.cpp 2008-05-30 23:50:26.000000000 +0200
2438 +#include <byteswap.h>
2439 #include "RTCPAPPNADUPacket.h"
2440 #include "MyAssert.h"
2442 @@ -131,46 +132,46 @@
2443 UInt32 *theWriterStart = (UInt32*)sRTCPTestBuffer;
2444 UInt32 *theWriter = (UInt32*)sRTCPTestBuffer;
2446 - *(theWriter++) = htonl(0x81c90007); // 1 RR packet header, full report
2447 - *(theWriter++) = htonl(0x2935F2D6); // 1 Sender SSRC = 691401430
2448 - *(theWriter++) = htonl(0x6078CE22); // 1 SSRC_1 = 1618529826
2449 - *(theWriter++) = htonl(0x01000001); // fraction lost | cumulative num packets lost 1% , 1 packet
2450 - *(theWriter++) = htonl(0x0000361A); // extended highest seq number received = 13850
2451 - *(theWriter++) = htonl(0x00C7ED4D); // interarrival jitter = 13102413
2452 - *(theWriter++) = htonl(0x00000000); // LSR last sender report = 0
2453 - *(theWriter++) = htonl(0x04625238); // Delay since last SR (DLSR) = 73552440 (garbage)
2455 - *(theWriter++) = htonl(0x81ca0005); // 1 SDES packet header,
2456 - *(theWriter++) = htonl(0x2935F2D6); // 1 Sender SSRC = 691401430
2457 - *(theWriter++) = htonl(0x010A5344); // 1 CNAME = 01, len=10, "SD"
2458 - *(theWriter++) = htonl(0x45532043); // 1 CNAME = "ES C"
2459 - *(theWriter++) = htonl(0x4e414d45); // 1 CNAME = "NAME"
2460 - *(theWriter++) = htonl(0x00000000); // NULL item = end of list + 32bit padding
2461 + *(theWriter++) = bswap_32(0x81c90007); // 1 RR packet header, full report
2462 + *(theWriter++) = bswap_32(0x2935F2D6); // 1 Sender SSRC = 691401430
2463 + *(theWriter++) = bswap_32(0x6078CE22); // 1 SSRC_1 = 1618529826
2464 + *(theWriter++) = bswap_32(0x01000001); // fraction lost | cumulative num packets lost 1% , 1 packet
2465 + *(theWriter++) = bswap_32(0x0000361A); // extended highest seq number received = 13850
2466 + *(theWriter++) = bswap_32(0x00C7ED4D); // interarrival jitter = 13102413
2467 + *(theWriter++) = bswap_32(0x00000000); // LSR last sender report = 0
2468 + *(theWriter++) = bswap_32(0x04625238); // Delay since last SR (DLSR) = 73552440 (garbage)
2470 + *(theWriter++) = bswap_32(0x81ca0005); // 1 SDES packet header,
2471 + *(theWriter++) = bswap_32(0x2935F2D6); // 1 Sender SSRC = 691401430
2472 + *(theWriter++) = bswap_32(0x010A5344); // 1 CNAME = 01, len=10, "SD"
2473 + *(theWriter++) = bswap_32(0x45532043); // 1 CNAME = "ES C"
2474 + *(theWriter++) = bswap_32(0x4e414d45); // 1 CNAME = "NAME"
2475 + *(theWriter++) = bswap_32(0x00000000); // NULL item = end of list + 32bit padding
2479 - *(theWriter++) = htonl(0x80CC0000); // 1 APP packet header, needs len -> assigned beow
2480 + *(theWriter++) = bswap_32(0x80CC0000); // 1 APP packet header, needs len -> assigned beow
2482 UInt32 *appPacketLenStart = theWriter;
2484 - *(theWriter++) = htonl(FOUR_CHARS_TO_INT('S', 'S', 'R', 'C')); //nadu ssrc
2485 - *(theWriter++) = htonl(FOUR_CHARS_TO_INT('P', 'S', 'S', '0')); //nadu app packet name
2486 + *(theWriter++) = bswap_32(FOUR_CHARS_TO_INT('S', 'S', 'R', 'C')); //nadu ssrc
2487 + *(theWriter++) = bswap_32(FOUR_CHARS_TO_INT('P', 'S', 'S', '0')); //nadu app packet name
2489 // first (typically only) ssrc block
2490 - *(theWriter++) = htonl(0x423A35C7); //ssrc = 1111111111
2491 - *(theWriter++) = htonl(0x2B6756CE); //delay | nsn = 11111 | 22222
2492 - *(theWriter++) = htonl(0xFFFFAD9C); //nun | fbs= 31 | 44444
2493 + *(theWriter++) = bswap_32(0x423A35C7); //ssrc = 1111111111
2494 + *(theWriter++) = bswap_32(0x2B6756CE); //delay | nsn = 11111 | 22222
2495 + *(theWriter++) = bswap_32(0xFFFFAD9C); //nun | fbs= 31 | 44444
2497 // optional 2nd or more ssrc blocks
2498 - *(theWriter++) = htonl(0x84746B8E); //ssrc = 222222222
2499 - *(theWriter++) = htonl(0x2B6756CE); //delay | nsn = 11111 | 22222
2500 - *(theWriter++) = htonl(0xFFFFAD9C); //nun | fbs= 31 | 44444
2501 + *(theWriter++) = bswap_32(0x84746B8E); //ssrc = 222222222
2502 + *(theWriter++) = bswap_32(0x2B6756CE); //delay | nsn = 11111 | 22222
2503 + *(theWriter++) = bswap_32(0xFFFFAD9C); //nun | fbs= 31 | 44444
2505 UInt16 *packetLenOffsetPtr = &( (UInt16*)theWriterStart)[29];
2506 - UInt16 packetLenInWords = htons( ((UInt32*)theWriter - (UInt32*)appPacketLenStart) ) ;
2507 + UInt16 packetLenInWords = bswap_16( ((UInt32*)theWriter - (UInt32*)appPacketLenStart) ) ;
2509 *packetLenOffsetPtr = packetLenInWords;
2510 - qtss_printf("packetLenInWords =%lu\n", ntohs(packetLenInWords));
2511 + qtss_printf("packetLenInWords =%lu\n", bswap_16(packetLenInWords));
2512 UInt32 len = (char*)theWriter - (char*)theWriterStart;
2514 resultPtr->Set(sRTCPTestBuffer, len);
2515 @@ -181,36 +182,36 @@
2516 UInt32 *theWriterStart = (UInt32*)sRTCPTestBuffer;
2517 UInt32 *theWriter = (UInt32*)sRTCPTestBuffer;
2519 - *(theWriter++) = htonl(0x80c90007); // 1 RR packet header, empty len is ok but could be a full report
2520 - *(theWriter++) = htonl(0x2935F2D6); // 1 SSRC = 691401430
2521 - *(theWriter++) = htonl(0x6078CE22); // 1 SSRC_1 = 1618529826
2522 - *(theWriter++) = htonl(0x01000001); // fraction lost | cumulative num packets lost 1% , 1 packet
2523 - *(theWriter++) = htonl(0x0000361A); // extended highest seq number received = 13850
2524 - *(theWriter++) = htonl(0x00C7ED4D); // interarrival jitter = 13102413
2525 - *(theWriter++) = htonl(0x00000000); // LSR last sender report = 0
2526 - *(theWriter++) = htonl(0x04625238); // Delay since last SR (DLSR) = 73552440 (garbage)
2527 + *(theWriter++) = bswap_32(0x80c90007); // 1 RR packet header, empty len is ok but could be a full report
2528 + *(theWriter++) = bswap_32(0x2935F2D6); // 1 SSRC = 691401430
2529 + *(theWriter++) = bswap_32(0x6078CE22); // 1 SSRC_1 = 1618529826
2530 + *(theWriter++) = bswap_32(0x01000001); // fraction lost | cumulative num packets lost 1% , 1 packet
2531 + *(theWriter++) = bswap_32(0x0000361A); // extended highest seq number received = 13850
2532 + *(theWriter++) = bswap_32(0x00C7ED4D); // interarrival jitter = 13102413
2533 + *(theWriter++) = bswap_32(0x00000000); // LSR last sender report = 0
2534 + *(theWriter++) = bswap_32(0x04625238); // Delay since last SR (DLSR) = 73552440 (garbage)
2538 - *(theWriter++) = htonl(0x80CC0000); // 1 APP packet header, needs len -> assigned beow
2539 + *(theWriter++) = bswap_32(0x80CC0000); // 1 APP packet header, needs len -> assigned beow
2541 UInt32 *appPacketLenStart = theWriter;
2543 - *(theWriter++) = htonl(FOUR_CHARS_TO_INT('S', 'S', 'R', 'C')); //nadu ssrc
2544 - *(theWriter++) = htonl(FOUR_CHARS_TO_INT('P', 'S', 'S', '0')); //nadu app packet name
2545 + *(theWriter++) = bswap_32(FOUR_CHARS_TO_INT('S', 'S', 'R', 'C')); //nadu ssrc
2546 + *(theWriter++) = bswap_32(FOUR_CHARS_TO_INT('P', 'S', 'S', '0')); //nadu app packet name
2548 // first (typically only) ssrc block
2549 - *(theWriter++) = htonl(0x423A35C7); //ssrc = 1111111111
2550 - *(theWriter++) = htonl(0x2B6756CE); //delay | nsn = 11111 | 22222
2551 - *(theWriter++) = htonl(0xFFFFAD9C); //nun | fbs= 31 | 44444
2552 + *(theWriter++) = bswap_32(0x423A35C7); //ssrc = 1111111111
2553 + *(theWriter++) = bswap_32(0x2B6756CE); //delay | nsn = 11111 | 22222
2554 + *(theWriter++) = bswap_32(0xFFFFAD9C); //nun | fbs= 31 | 44444
2556 // optional 2nd or more ssrc blocks
2557 - *(theWriter++) = htonl(0x84746B8E); //ssrc = 222222222
2558 - *(theWriter++) = htonl(0x2B6756CE); //delay | nsn = 11111 | 22222
2559 - *(theWriter++) = htonl(0xFFFFAD9C); //nun | fbs= 31 | 44444
2560 + *(theWriter++) = bswap_32(0x84746B8E); //ssrc = 222222222
2561 + *(theWriter++) = bswap_32(0x2B6756CE); //delay | nsn = 11111 | 22222
2562 + *(theWriter++) = bswap_32(0xFFFFAD9C); //nun | fbs= 31 | 44444
2564 UInt16 *packetLenOffsetPtr = &( (UInt16*)theWriterStart)[17];
2565 - UInt16 packetLenInWords = htons( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ;
2566 + UInt16 packetLenInWords = bswap_16( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ;
2568 *packetLenOffsetPtr = packetLenInWords;
2570 @@ -224,27 +225,27 @@
2571 UInt32 *theWriterStart = (UInt32*)sRTCPTestBuffer;
2572 UInt32 *theWriter = (UInt32*)sRTCPTestBuffer;
2574 - *(theWriter++) = htonl(0x80c90000); // 1 RR packet header, empty len is ok but could be a full report
2575 + *(theWriter++) = bswap_32(0x80c90000); // 1 RR packet header, empty len is ok but could be a full report
2577 - *(theWriter++) = htonl(0x80CC0000); // 1 APP packet header, needs len -> assigned beow
2578 + *(theWriter++) = bswap_32(0x80CC0000); // 1 APP packet header, needs len -> assigned beow
2580 UInt32 *appPacketLenStart = theWriter;
2582 - *(theWriter++) = htonl(FOUR_CHARS_TO_INT('S', 'S', 'R', 'C')); //nadu ssrc
2583 - *(theWriter++) = htonl(FOUR_CHARS_TO_INT('P', 'S', 'S', '0')); //nadu app packet name
2584 + *(theWriter++) = bswap_32(FOUR_CHARS_TO_INT('S', 'S', 'R', 'C')); //nadu ssrc
2585 + *(theWriter++) = bswap_32(FOUR_CHARS_TO_INT('P', 'S', 'S', '0')); //nadu app packet name
2587 // first (typically only) ssrc block
2588 - *(theWriter++) = htonl(0x423A35C7); //ssrc = 1111111111
2589 - *(theWriter++) = htonl(0x2B6756CE); //delay | nsn = 11111 | 22222
2590 - *(theWriter++) = htonl(0xFFFFAD9C); //nun | fbs= 31 | 44444
2591 + *(theWriter++) = bswap_32(0x423A35C7); //ssrc = 1111111111
2592 + *(theWriter++) = bswap_32(0x2B6756CE); //delay | nsn = 11111 | 22222
2593 + *(theWriter++) = bswap_32(0xFFFFAD9C); //nun | fbs= 31 | 44444
2595 // optional 2nd or more ssrc blocks
2596 - *(theWriter++) = htonl(0x84746B8E); //ssrc = 222222222
2597 - *(theWriter++) = htonl(0x2B6756CE); //delay | nsn = 11111 | 22222
2598 - *(theWriter++) = htonl(0xFFFFAD9C); //nun | fbs= 31 | 44444
2599 + *(theWriter++) = bswap_32(0x84746B8E); //ssrc = 222222222
2600 + *(theWriter++) = bswap_32(0x2B6756CE); //delay | nsn = 11111 | 22222
2601 + *(theWriter++) = bswap_32(0xFFFFAD9C); //nun | fbs= 31 | 44444
2603 UInt16 *packetLenOffsetPtr = &( (UInt16*)theWriterStart)[3];
2604 - UInt16 packetLenInWords = htons( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ;
2605 + UInt16 packetLenInWords = bswap_16( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ;
2607 *packetLenOffsetPtr = packetLenInWords;
2610 for (; count < fNumBlocks ; count ++)
2612 blockBuffer = fNaduDataBuffer + (count * 3);
2613 - ssrc = (UInt32) ntohl(*(UInt32*)&blockBuffer[kOffsetNaduSSRC]);
2614 + ssrc = (UInt32) bswap_32(*(UInt32*)&blockBuffer[kOffsetNaduSSRC]);
2621 UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3);
2622 - UInt32 ssrc = (UInt32) ntohl(*(UInt32*)&blockBufferPtr[kOffsetNaduSSRC]);
2623 + UInt32 ssrc = (UInt32) bswap_32(*(UInt32*)&blockBufferPtr[kOffsetNaduSSRC]);
2630 UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3);
2631 - UInt16 delay = (UInt16) ( ( ntohl(*(UInt32*)&blockBufferPtr[kOffsetNaduPlayoutDelay]) & kPlayoutMask) >> 16);
2632 + UInt16 delay = (UInt16) ( ( bswap_32(*(UInt32*)&blockBufferPtr[kOffsetNaduPlayoutDelay]) & kPlayoutMask) >> 16);
2639 UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3);
2640 - UInt16 nsn = (UInt16) ( ntohl(blockBufferPtr[kOffsetNSN]) & kNSNMask );
2641 + UInt16 nsn = (UInt16) ( bswap_32(blockBufferPtr[kOffsetNSN]) & kNSNMask );
2648 UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3);
2649 - UInt16 nun = (UInt16) ((ntohl(blockBufferPtr[kOffsetNUN]) & kNUNMask) >> 16);
2650 + UInt16 nun = (UInt16) ((bswap_32(blockBufferPtr[kOffsetNUN]) & kNUNMask) >> 16);
2657 UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3);
2658 - UInt16 fbs = (UInt16) ntohl(blockBufferPtr[kOffsetFBS]) & kFBSMask;
2659 + UInt16 fbs = (UInt16) bswap_32(blockBufferPtr[kOffsetFBS]) & kFBSMask;
2663 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPPacket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPPacket.cpp
2664 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPPacket.cpp 2008-05-06 01:28:59.000000000 +0200
2665 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPPacket.cpp 2008-05-30 23:46:00.000000000 +0200
2670 +#include <byteswap.h>
2671 #include "RTCPAPPPacket.h"
2672 #include "MyAssert.h"
2674 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPPacket.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPPacket.h
2675 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPPacket.h 2008-05-06 01:28:59.000000000 +0200
2676 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPPacket.h 2008-05-30 23:46:06.000000000 +0200
2678 #ifndef _RTCPAPPPACKET_H_
2679 #define _RTCPAPPPACKET_H_
2681 +#include <byteswap.h>
2682 #include "RTCPPacket.h"
2683 #include "StrPtrLen.h"
2684 #include "ResizeableStringFormatter.h"
2689 - return ntohl(packetName);
2690 + return bswap_32(packetName);
2694 inline UInt32 RTCPAPPPacket::GetAppPacketSSRC()
2696 - return (UInt32) ntohl(*(UInt32*)&(GetPacketBuffer()[kAppSSRCOffset]) ) ;
2697 + return (UInt32) bswap_32(*(UInt32*)&(GetPacketBuffer()[kAppSSRCOffset]) ) ;
2701 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPQTSSPacket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPQTSSPacket.cpp
2702 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPQTSSPacket.cpp 2008-05-06 01:28:59.000000000 +0200
2703 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPQTSSPacket.cpp 2008-05-30 23:50:02.000000000 +0200
2708 +#include <byteswap.h>
2709 #include "RTCPAPPQTSSPacket.h"
2710 #include "MyAssert.h"
2713 // DMS - There is no guarentee that qtssDataBuffer will be 4 byte aligned, because
2714 // individual APP packet fields can be 6 bytes or 4 bytes or 8 bytes. So we have to
2715 // use the 4-byte align protection functions. Sparc and MIPS processors will crash otherwise
2716 - UInt32 theHeader = ntohl(OS::GetUInt32FromMemory((UInt32*)&qtssDataBuffer[kQTSSItemTypeOffset]));
2717 + UInt32 theHeader = bswap_32(OS::GetUInt32FromMemory((UInt32*)&qtssDataBuffer[kQTSSItemTypeOffset]));
2718 UInt16 itemType = (UInt16)((theHeader & kQTSSItemTypeMask) >> kQTSSItemTypeShift);
2719 UInt8 itemVersion = (UInt8)((theHeader & kQTSSItemVersionMask) >> kQTSSItemVersionShift);
2720 UInt8 itemLengthInBytes = (UInt8)(theHeader & kQTSSItemLengthMask);
2723 case TW0_CHARS_TO_INT( 'r', 'r' ): //'rr': //'rrcv':
2725 - fReceiverBitRate = ntohl(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2726 + fReceiverBitRate = bswap_32(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2727 qtssDataBuffer += sizeof(fReceiverBitRate);
2728 APPEND_TO_DUMP_ARRAY(", rcvr_bit_rate=%"_U32BITARG_"", fReceiverBitRate);
2732 case TW0_CHARS_TO_INT('l', 't'): //'lt': //'late':
2734 - fAverageLateMilliseconds = ntohs(*(UInt16*)qtssDataBuffer);
2735 + fAverageLateMilliseconds = bswap_16(*(UInt16*)qtssDataBuffer);
2736 qtssDataBuffer += sizeof(fAverageLateMilliseconds);
2737 APPEND_TO_DUMP_ARRAY(", avg_late=%u", fAverageLateMilliseconds);
2741 case TW0_CHARS_TO_INT('l', 's'): // 'ls': //'loss':
2743 - fPercentPacketsLost = ntohs(*(UInt16*)qtssDataBuffer);
2744 + fPercentPacketsLost = bswap_16(*(UInt16*)qtssDataBuffer);
2745 qtssDataBuffer += sizeof(fPercentPacketsLost);
2746 APPEND_TO_DUMP_ARRAY(", percent_loss=%u", fPercentPacketsLost);
2750 case TW0_CHARS_TO_INT('d', 'l'): //'dl': //'bdly':
2752 - fAverageBufferDelayMilliseconds = ntohs(*(UInt16*)qtssDataBuffer);
2753 + fAverageBufferDelayMilliseconds = bswap_16(*(UInt16*)qtssDataBuffer);
2754 qtssDataBuffer += sizeof(fAverageBufferDelayMilliseconds);
2755 APPEND_TO_DUMP_ARRAY(", avg_buf_delay=%u", fAverageBufferDelayMilliseconds);
2757 @@ -196,19 +197,19 @@
2759 case TW0_CHARS_TO_INT('e', 'y' ): //'ey': //'eyes':
2761 - fNumEyes = ntohl(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2762 + fNumEyes = bswap_32(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2763 qtssDataBuffer += sizeof(fNumEyes);
2764 APPEND_TO_DUMP_ARRAY(", eyes=%"_U32BITARG_"", fNumEyes);
2766 if (itemLengthInBytes >= 2)
2768 - fNumEyesActive = ntohl(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2769 + fNumEyesActive = bswap_32(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2770 qtssDataBuffer += sizeof(fNumEyesActive);
2771 APPEND_TO_DUMP_ARRAY(", eyes_actv=%"_U32BITARG_"", fNumEyesActive);
2773 if (itemLengthInBytes >= 3)
2775 - fNumEyesPaused = ntohl(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2776 + fNumEyesPaused = bswap_32(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2777 qtssDataBuffer += sizeof(fNumEyesPaused);
2778 APPEND_TO_DUMP_ARRAY(", eyes_pausd=%"_U32BITARG_"", fNumEyesPaused);
2782 case TW0_CHARS_TO_INT('p', 'r' ): // 'pr': //'prcv':
2784 - fTotalPacketsReceived = ntohl(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2785 + fTotalPacketsReceived = bswap_32(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2786 qtssDataBuffer += sizeof(fTotalPacketsReceived);
2787 APPEND_TO_DUMP_ARRAY(", pckts_rcvd=%"_U32BITARG_"", fTotalPacketsReceived);
2791 case TW0_CHARS_TO_INT('p', 'd'): //'pd': //'pdrp':
2793 - fTotalPacketsDropped = ntohs(*(UInt16*)qtssDataBuffer);
2794 + fTotalPacketsDropped = bswap_16(*(UInt16*)qtssDataBuffer);
2795 qtssDataBuffer += sizeof(fTotalPacketsDropped);
2796 APPEND_TO_DUMP_ARRAY(", pckts_drppd=%u", fTotalPacketsDropped);
2800 case TW0_CHARS_TO_INT('p', 'l'): //'pl': //'p???':
2802 - fTotalPacketsLost = ntohs(*(UInt16*)qtssDataBuffer);
2803 + fTotalPacketsLost = bswap_16(*(UInt16*)qtssDataBuffer);
2804 qtssDataBuffer += sizeof(fTotalPacketsLost);
2805 APPEND_TO_DUMP_ARRAY(", ttl_pckts_lost=%u", fTotalPacketsLost);
2809 case TW0_CHARS_TO_INT('b', 'l'): //'bl': //'bufl':
2811 - fClientBufferFill = ntohs(*(UInt16*)qtssDataBuffer);
2812 + fClientBufferFill = bswap_16(*(UInt16*)qtssDataBuffer);
2813 qtssDataBuffer += sizeof(fClientBufferFill);
2814 APPEND_TO_DUMP_ARRAY(", buffr_fill=%u", fClientBufferFill);
2818 case TW0_CHARS_TO_INT('f', 'r'): //'fr': //'frat':
2820 - fFrameRate = ntohs(*(UInt16*)qtssDataBuffer);
2821 + fFrameRate = bswap_16(*(UInt16*)qtssDataBuffer);
2822 qtssDataBuffer += sizeof(fFrameRate);
2823 APPEND_TO_DUMP_ARRAY(", frame_rate=%u", fFrameRate);
2827 case TW0_CHARS_TO_INT('x', 'r'): //'xr': //'xrat':
2829 - fExpectedFrameRate = ntohs(*(UInt16*)qtssDataBuffer);
2830 + fExpectedFrameRate = bswap_16(*(UInt16*)qtssDataBuffer);
2831 qtssDataBuffer += sizeof(fExpectedFrameRate);
2832 APPEND_TO_DUMP_ARRAY(", xpectd_frame_rate=%u", fExpectedFrameRate);
2836 case TW0_CHARS_TO_INT('d', '#'): //'d#': //'dry#':
2838 - fAudioDryCount = ntohs(*(UInt16*)qtssDataBuffer);
2839 + fAudioDryCount = bswap_16(*(UInt16*)qtssDataBuffer);
2840 qtssDataBuffer += sizeof(fAudioDryCount);
2841 APPEND_TO_DUMP_ARRAY(", aud_dry_count=%u", fAudioDryCount);
2845 case TW0_CHARS_TO_INT('o', 'b'): //'ob': // overbuffer window size
2847 - fOverbufferWindowSize = ntohl(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2848 + fOverbufferWindowSize = bswap_32(OS::GetUInt32FromMemory((UInt32*)qtssDataBuffer));
2849 qtssDataBuffer += sizeof(fOverbufferWindowSize);
2850 APPEND_TO_DUMP_ARRAY(", ovr_buffr_windw_siz=%"_U32BITARG_"", fOverbufferWindowSize);
2852 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPQTSSPacket.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPQTSSPacket.h
2853 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPAPPQTSSPacket.h 2008-05-06 01:28:59.000000000 +0200
2854 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPAPPQTSSPacket.h 2008-05-31 00:02:44.000000000 +0200
2856 #ifndef _RTCPAPPQTSSPACKET_H_
2857 #define _RTCPAPPQTSSPACKET_H_
2859 +#include <byteswap.h>
2860 #include "RTCPAPPPacket.h"
2861 #include "StrPtrLen.h"
2863 @@ -143,21 +144,21 @@
2865 inline UInt32 RTCPCompressedQTSSPacket::GetQTSSReportSourceID()
2867 - return (UInt32) ntohl( ((UInt32*)this->GetPacketBuffer())[kQTSSReportSourceIDOffset] ) ;
2868 + return (UInt32) bswap_32( ((UInt32*)this->GetPacketBuffer())[kQTSSReportSourceIDOffset] ) ;
2872 inline UInt16 RTCPCompressedQTSSPacket::GetQTSSPacketVersion()
2874 UInt32 field = ((UInt32*)this->GetPacketBuffer())[kQTSSPacketVersionOffset];
2875 - UInt16 vers = (UInt16) ( ( ntohl(field) & kQTSSPacketVersionMask) >> kQTSSPacketVersionShift );
2876 + UInt16 vers = (UInt16) ( ( bswap_32(field) & kQTSSPacketVersionMask) >> kQTSSPacketVersionShift );
2880 inline UInt16 RTCPCompressedQTSSPacket::GetQTSSPacketLength()
2882 UInt32 field = ((UInt32*)this->GetPacketBuffer())[kQTSSPacketLengthOffset];
2883 - return (UInt16) ( (UInt32) ntohl(field) & kQTSSPacketLengthMask );
2884 + return (UInt16) ( (UInt32) bswap_32(field) & kQTSSPacketLengthMask );
2888 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPNADUPacketFmt.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPNADUPacketFmt.h
2889 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPNADUPacketFmt.h 2008-05-06 01:28:59.000000000 +0200
2890 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPNADUPacketFmt.h 2008-05-30 23:57:32.000000000 +0200
2892 #ifndef _RTCPNADUPACKETFMT_H_
2893 #define _RTCPNADUPACKETFMT_H_
2895 +#include <byteswap.h>
2896 #include "StrPtrLen.h"
2897 #include "arpa/inet.h"
2898 #include "OSHeaders.h"
2900 //fill in the header
2901 NADUHeader &header = *reinterpret_cast<NADUHeader *>(fBuf.Ptr);
2902 ::memset(&header, 0, sizeof(header));
2903 - header.naduHeader = htons(0x80CC); //(RTP_VERSION << 14) + RTCP_APP;
2904 - header.name = htonl(FOUR_CHARS_TO_INT('P', 'S', 'S', '0'));
2905 - header.length = htons(GetPacketLen() / 4 - 1);
2906 + header.naduHeader = bswap_16(0x80CC); //(RTP_VERSION << 14) + RTCP_APP;
2907 + header.name = bswap_32(FOUR_CHARS_TO_INT('P', 'S', 'S', '0'));
2908 + header.length = bswap_16(GetPacketLen() / 4 - 1);
2911 //units are in milliseconds and in bytes; use a playoutDelay of kUInt32_Max if the buffer is empty
2912 @@ -102,22 +103,22 @@
2913 ::memset(&nadu, 0, sizeof(NADUBlock));
2916 - reinterpret_cast<NADUHeader *>(fBuf.Ptr)->length = htons(GetPacketLen() / 4 - 1);
2917 + reinterpret_cast<NADUHeader *>(fBuf.Ptr)->length = bswap_16(GetPacketLen() / 4 - 1);
2919 - nadu.SSRC = htonl(SSRC);
2920 - nadu.NSN = htons(static_cast<UInt16>(nextSeqNum));
2921 - nadu.NUN = htons(nextUnitNum & 0x1F);
2922 + nadu.SSRC = bswap_32(SSRC);
2923 + nadu.NSN = bswap_16(static_cast<UInt16>(nextSeqNum));
2924 + nadu.NUN = bswap_16(nextUnitNum & 0x1F);
2926 //Use reserved value of 0xffff for undefined
2927 playoutDelay = MIN(0xffff, playoutDelay);
2928 - nadu.delay = htons(static_cast<UInt16>(playoutDelay));
2929 + nadu.delay = bswap_16(static_cast<UInt16>(playoutDelay));
2931 //the free buffer space is reported in 64 bytes blocks, and maximum value is 0xffff
2932 freeBufferSpace = MIN(0xffff, freeBufferSpace / 64);
2933 - nadu.FBS = htons(static_cast<UInt16>(freeBufferSpace));
2934 + nadu.FBS = bswap_16(static_cast<UInt16>(freeBufferSpace));
2937 - void SetSSRC(UInt32 SSRC) { reinterpret_cast<NADUHeader *>(fBuf.Ptr)->SSRC = htonl(SSRC); }
2938 + void SetSSRC(UInt32 SSRC) { reinterpret_cast<NADUHeader *>(fBuf.Ptr)->SSRC = bswap_32(SSRC); }
2940 //The length of packet written out
2941 UInt32 GetPacketLen() { return sizeof(NADUHeader) + sizeof(NADUBlock) * fNumNADUBlocks; }
2942 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPPacket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPPacket.cpp
2943 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPPacket.cpp 2008-05-06 01:28:59.000000000 +0200
2944 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPPacket.cpp 2008-05-31 00:02:17.000000000 +0200
2949 +#include <byteswap.h>
2950 #include "RTCPPacket.h"
2951 #include "RTCPAckPacket.h"
2956 fReceiverPacketBuffer = inPacketBuffer;
2957 - if (RTCP_PACKET_DEBUG) qtss_printf("RTCPPacket::ParsePacket first 4 bytes of packet=%x \n", ntohl( *(UInt32 *)inPacketBuffer));
2958 + if (RTCP_PACKET_DEBUG) qtss_printf("RTCPPacket::ParsePacket first 4 bytes of packet=%x \n", bswap_32( *(UInt32 *)inPacketBuffer));
2960 //the length of this packet can be no less than the advertised length (which is
2961 //in 32-bit words, so we must multiply) plus the size of the header (4 bytes)
2962 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPPacket.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPPacket.h
2963 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPPacket.h 2008-05-06 01:28:59.000000000 +0200
2964 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPPacket.h 2008-05-30 23:46:17.000000000 +0200
2966 #ifndef _RTCPPACKET_H_
2967 #define _RTCPPACKET_H_
2969 +#include <byteswap.h>
2971 #include "SafeStdLib.h"
2973 @@ -185,14 +186,14 @@
2974 SInt64 GetNTPTimeStamp()
2976 UInt32* fieldPtr = (UInt32*)&fReceiverPacketBuffer[kSRPacketNTPTimeStampMSW];
2977 - SInt64 timestamp = ntohl(*fieldPtr);
2978 + SInt64 timestamp = bswap_32(*fieldPtr);
2979 fieldPtr = (UInt32*)&fReceiverPacketBuffer[kSRPacketNTPTimeStampLSW];
2980 - return (timestamp << 32) | ntohl(*fieldPtr);
2981 + return (timestamp << 32) | bswap_32(*fieldPtr);
2983 UInt32 GetRTPTimeStamp()
2985 UInt32* fieldPtr = (UInt32*)&fReceiverPacketBuffer[kSRPacketRTPTimeStamp];
2986 - return ntohl(*fieldPtr);
2987 + return bswap_32(*fieldPtr);
2991 @@ -209,46 +210,46 @@
2992 inline int RTCPPacket::GetVersion()
2994 UInt32* theVersionPtr = (UInt32*)&fReceiverPacketBuffer[kVersionOffset];
2995 - UInt32 theVersion = ntohl(*theVersionPtr);
2996 + UInt32 theVersion = bswap_32(*theVersionPtr);
2997 return (int) ((theVersion & kVersionMask) >> kVersionShift);
3000 inline Bool16 RTCPPacket::GetHasPadding()
3002 UInt32* theHasPaddingPtr = (UInt32*)&fReceiverPacketBuffer[kHasPaddingOffset];
3003 - UInt32 theHasPadding = ntohl(*theHasPaddingPtr);
3004 + UInt32 theHasPadding = bswap_32(*theHasPaddingPtr);
3005 return (Bool16) (theHasPadding & kHasPaddingMask);
3008 inline int RTCPPacket::GetReportCount()
3010 UInt32* theReportCountPtr = (UInt32*)&fReceiverPacketBuffer[kReportCountOffset];
3011 - UInt32 theReportCount = ntohl(*theReportCountPtr);
3012 + UInt32 theReportCount = bswap_32(*theReportCountPtr);
3013 return (int) ((theReportCount & kReportCountMask) >> kReportCountShift);
3016 inline UInt8 RTCPPacket::GetPacketType()
3018 UInt32* thePacketTypePtr = (UInt32*)&fReceiverPacketBuffer[kPacketTypeOffset];
3019 - UInt32 thePacketType = ntohl(*thePacketTypePtr);
3020 + UInt32 thePacketType = bswap_32(*thePacketTypePtr);
3021 return (UInt8) ((thePacketType & kPacketTypeMask) >> kPacketTypeShift);
3024 inline UInt16 RTCPPacket::GetPacketLength()
3026 UInt32* fieldPtr = (UInt32*)&fReceiverPacketBuffer[kPacketLengthOffset];
3027 - UInt32 field = ntohl(*fieldPtr);
3028 + UInt32 field = bswap_32(*fieldPtr);
3029 return (UInt16) (field & kPacketLengthMask);
3032 inline UInt32 RTCPPacket::GetPacketSSRC()
3034 UInt32* fieldPtr = (UInt32*)&fReceiverPacketBuffer[kPacketSourceIDOffset];
3035 - UInt32 field = ntohl(*fieldPtr);
3036 + UInt32 field = bswap_32(*fieldPtr);
3040 -inline SInt16 RTCPPacket::GetHeader(){ return (SInt16) ntohs(*(SInt16*)&fReceiverPacketBuffer[0]) ;}
3041 +inline SInt16 RTCPPacket::GetHeader(){ return (SInt16) bswap_16(*(SInt16*)&fReceiverPacketBuffer[0]) ;}
3043 /************** RTCPReceiverPacket inlines **************/
3044 inline int RTCPReceiverPacket::RecordOffset(int inReportNum)
3045 @@ -259,41 +260,41 @@
3047 inline UInt32 RTCPReceiverPacket::GetReportSourceID(int inReportNum)
3049 - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kReportSourceIDOffset]) ;
3050 + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kReportSourceIDOffset]) ;
3053 inline UInt8 RTCPReceiverPacket::GetFractionLostPackets(int inReportNum)
3055 - return (UInt8) ( (ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kFractionLostOffset]) & kFractionLostMask) >> kFractionLostShift );
3056 + return (UInt8) ( (bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kFractionLostOffset]) & kFractionLostMask) >> kFractionLostShift );
3060 inline UInt32 RTCPReceiverPacket::GetTotalLostPackets(int inReportNum)
3062 - return (ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kTotalLostPacketsOffset]) & kTotalLostPacketsMask );
3063 + return (bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kTotalLostPacketsOffset]) & kTotalLostPacketsMask );
3067 inline UInt32 RTCPReceiverPacket::GetHighestSeqNumReceived(int inReportNum)
3069 - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kHighestSeqNumReceivedOffset]) ;
3070 + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kHighestSeqNumReceivedOffset]) ;
3073 inline UInt32 RTCPReceiverPacket::GetJitter(int inReportNum)
3075 - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kJitterOffset]) ;
3076 + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kJitterOffset]) ;
3080 inline UInt32 RTCPReceiverPacket::GetLastSenderReportTime(int inReportNum)
3082 - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportOffset]) ;
3083 + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportOffset]) ;
3087 inline UInt32 RTCPReceiverPacket::GetLastSenderReportDelay(int inReportNum)
3089 - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportDelayOffset]) ;
3090 + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportDelayOffset]) ;
3094 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPRRPacket.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPRRPacket.h
3095 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPRRPacket.h 2008-05-06 01:28:59.000000000 +0200
3096 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPRRPacket.h 2008-05-30 23:50:45.000000000 +0200
3098 #ifndef _RTCPRRPACKET_H_
3099 #define _RTCPRRPACKET_H_
3101 +#include <byteswap.h>
3102 #include "StrPtrLen.h"
3103 #include "arpa/inet.h"
3104 #include "OSHeaders.h"
3106 //fill in the header
3107 RTCPRRHeader &header = *reinterpret_cast<RTCPRRHeader *>(fBuf.Ptr);
3108 ::memset(&header, 0, sizeof(header));
3109 - header.rrheader = htons(0x80C9); //(RTP_VERSION << 14) + RTCP_RR;
3110 - header.length = htons(GetPacketLen() / 4 - 1);
3111 + header.rrheader = bswap_16(0x80C9); //(RTP_VERSION << 14) + RTCP_RR;
3112 + header.length = bswap_16(GetPacketLen() / 4 - 1);
3115 - void SetSSRC(UInt32 SSRC) { reinterpret_cast<RTCPRRHeader *>(fBuf.Ptr)->SSRC = htonl(SSRC); }
3116 + void SetSSRC(UInt32 SSRC) { reinterpret_cast<RTCPRRHeader *>(fBuf.Ptr)->SSRC = bswap_32(SSRC); }
3119 void SetCount(UInt16 count)
3120 @@ -105,10 +106,10 @@
3124 - UInt16 newVal = ntohs(*reinterpret_cast<UInt16 *>(fBuf.Ptr));
3125 + UInt16 newVal = bswap_16(*reinterpret_cast<UInt16 *>(fBuf.Ptr));
3128 - *reinterpret_cast<UInt16 *>(fBuf.Ptr) = htons(newVal);
3129 + *reinterpret_cast<UInt16 *>(fBuf.Ptr) = bswap_16(newVal);
3133 @@ -122,22 +123,22 @@
3134 RTCPReportBlock &reportBlock = *reinterpret_cast<RTCPReportBlock *>(fBuf.Ptr + GetPacketLen());
3135 ::memset(&reportBlock, 0, sizeof(RTCPReportBlock));
3137 - reportBlock.ssrc = htonl(SSRC);
3138 + reportBlock.ssrc = bswap_32(SSRC);
3139 reportBlock.fraction = fractionLost;
3140 - reportBlock.last_seq = htonl(highestSeqNum);
3141 - reportBlock.lsr = htonl(lsr);
3142 - reportBlock.dlsr = htonl(dlsr);
3143 + reportBlock.last_seq = bswap_32(highestSeqNum);
3144 + reportBlock.lsr = bswap_32(lsr);
3145 + reportBlock.dlsr = bswap_32(dlsr);
3147 //since the cumulative packets lost is a 24 bit signed integer, its clamped between 0x7fffff and 0x800000)
3148 if(cumLostPackets > 0x7fffff)
3149 - reportBlock.lost = htonl(0x7fffff);
3150 + reportBlock.lost = bswap_32(0x7fffff);
3151 else if (cumLostPackets < static_cast<SInt32>(0xff800000))
3152 - reportBlock.lost = htonl(0x800000);
3153 + reportBlock.lost = bswap_32(0x800000);
3155 - reportBlock.lost = htonl(cumLostPackets);
3156 + reportBlock.lost = bswap_32(cumLostPackets);
3158 SetCount(++fNumReportBlocks);
3159 - reinterpret_cast<RTCPRRHeader *>(fBuf.Ptr)->length = htons(GetPacketLen() / 4 - 1);
3160 + reinterpret_cast<RTCPRRHeader *>(fBuf.Ptr)->length = bswap_16(GetPacketLen() / 4 - 1);
3163 //The length of packet written out
3164 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPSRPacket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPSRPacket.cpp
3165 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPSRPacket.cpp 2008-05-06 01:28:59.000000000 +0200
3166 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPSRPacket.cpp 2008-05-30 23:46:29.000000000 +0200
3171 +#include <byteswap.h>
3174 #include "RTCPSRPacket.h"
3177 //write the SR & SDES headers
3178 UInt32* theSRWriter = (UInt32*)&fSenderReportBuffer;
3179 - *theSRWriter = htonl(0x80c80006);
3180 + *theSRWriter = bswap_32(0x80c80006);
3181 theSRWriter += 7; //number of UInt32s in an SR.
3183 //SDES length is the length of the CName, plus 2 32bit words, plus the 32bit word for the SSRC
3184 - *theSRWriter = htonl(0x81ca0000 + (cNameLen >> 2) + 1);
3185 + *theSRWriter = bswap_32(0x81ca0000 + (cNameLen >> 2) + 1);
3186 ::memcpy(&fSenderReportBuffer[kSenderReportSizeInBytes], theTempCName, cNameLen);
3187 fSenderReportSize = kSenderReportSizeInBytes + cNameLen;
3191 // Write the SERVER INFO APP packet
3192 UInt32* theAckInfoWriter = (UInt32*)&fSenderReportBuffer[fSenderReportSize];
3193 - *theAckInfoWriter = htonl(0x81cc0006);
3194 + *theAckInfoWriter = bswap_32(0x81cc0006);
3195 theAckInfoWriter += 2;
3196 - *(theAckInfoWriter++) = htonl(FOUR_CHARS_TO_INT('q', 't', 's', 'i')); // Ack Info APP name
3197 + *(theAckInfoWriter++) = bswap_32(FOUR_CHARS_TO_INT('q', 't', 's', 'i')); // Ack Info APP name
3198 theAckInfoWriter++; // leave space for the ssrc (again)
3199 - *(theAckInfoWriter++) = htonl(2); // 2 UInt32s for the 'at' field
3200 - *(theAckInfoWriter++) = htonl(FOUR_CHARS_TO_INT( 'a', 't', 0, 4 ));
3201 + *(theAckInfoWriter++) = bswap_32(2); // 2 UInt32s for the 'at' field
3202 + *(theAckInfoWriter++) = bswap_32(FOUR_CHARS_TO_INT( 'a', 't', 0, 4 ));
3203 fSenderReportWithServerInfoSize = (char*)(theAckInfoWriter+1) - fSenderReportBuffer;
3205 UInt32* theByeWriter = (UInt32*)&fSenderReportBuffer[fSenderReportWithServerInfoSize];
3206 - *theByeWriter = htonl(0x81cb0001);
3207 + *theByeWriter = bswap_32(0x81cb0001);
3210 UInt32 RTCPSRPacket::GetACName(char* ioCNameBuffer)
3211 diff -ur DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPSRPacket.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPSRPacket.h
3212 --- DarwinStreamingSrvr6.0.3-Source/RTCPUtilitiesLib/RTCPSRPacket.h 2008-05-06 01:28:59.000000000 +0200
3213 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTCPUtilitiesLib/RTCPSRPacket.h 2008-05-30 23:46:38.000000000 +0200
3215 #ifndef __RTCP_SR_PACKET__
3216 #define __RTCP_SR_PACKET__
3218 +#include <byteswap.h>
3219 #include "OSHeaders.h"
3221 #include "MyAssert.h"
3222 @@ -109,25 +110,25 @@
3223 inline void RTCPSRPacket::SetSSRC(UInt32 inSSRC)
3226 - ((UInt32*)&fSenderReportBuffer)[1] = htonl(inSSRC);
3227 + ((UInt32*)&fSenderReportBuffer)[1] = bswap_32(inSSRC);
3230 - ((UInt32*)&fSenderReportBuffer)[8] = htonl(inSSRC);
3231 + ((UInt32*)&fSenderReportBuffer)[8] = bswap_32(inSSRC);
3233 // Set SSRC in SERVER INFO
3234 Assert((fSenderReportSize & 3) == 0);
3235 - ((UInt32*)&fSenderReportBuffer)[(fSenderReportSize >> 2) + 1] = htonl(inSSRC);
3236 + ((UInt32*)&fSenderReportBuffer)[(fSenderReportSize >> 2) + 1] = bswap_32(inSSRC);
3239 Assert((fSenderReportWithServerInfoSize & 3) == 0);
3240 - ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) + 1] = htonl(inSSRC);
3241 + ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) + 1] = bswap_32(inSSRC);
3244 inline void RTCPSRPacket::SetClientSSRC(UInt32 inClientSSRC)
3247 // Set Client SSRC in SERVER INFO
3248 - ((UInt32*)&fSenderReportBuffer)[(fSenderReportSize >> 2) + 3] = htonl(inClientSSRC);
3249 + ((UInt32*)&fSenderReportBuffer)[(fSenderReportSize >> 2) + 3] = bswap_32(inClientSSRC);
3252 inline void RTCPSRPacket::SetNTPTimestamp(SInt64 inNTPTimestamp)
3253 @@ -142,22 +143,22 @@
3255 inline void RTCPSRPacket::SetRTPTimestamp(UInt32 inRTPTimestamp)
3257 - ((UInt32*)&fSenderReportBuffer)[4] = htonl(inRTPTimestamp);
3258 + ((UInt32*)&fSenderReportBuffer)[4] = bswap_32(inRTPTimestamp);
3261 inline void RTCPSRPacket::SetPacketCount(UInt32 inPacketCount)
3263 - ((UInt32*)&fSenderReportBuffer)[5] = htonl(inPacketCount);
3264 + ((UInt32*)&fSenderReportBuffer)[5] = bswap_32(inPacketCount);
3267 inline void RTCPSRPacket::SetByteCount(UInt32 inByteCount)
3269 - ((UInt32*)&fSenderReportBuffer)[6] = htonl(inByteCount);
3270 + ((UInt32*)&fSenderReportBuffer)[6] = bswap_32(inByteCount);
3273 inline void RTCPSRPacket::SetAckTimeout(UInt32 inAckTimeoutInMsec)
3275 - ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) - 1] = htonl(inAckTimeoutInMsec);
3276 + ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) - 1] = bswap_32(inAckTimeoutInMsec);
3279 #endif //__RTCP_SR_PACKET__
3280 diff -ur DarwinStreamingSrvr6.0.3-Source/RTPMetaInfoLib/RTPMetaInfoPacket.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTPMetaInfoLib/RTPMetaInfoPacket.cpp
3281 --- DarwinStreamingSrvr6.0.3-Source/RTPMetaInfoLib/RTPMetaInfoPacket.cpp 2008-05-06 01:28:59.000000000 +0200
3282 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTPMetaInfoLib/RTPMetaInfoPacket.cpp 2008-05-30 23:46:52.000000000 +0200
3284 // Some defs for RTP-Meta-Info payloads.
3287 +#include <byteswap.h>
3288 #include "RTPMetaInfoPacket.h"
3289 #include "MyAssert.h"
3290 #include "StringParser.h"
3293 // Extract the Field Name and convert it to a Field Index
3294 ::memcpy (&fieldNameValue, theFieldP.Ptr, sizeof(UInt16));
3295 - FieldIndex theIndex = RTPMetaInfoPacket::GetFieldIndexForName(ntohs(fieldNameValue));
3296 -// FieldIndex theIndex = RTPMetaInfoPacket::GetFieldIndexForName(ntohs(*(UInt16*)theFieldP.Ptr));
3297 + FieldIndex theIndex = RTPMetaInfoPacket::GetFieldIndexForName(bswap_16(fieldNameValue));
3298 +// FieldIndex theIndex = RTPMetaInfoPacket::GetFieldIndexForName(bswap_16(*(UInt16*)theFieldP.Ptr));
3301 // Get the Field ID if there is one.
3302 @@ -153,10 +154,10 @@
3305 ::memcpy(&uInt16Val, theFieldP, sizeof(uInt16Val));
3306 - theFieldIndex = this->GetFieldIndexForName(ntohs(uInt16Val));
3307 + theFieldIndex = this->GetFieldIndexForName(bswap_16(uInt16Val));
3309 ::memcpy(&uInt16Val, theFieldP + 2, sizeof(uInt16Val));
3310 - theFieldLen = ntohs(uInt16Val);
3311 + theFieldLen = bswap_16(uInt16Val);
3317 case kFrameTypeField:
3319 - fFrameType = ntohs(*((FrameTypeField*)theFieldP));
3320 + fFrameType = bswap_16(*((FrameTypeField*)theFieldP));
3323 case kPacketNumField:
3327 ::memcpy(&uInt16Val, theFieldP, sizeof(uInt16Val));
3328 - fSeqNum = ntohs(uInt16Val);
3329 + fSeqNum = bswap_16(uInt16Val);
3332 case kMediaDataField:
3333 diff -ur DarwinStreamingSrvr6.0.3-Source/RTSPClientLib/ClientSession.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTSPClientLib/ClientSession.cpp
3334 --- DarwinStreamingSrvr6.0.3-Source/RTSPClientLib/ClientSession.cpp 2008-05-06 01:29:00.000000000 +0200
3335 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTSPClientLib/ClientSession.cpp 2008-05-30 23:47:13.000000000 +0200
3340 +#include <byteswap.h>
3341 #include <arpa/inet.h>
3342 //#include <stdlib.h>
3343 #include "ClientSession.h"
3344 @@ -985,11 +986,11 @@
3348 - *(theWriter++) = htonl(0x81c90007); // 1 src RR packet
3349 - *(theWriter++) = htonl(0);
3350 - *(theWriter++) = htonl(0);
3351 - *(theWriter++) = htonl(0);
3352 - *(theWriter++) = htonl(trackStats.fHighestSeqNum == kUInt32_Max ? 0 : trackStats.fHighestSeqNum); //EHSN
3353 + *(theWriter++) = bswap_32(0x81c90007); // 1 src RR packet
3354 + *(theWriter++) = bswap_32(0);
3355 + *(theWriter++) = bswap_32(0);
3356 + *(theWriter++) = bswap_32(0);
3357 + *(theWriter++) = bswap_32(trackStats.fHighestSeqNum == kUInt32_Max ? 0 : trackStats.fHighestSeqNum); //EHSN
3358 *(theWriter++) = 0; // don't do jitter yet.
3359 *(theWriter++) = 0; // don't do last SR timestamp
3360 *(theWriter++) = 0; // don't do delay since last SR
3361 @@ -1000,19 +1001,19 @@
3362 if(fTransportType == kRTSPReliableUDPClientType)
3364 // APP PACKET - QoS info
3365 - *(theWriter++) = htonl(0x80CC000C);
3366 - //*(ia++) = htonl(trk[i].TrackSSRC);
3367 - *(theWriter++) = htonl(trackStats.fClientSSRC);
3368 + *(theWriter++) = bswap_32(0x80CC000C);
3369 + //*(ia++) = bswap_32(trk[i].TrackSSRC);
3370 + *(theWriter++) = bswap_32(trackStats.fClientSSRC);
3371 // this QTSS changes after beta to 'qtss'
3372 - *(theWriter++) = htonl(FOUR_CHARS_TO_INT('Q', 'T', 'S', 'S'));
3373 + *(theWriter++) = bswap_32(FOUR_CHARS_TO_INT('Q', 'T', 'S', 'S'));
3374 //*(ia++) = toBigEndian_ulong(trk[i].rcvrSSRC);
3375 - *(theWriter++) = htonl(trackStats.fServerSSRC);
3376 - *(theWriter++) = htonl(8); // number of 4-byte quants below
3377 + *(theWriter++) = bswap_32(trackStats.fServerSSRC);
3378 + *(theWriter++) = bswap_32(8); // number of 4-byte quants below
3379 #define RR 0x72720004
3380 #define PR 0x70720004
3381 #define PD 0x70640002
3382 #define OB 0x6F620004
3383 - *(theWriter++) = htonl(RR);
3384 + *(theWriter++) = bswap_32(RR);
3385 //unsigned int now, secs;
3386 //now = microseconds();
3387 //secs = now - trk[i].last_rtcp_packet_sent_us / USEC_PER_SEC;
3388 @@ -1020,18 +1021,18 @@
3389 // temp = trk[i].bytes_received_since_last_rtcp / secs;
3392 - //*(ia++) = htonl(temp);
3393 - *(theWriter++) = htonl(0);
3394 - *(theWriter++) = htonl(PR);
3395 - //*(ia++) = htonl(trk[i].rtp_num_received);
3396 - *(theWriter++) = htonl(0);
3397 - //*(theWriter++) = htonl(PL);
3398 - //*(ia++) = htonl(trk[i].rtp_num_lost);
3399 - //*(theWriter++) = htonl(0);
3400 - *(theWriter++) = htonl(OB);
3401 - *(theWriter++) = htonl(fOverbufferWindowSizeInK * 1024);
3402 - *(theWriter++) = htonl(PD);
3403 - *(theWriter++) = htonl(0); // should be a short, but we need to pad to a long for the entire RTCP app packet
3404 + //*(ia++) = bswap_32(temp);
3405 + *(theWriter++) = bswap_32(0);
3406 + *(theWriter++) = bswap_32(PR);
3407 + //*(ia++) = bswap_32(trk[i].rtp_num_received);
3408 + *(theWriter++) = bswap_32(0);
3409 + //*(theWriter++) = bswap_32(PL);
3410 + //*(ia++) = bswap_32(trk[i].rtp_num_lost);
3411 + //*(theWriter++) = bswap_32(0);
3412 + *(theWriter++) = bswap_32(OB);
3413 + *(theWriter++) = bswap_32(fOverbufferWindowSizeInK * 1024);
3414 + *(theWriter++) = bswap_32(PD);
3415 + *(theWriter++) = bswap_32(0); // should be a short, but we need to pad to a long for the entire RTCP app packet
3418 char *buf = reinterpret_cast<char *>(theWriter);
3419 diff -ur DarwinStreamingSrvr6.0.3-Source/RTSPClientLib/RTPPacket.h DarwinStreamingSrvr6.0.3-Source.x86_64/RTSPClientLib/RTPPacket.h
3420 --- DarwinStreamingSrvr6.0.3-Source/RTSPClientLib/RTPPacket.h 2008-05-06 01:29:00.000000000 +0200
3421 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTSPClientLib/RTPPacket.h 2008-05-30 23:49:47.000000000 +0200
3423 #ifndef _RTPPACKET_H_
3424 #define _RTPPACKET_H_
3426 +#include <byteswap.h>
3427 #include "arpa/inet.h"
3428 #include "OSHeaders.h"
3429 #include "StrPtrLen.h"
3431 : fPacket(reinterpret_cast<RTPHeader *>(inPacket)), fLen(inLen)
3434 - UInt8 GetPayloadType() const { return ntohs(fPacket->rtpheader) & 0x007F; }
3435 - UInt8 GetCSRCCount() const { return (ntohs(fPacket->rtpheader) & 0x0F00 ) >> 8; }
3436 + UInt8 GetPayloadType() const { return bswap_16(fPacket->rtpheader) & 0x007F; }
3437 + UInt8 GetCSRCCount() const { return (bswap_16(fPacket->rtpheader) & 0x0F00 ) >> 8; }
3439 //The following get functions will convert from network byte order to host byte order.
3440 //Conversely the set functions will convert from host byte order to network byte order.
3441 - UInt16 GetSeqNum() const { return ntohs(fPacket->seq); }
3442 - void SetSeqNum(UInt16 seqNum) { fPacket->seq = htons(seqNum); }
3443 + UInt16 GetSeqNum() const { return bswap_16(fPacket->seq); }
3444 + void SetSeqNum(UInt16 seqNum) { fPacket->seq = bswap_16(seqNum); }
3446 - UInt32 GetTimeStamp() const { return ntohl(fPacket->ts); }
3447 - void SetTimeStamp(UInt32 timeStamp) { fPacket->ts = htonl(timeStamp); }
3448 + UInt32 GetTimeStamp() const { return bswap_32(fPacket->ts); }
3449 + void SetTimeStamp(UInt32 timeStamp) { fPacket->ts = bswap_32(timeStamp); }
3451 - UInt32 GetSSRC() const { return ntohl(fPacket->ssrc); }
3452 - void SetSSRC(UInt32 SSRC) { fPacket->ssrc = htonl(SSRC); }
3453 + UInt32 GetSSRC() const { return bswap_32(fPacket->ssrc); }
3454 + void SetSSRC(UInt32 SSRC) { fPacket->ssrc = bswap_32(SSRC); }
3456 //Includes the variable CSRC portion
3457 UInt32 GetHeaderLen() const { return sizeof(RTPHeader) + GetCSRCCount() * 4; }
3459 Assert(sizeof(RTPHeader) == 12);
3460 if (fLen < sizeof(RTPHeader))
3462 - if ( ( ntohs(fPacket->rtpheader) >> 14) != RTP_VERSION )
3463 + if ( ( bswap_16(fPacket->rtpheader) >> 14) != RTP_VERSION )
3465 if (GetHeaderLen() > fLen)
3467 diff -ur DarwinStreamingSrvr6.0.3-Source/RTSPClientLib/RTSPClient.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/RTSPClientLib/RTSPClient.cpp
3468 --- DarwinStreamingSrvr6.0.3-Source/RTSPClientLib/RTSPClient.cpp 2008-05-06 01:29:00.000000000 +0200
3469 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/RTSPClientLib/RTSPClient.cpp 2008-05-30 23:47:22.000000000 +0200
3474 +#include <byteswap.h>
3475 #include <sys/types.h>
3476 #include <sys/socket.h>
3477 #include <netinet/in.h>
3478 @@ -1261,7 +1262,7 @@
3480 header[1] = (UInt8)x;
3481 UInt16* theLenP = (UInt16*)header;
3482 - theLenP[1] = htons(inLen);
3483 + theLenP[1] = bswap_16(inLen);
3487 @@ -1301,7 +1302,7 @@
3488 { *getNext = true; // handle a new packet
3489 fSendBuffer[0] = '$';
3490 fSendBuffer[1] = channel;
3491 - UInt16 netlen = htons(len);
3492 + UInt16 netlen = bswap_16(len);
3493 memcpy(&fSendBuffer[2],&netlen,2);
3494 memcpy(&fSendBuffer[4],data,len);
3496 @@ -1397,7 +1398,7 @@
3497 // The previous call to this function returned a packet successfully. We've been holding
3498 // onto that packet data until now... Now we can blow it away.
3499 UInt16* thePacketLenP = (UInt16*)fPacketBuffer;
3500 - UInt16 thePacketLen = ntohs(thePacketLenP[1]);
3501 + UInt16 thePacketLen = bswap_16(thePacketLenP[1]);
3503 Assert(fPacketBuffer[0] == '$');
3505 @@ -1442,7 +1443,7 @@
3507 Assert(fPacketBuffer[0] == '$');
3508 UInt16* thePacketLenP = (UInt16*)fPacketBuffer;
3509 - UInt16 thePacketLen = ntohs(thePacketLenP[1]);
3510 + UInt16 thePacketLen = bswap_16(thePacketLenP[1]);
3511 UInt8 channelIndex = fPacketBuffer[1];
3512 if (fPacketBufferOffset >= (thePacketLen + kPacketHeaderLen))
3514 @@ -1929,7 +1930,7 @@
3515 Socket::Initialize();
3516 SocketUtils::Initialize();
3518 - UInt32 ipAddr = (UInt32)ntohl(::inet_addr("17.221.41.111"));
3519 + UInt32 ipAddr = (UInt32)bswap_32(::inet_addr("17.221.41.111"));
3521 StrPtrLen theURL("rtsp://17.221.41.111/mystery.mov");
3523 diff -ur DarwinStreamingSrvr6.0.3-Source/Server.tproj/main.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/main.cpp
3524 --- DarwinStreamingSrvr6.0.3-Source/Server.tproj/main.cpp 2008-05-06 01:28:59.000000000 +0200
3525 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/main.cpp 2008-05-30 23:01:50.000000000 +0200
3527 //(void) ::signal(SIGPIPE, SIG_IGN);
3528 struct sigaction act;
3530 -#if defined(sun) || defined(i386) || defined (__MacOSX__) || defined(__powerpc__) || defined (__osf__) || defined (__sgi_cc__) || defined (__hpux__)
3531 +#if defined(sun) || defined(i386) || defined (__MacOSX__) || defined(__powerpc__) || defined (__osf__) || defined (__sgi_cc__) || defined (__hpux__) || defined(__linux__)
3532 sigemptyset(&act.sa_mask);
3534 act.sa_handler = (void(*)(int))&sigcatcher;
3535 diff -ur DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTPPacketResender.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTPPacketResender.cpp
3536 --- DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTPPacketResender.cpp 2008-05-06 01:28:59.000000000 +0200
3537 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTPPacketResender.cpp 2008-05-30 23:47:41.000000000 +0200
3542 +#include <byteswap.h>
3545 #include "RTPPacketResender.h"
3547 // we compute a re-transmit timeout based on the Karns RTT esmitate
3549 UInt16* theSeqNumP = (UInt16*)inRTPPacket;
3550 - UInt16 theSeqNum = ntohs(theSeqNumP[1]);
3551 + UInt16 theSeqNum = bswap_16(theSeqNumP[1]);
3558 #if RTP_PACKET_RESENDER_DEBUGGING
3559 - this->logprintf( "packet too old to add: seq# %li, age limit %li, cur late %li, track id %li\n", (SInt32)ntohs( *((UInt16*)(((char*)inRTPPacket)+2)) ), (SInt32)ageLimit, fCurrentPacketDelay, fTrackID );
3560 + this->logprintf( "packet too old to add: seq# %li, age limit %li, cur late %li, track id %li\n", (SInt32)bswap_16( *((UInt16*)(((char*)inRTPPacket)+2)) ), (SInt32)ageLimit, fCurrentPacketDelay, fTrackID );
3566 #if RTP_PACKET_RESENDER_DEBUGGING
3567 this->logprintf( "re-tx'd packet acked. ack num : %li, pack seq #: %li, num resends %li, track id %li, size %li, OS::MSecs %qd\n" \
3568 - , (SInt32)inSeqNum, (SInt32)ntohs( *((UInt16*)(((char*)theEntry->fPacketData)+2)) ), (SInt32)theEntry->fNumResends
3569 + , (SInt32)inSeqNum, (SInt32)bswap_16( *((UInt16*)(((char*)theEntry->fPacketData)+2)) ), (SInt32)theEntry->fNumResends
3570 , (SInt32)fTrackID, theEntry->fPacketSize, OS::Milliseconds() );
3574 version &= 0x84; // grab most sig 2 bits
3575 version = version >> 6; // shift by 6 bits
3576 this->logprintf( "expired: seq number %li, track id %li (port: %li), vers # %li, pack seq # %li, size: %li, OS::Msecs: %qd\n", \
3577 - (SInt32)ntohs( *((UInt16*)(((char*)theEntry->fPacketData)+2)) ), fTrackID, (SInt32) ntohs(fDestPort), \
3578 - (SInt32)version, (SInt32)ntohs( *((UInt16*)(((char*)theEntry->fPacketData)+2))), theEntry->fPacketSize, OS::Milliseconds() );
3579 + (SInt32)bswap_16( *((UInt16*)(((char*)theEntry->fPacketData)+2)) ), fTrackID, (SInt32) bswap_16(fDestPort), \
3580 + (SInt32)version, (SInt32)bswap_16( *((UInt16*)(((char*)theEntry->fPacketData)+2))), theEntry->fPacketSize, OS::Milliseconds() );
3583 // This packet is expired
3586 theEntry->fNumResends++;
3587 #if RTP_PACKET_RESENDER_DEBUGGING
3588 - this->logprintf( "re-sent: %li RTO %li, track id %li (port %li), size: %li, OS::Ms %qd\n", (SInt32)ntohs( *((UInt16*)(((char*)theEntry->fPacketData)+2)) ), curTime - theEntry->fAddedTime, \
3589 - fTrackID, (SInt32) ntohs(fDestPort) \
3590 + this->logprintf( "re-sent: %li RTO %li, track id %li (port %li), size: %li, OS::Ms %qd\n", (SInt32)bswap_16( *((UInt16*)(((char*)theEntry->fPacketData)+2)) ), curTime - theEntry->fAddedTime, \
3591 + fTrackID, (SInt32) bswap_16(fDestPort) \
3592 , theEntry->fPacketSize, OS::Milliseconds());
3595 diff -ur DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTPStream.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTPStream.cpp
3596 --- DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTPStream.cpp 2008-05-06 01:28:59.000000000 +0200
3597 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTPStream.cpp 2008-05-30 23:47:51.000000000 +0200
3602 +#include <byteswap.h>
3604 #include <arpa/inet.h>
3605 #include "SafeStdLib.h"
3606 @@ -768,12 +769,12 @@
3607 struct sockaddr_in sin;
3608 memset(&sin, 0, sizeof(struct sockaddr_in));
3609 sin.sin_family = AF_INET;
3610 - sin.sin_addr.s_addr = htonl(fMonitorAddr);
3611 + sin.sin_addr.s_addr = bswap_32(fMonitorAddr);
3613 if (fPayloadType == qtssVideoPayloadType)
3614 - sin.sin_port = (in_port_t) htons(fMonitorVideoDestPort+RTCPportOffset);
3615 + sin.sin_port = (in_port_t) bswap_16(fMonitorVideoDestPort+RTCPportOffset);
3616 else if (fPayloadType == qtssAudioPayloadType)
3617 - sin.sin_port = (in_port_t) htons(fMonitorAudioDestPort+RTCPportOffset);
3618 + sin.sin_port = (in_port_t) bswap_16(fMonitorAudioDestPort+RTCPportOffset);
3620 if (sin.sin_port != 0)
3624 qtss_printf("RTCP Monitor Socket sendto failed\n");
3626 - qtss_printf("RTCP Monitor Socket sendto port=%hu, packetLen=%"_U32BITARG_"\n", ntohs(sin.sin_port), inLen);
3627 + qtss_printf("RTCP Monitor Socket sendto port=%hu, packetLen=%"_U32BITARG_"\n", bswap_16(sin.sin_port), inLen);
3631 @@ -1211,7 +1212,7 @@
3632 this->PrintPacketPrefEnabled( (char*) thePacket->packetData, inLen, (SInt32) RTPStream::rtp);
3634 UInt16* theSeqNumP = (UInt16*)thePacket->packetData;
3635 - UInt16 theSeqNum = ntohs(theSeqNumP[1]);
3636 + UInt16 theSeqNum = bswap_16(theSeqNumP[1]);
3638 //Add the packet sequence number and the timestamp to the list of mappings if doing 3GPP-rate-adaptation.
3639 fStream3GPP->AddSeqNumTimeMapping(theSeqNum, thePacket->packetTransmitTime);
3640 @@ -1263,7 +1264,7 @@
3641 if (err != QTSS_NoErr)
3642 fResender.logprintf("Flow controlled: %qd Overbuffer window: %d. Cur time %qd\n", theCurrentPacketDelay, fSession->GetOverbufferWindow()->AvailableSpaceInWindow(), theTime);
3644 - fResender.logprintf("Sent packet: %d. Overbuffer window: %d Transmit time %qd. Cur time %qd\n", ntohs(theSeqNum[1]), fSession->GetOverbufferWindow()->AvailableSpaceInWindow(), thePacket->packetTransmitTime, theTime);
3645 + fResender.logprintf("Sent packet: %d. Overbuffer window: %d Transmit time %qd. Cur time %qd\n", bswap_16(theSeqNum[1]), fSession->GetOverbufferWindow()->AvailableSpaceInWindow(), thePacket->packetTransmitTime, theTime);
3647 //if (err != QTSS_NoErr)
3648 // qtss_printf("flow controlled\n");
3649 @@ -1283,7 +1284,7 @@
3651 // Record the RTP timestamp for RTCPs
3652 UInt32* timeStampP = (UInt32*)(thePacket->packetData);
3653 - fLastRTPTimestamp = ntohl(timeStampP[1]);
3654 + fLastRTPTimestamp = bswap_32(timeStampP[1]);
3658 @@ -1786,9 +1787,9 @@
3659 void RTPStream::PrintRTP(char* packetBuff, UInt32 inLen)
3662 - UInt16 sequence = ntohs( ((UInt16*)packetBuff)[1]);
3663 - UInt32 timestamp = ntohl( ((UInt32*)packetBuff)[1]);
3664 - UInt32 ssrc = ntohl( ((UInt32*)packetBuff)[2]);
3665 + UInt16 sequence = bswap_16( ((UInt16*)packetBuff)[1]);
3666 + UInt32 timestamp = bswap_32( ((UInt32*)packetBuff)[1]);
3667 + UInt32 ssrc = bswap_32( ((UInt32*)packetBuff)[2]);
3671 @@ -1819,7 +1820,7 @@
3672 UInt32* theReport = (UInt32*)packetBuff;
3675 - UInt32 ssrc = htonl(*theReport);
3676 + UInt32 ssrc = bswap_32(*theReport);
3680 @@ -1828,7 +1829,7 @@
3681 time_t theTime = OS::Time1900Fixed64Secs_To_UnixTimeSecs(ntp);
3684 - UInt32 timestamp = ntohl(*theReport);
3685 + UInt32 timestamp = bswap_32(*theReport);
3686 Float32 theTimeInSecs = 0.0;
3688 if (fFirstTimeStamp == 0)
3689 @@ -1838,10 +1839,10 @@
3690 theTimeInSecs = (Float32) (timestamp - fFirstTimeStamp) / (Float32) fTimescale;
3693 - UInt32 packetcount = ntohl(*theReport);
3694 + UInt32 packetcount = bswap_32(*theReport);
3697 - UInt32 bytecount = ntohl(*theReport);
3698 + UInt32 bytecount = bswap_32(*theReport);
3700 StrPtrLen *payloadStr = this->GetValue(qtssRTPStrPayloadName);
3701 if (payloadStr && payloadStr->Len > 0)
3702 diff -ur DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPRequestInterface.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPRequestInterface.cpp
3703 --- DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPRequestInterface.cpp 2008-05-06 01:28:59.000000000 +0200
3704 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPRequestInterface.cpp 2008-05-30 23:48:14.000000000 +0200
3709 +#include <byteswap.h>
3710 #include <sys/types.h>
3711 #include <sys/uio.h>
3716 ::sscanf(theCString, "%"_U32BITARG_"", &ssrcVal);
3717 - ssrcVal = htonl(ssrcVal);
3718 + ssrcVal = bswap_32(ssrcVal);
3720 StrPtrLen hexSSRC(QTSSDataConverter::ValueToString( &ssrcVal, sizeof(ssrcVal), qtssAttrDataTypeUnknown));
3721 OSCharArrayDeleter hexStrDeleter(hexSSRC.Ptr);
3722 diff -ur DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPRequestStream.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPRequestStream.cpp
3723 --- DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPRequestStream.cpp 2008-05-06 01:28:59.000000000 +0200
3724 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPRequestStream.cpp 2008-05-30 23:48:21.000000000 +0200
3729 +#include <byteswap.h>
3730 #include "RTSPRequestStream.h"
3731 #include "StringParser.h"
3732 #include "OSMemory.h"
3734 if (fRequest.Len < 4)
3736 UInt16* dataLenP = (UInt16*)fRequest.Ptr;
3737 - UInt32 interleavedPacketLen = ntohs(dataLenP[1]) + 4;
3738 + UInt32 interleavedPacketLen = bswap_16(dataLenP[1]) + 4;
3739 if (interleavedPacketLen > fRequest.Len)
3742 diff -ur DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPSession.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPSession.cpp
3743 --- DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPSession.cpp 2008-05-06 01:28:59.000000000 +0200
3744 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPSession.cpp 2008-05-31 00:03:01.000000000 +0200
3746 #define __RTSP_AUTH_DEBUG__ 0
3747 #define debug_printf if (__RTSP_AUTH_DEBUG__) qtss_printf
3749 +#include <byteswap.h>
3750 #include "RTSPSession.h"
3751 #include "RTSPRequest.h"
3752 #include "QTSServerInterface.h"
3753 @@ -1556,7 +1557,7 @@
3754 QTSSDataConverter::ConvertCHexStringToBytes(tempString.Ptr,
3757 - ncValue = ntohl(ncValue);
3758 + ncValue = bswap_32(ncValue);
3761 // nonce count must not be repeated by the client
3762 diff -ur DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPSessionInterface.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPSessionInterface.cpp
3763 --- DarwinStreamingSrvr6.0.3-Source/Server.tproj/RTSPSessionInterface.cpp 2008-05-06 01:28:59.000000000 +0200
3764 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/Server.tproj/RTSPSessionInterface.cpp 2008-05-30 23:48:28.000000000 +0200
3769 +#include <byteswap.h>
3772 #include "RTSPSessionInterface.h"
3774 // write direct to stream
3776 rih.channel = channel;
3777 - rih.len = htons( (UInt16)inLen);
3778 + rih.len = bswap_16( (UInt16)inLen);
3780 iov[1].iov_base = (char*)&rih;
3781 iov[1].iov_len = sizeof(rih);
3782 @@ -357,11 +358,11 @@
3783 fTCPCoalesceBuffer[fNumInCoalesceBuffer] = channel;
3784 fNumInCoalesceBuffer++;
3786 - //*((short*)&fTCPCoalesceBuffer[fNumInCoalesceBuffer]) = htons(inLen);
3787 + //*((short*)&fTCPCoalesceBuffer[fNumInCoalesceBuffer]) = bswap_16(inLen);
3788 // if we ever turn TCPCoalesce back on, this should be optimized
3789 // for processors w/o alignment restrictions as above.
3791 - SInt16 pcketLen = htons( (UInt16) inLen);
3792 + SInt16 pcketLen = bswap_16( (UInt16) inLen);
3793 ::memcpy( &fTCPCoalesceBuffer[fNumInCoalesceBuffer], &pcketLen, 2 );
3794 fNumInCoalesceBuffer += 2;
3796 diff -ur DarwinStreamingSrvr6.0.3-Source/StreamingLoadTool/Makefile.POSIX DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingLoadTool/Makefile.POSIX
3797 --- DarwinStreamingSrvr6.0.3-Source/StreamingLoadTool/Makefile.POSIX 2008-05-24 02:32:03.000000000 +0200
3798 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingLoadTool/Makefile.POSIX 2008-05-31 11:16:47.000000000 +0200
3802 rm -f $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
3803 + rm -f StreamingLoadTool
3805 .SUFFIXES: .cpp .c .o
3807 diff -ur DarwinStreamingSrvr6.0.3-Source/StreamingLoadTool/StreamingLoadTool.cpp DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingLoadTool/StreamingLoadTool.cpp
3808 --- DarwinStreamingSrvr6.0.3-Source/StreamingLoadTool/StreamingLoadTool.cpp 2008-05-24 02:22:13.000000000 +0200
3809 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingLoadTool/StreamingLoadTool.cpp 2008-05-30 23:59:56.000000000 +0200
3811 Contains: Tool that simulates streaming movie load
3814 +#include <byteswap.h>
3817 #include <sys/types.h>
3820 struct sigaction act;
3822 -#if defined(sun) || defined(i386) || defined (__MacOSX__) || defined(__powerpc__) || defined (__osf__) || defined (__sgi_cc__) || defined (__hpux__)
3823 +#if defined(sun) || defined(i386) || defined (__MacOSX__) || defined(__powerpc__) || defined (__osf__) || defined (__sgi_cc__) || defined (__hpux__) || defined (__linux__)
3824 sigemptyset(&act.sa_mask);
3826 act.sa_handler = (void(*)(int))&sigcatcher;
3828 char theAddrBuf[50];
3829 StrPtrLen theAddrBufPtr(theAddrBuf, 50);
3830 struct in_addr theAddr;
3831 - theAddr.s_addr = htonl(ioIPAddrArray[count]);
3832 + theAddr.s_addr = bswap_32(ioIPAddrArray[count]);
3834 SocketUtils::ConvertAddrToString(theAddr, &theAddrBufPtr);
3836 @@ -1015,7 +1016,7 @@
3837 struct hostent* theHostent = ::gethostbyname(theDNSName);
3839 if (theHostent != NULL)
3840 - ioIPAddrs[x] = ntohl(*(UInt32*)(theHostent->h_addr_list[0]));
3841 + ioIPAddrs[x] = bswap_32(*(UInt32*)(theHostent->h_addr_list[0]));
3843 ioIPAddrs[x] = SocketUtils::ConvertStringToAddr(theDNSName);
3845 @@ -1117,7 +1118,7 @@
3847 UInt32 theReason = inSession->GetReasonForDying();
3849 - theAddr.s_addr = htonl(inSession->GetSocket()->GetHostAddr());
3850 + theAddr.s_addr = bswap_32(inSession->GetSocket()->GetHostAddr());
3851 char* theAddrStr = ::inet_ntoa(theAddr);
3854 diff -ur DarwinStreamingSrvr6.0.3-Source/StreamingProxy.tproj/Makefile.POSIX DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingProxy.tproj/Makefile.POSIX
3855 --- DarwinStreamingSrvr6.0.3-Source/StreamingProxy.tproj/Makefile.POSIX 2007-11-16 06:16:39.000000000 +0100
3856 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingProxy.tproj/Makefile.POSIX 2008-05-31 11:02:10.000000000 +0200
3861 +CCFLAGS += -I../CommonUtilitiesLib
3863 C++FLAGS = $(CCFLAGS)
3865 diff -ur DarwinStreamingSrvr6.0.3-Source/StreamingProxy.tproj/proxy.c DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingProxy.tproj/proxy.c
3866 --- DarwinStreamingSrvr6.0.3-Source/StreamingProxy.tproj/proxy.c 2008-05-06 01:28:57.000000000 +0200
3867 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingProxy.tproj/proxy.c 2008-05-31 11:02:38.000000000 +0200
3872 +#include <byteswap.h>
3877 #include "./proxy_plat.h"
3880 +#include "OSHeaders.h"
3888 - printf("%x\ncommand str=%s\ncommand count with term=%d\n",*cmd, firstCmdChar, (cmd - firstCmdChar) + 1);
3889 + printf("%x\ncommand str=%s\ncommand count with term=%"_SPOINTERSIZEARG_"\n",*cmd, firstCmdChar, (cmd - firstCmdChar) + 1);
3891 if (strn_casecmp(p, " rtsp://", 8) != 0)
3897 - printf("%x\nserver str=%s\nserver count with term=%d\n",*server, firstServerChar, (server - firstServerChar) + 1);
3898 + printf("%x\nserver str=%s\nserver count with term=%"_SPOINTERSIZEARG_"\n",*server, firstServerChar, (server - firstServerChar) + 1);
3902 @@ -1821,7 +1823,7 @@
3904 range = atoi(line + pmatch[2].rm_so);
3905 //name_to_ip_num(temp, &ip, false);
3906 - ip = ntohl(inet_addr(temp));
3907 + ip = bswap_32(inet_addr(temp));
3909 printf("Allow connections from %s/%d\n", ip_to_string(ip), range);
3910 add_allow_subnet(ip, range);
3911 @@ -1836,7 +1838,7 @@
3912 int port = atoi(line + pmatch[2].rm_so);
3914 if(pmatch[1].rm_so==-1)
3915 - bindaddr.s_addr= (in_addr_t) htonl(ANY_ADDRESS);
3916 + bindaddr.s_addr= (in_addr_t) bswap_32(ANY_ADDRESS);
3919 *(line+pmatch[1].rm_eo)='\0';
3920 @@ -1849,7 +1851,7 @@
3921 printf("listen: failed to parse IP address %s\n",line+pmatch[1].rm_so);
3924 - add_rtsp_port_listener( (int) ntohl(bindaddr.s_addr),port);
3925 + add_rtsp_port_listener( (int) bswap_32(bindaddr.s_addr),port);
3927 else if (regexec(®expPortRange, line, 3, pmatch, 0) == 0) {
3928 int minPort, maxPort;
3929 diff -ur DarwinStreamingSrvr6.0.3-Source/StreamingProxy.tproj/proxy_unix.c DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingProxy.tproj/proxy_unix.c
3930 --- DarwinStreamingSrvr6.0.3-Source/StreamingProxy.tproj/proxy_unix.c 2008-05-06 01:28:57.000000000 +0200
3931 +++ DarwinStreamingSrvr6.0.3-Source.x86_64/StreamingProxy.tproj/proxy_unix.c 2008-05-30 23:49:17.000000000 +0200
3936 +#include <byteswap.h>
3944 - id = ntohl(((struct in_addr *)(hent->h_addr_list[0]))->s_addr);
3945 + id = bswap_32(((struct in_addr *)(hent->h_addr_list[0]))->s_addr);
3952 if ( inet_aton( name, &addr ) )
3953 - { *ip = ntohl( addr.s_addr );
3954 + { *ip = bswap_32( addr.s_addr );
3955 add_to_IP_cache(name, *ip );
3959 add_to_IP_cache(name, -1);
3962 - *ip = ntohl(((struct in_addr *) (hent->h_addr_list[0]))->s_addr);
3963 + *ip = bswap_32(((struct in_addr *) (hent->h_addr_list[0]))->s_addr);
3964 add_to_IP_cache(name, *ip);
3971 - *port = ntohs(remAddr.sin_port);
3972 - return ntohl(remAddr.sin_addr.s_addr);
3973 + *port = bswap_16(remAddr.sin_port);
3974 + return bswap_32(remAddr.sin_addr.s_addr);
3982 - *port = ntohs(remAddr.sin_port);
3983 - return ntohl(remAddr.sin_addr.s_addr);
3984 + *port = bswap_16(remAddr.sin_port);
3985 + return bswap_32(remAddr.sin_addr.s_addr);
3993 - __local_ip_address = ntohl(((struct in_addr *)hent->h_addr)->s_addr);
3994 + __local_ip_address = bswap_32(((struct in_addr *)hent->h_addr)->s_addr);
3995 return __local_ip_address;
4000 memset(&sin, 0, sizeof(sin));
4001 sin.sin_family = AF_INET;
4002 - sin.sin_port = htons(port);
4003 - sin.sin_addr.s_addr = htonl(address);
4004 + sin.sin_port = bswap_16(port);
4005 + sin.sin_addr.s_addr = bswap_32(address);
4006 return bind(skt, (struct sockaddr*)&sin, sizeof(sin));
4011 memset(&sin, 0, sizeof(sin));
4012 sin.sin_family = AF_INET;
4013 - sin.sin_port = htons(port);
4014 - sin.sin_addr.s_addr = htonl(address);;
4015 + sin.sin_port = bswap_16(port);
4016 + sin.sin_addr.s_addr = bswap_32(address);;
4017 return connect(skt, (struct sockaddr*)&sin, sizeof(sin));
4021 memset(&localAddr, 0, sizeof(localAddr));
4023 err = getsockname(skt, (struct sockaddr*)&localAddr, &len);
4024 - return ntohl(localAddr.sin_addr.s_addr);
4025 + return bswap_32(localAddr.sin_addr.s_addr);
4028 /**********************************************/
4030 ret = recvfrom(socket, buf, (size_t) amt, 0, (struct sockaddr*)&sin, &len);
4033 - *fromip = ntohl(sin.sin_addr.s_addr);
4034 + *fromip = bswap_32(sin.sin_addr.s_addr);
4036 - *fromport = ntohs(sin.sin_port);
4037 + *fromport = bswap_16(sin.sin_port);
4043 memset(&sin, 0, sizeof(sin));
4044 sin.sin_family = AF_INET;
4045 - sin.sin_port = htons(port);
4046 - sin.sin_addr.s_addr = htonl(address);
4047 + sin.sin_port = bswap_16(port);
4048 + sin.sin_addr.s_addr = bswap_32(address);
4049 return sendto(skt, buf, (size_t) amt, 0, (struct sockaddr*)&sin, sizeof(sin));