]>
Commit | Line | Data |
---|---|---|
720b962c ER |
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 | |
3 | ||
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 | |
7 | @@ -29,6 +29,7 @@ | |
8 | ||
9 | */ | |
10 | ||
11 | +#include <byteswap.h> | |
12 | #include "QTSSModuleUtils.h" | |
13 | #include "QTSS_Private.h" | |
14 | ||
15 | @@ -282,7 +283,7 @@ | |
16 | RTPMetaInfoPacket::FieldName* theFieldName = (RTPMetaInfoPacket::FieldName*)theHeader.Ptr; | |
17 | ::memcpy (&fieldNameValue, theFieldName, sizeof(UInt16)); | |
18 | ||
19 | - RTPMetaInfoPacket::FieldIndex theFieldIndex = RTPMetaInfoPacket::GetFieldIndexForName(ntohs(fieldNameValue)); | |
20 | + RTPMetaInfoPacket::FieldIndex theFieldIndex = RTPMetaInfoPacket::GetFieldIndexForName(bswap_16(fieldNameValue)); | |
21 | ||
22 | // | |
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 | |
27 | @@ -934,7 +934,7 @@ | |
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]; | |
35 | } | |
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 | |
39 | @@ -31,6 +31,7 @@ | |
40 | ||
41 | */ | |
42 | ||
43 | +#include <byteswap.h> | |
44 | #include <string.h> | |
45 | ||
46 | #include "QTSSFileModule.h" | |
47 | @@ -190,7 +191,7 @@ | |
48 | ||
49 | inline UInt16 GetPacketSequenceNumber(void * packetDataPtr) | |
50 | { | |
51 | - return ntohs( ((UInt16*)packetDataPtr)[1]); | |
52 | + return bswap_16( ((UInt16*)packetDataPtr)[1]); | |
53 | } | |
54 | ||
55 | inline UInt16 GetLastPacketSeqNum(QTSS_Object stream) | |
56 | @@ -218,18 +219,18 @@ | |
57 | ||
58 | inline void SetPacketSequenceNumber(UInt16 newSequenceNumber, void * packetDataPtr) | |
59 | { | |
60 | - ((UInt16*)packetDataPtr)[1] = htons(newSequenceNumber); | |
61 | + ((UInt16*)packetDataPtr)[1] = bswap_16(newSequenceNumber); | |
62 | } | |
63 | ||
64 | ||
65 | inline UInt32 GetPacketTimeStamp(void * packetDataPtr) | |
66 | { | |
67 | - return ntohl( ((UInt32*)packetDataPtr)[1]); | |
68 | + return bswap_32( ((UInt32*)packetDataPtr)[1]); | |
69 | } | |
70 | ||
71 | inline void SetPacketTimeStamp(UInt32 newTimeStamp, void * packetDataPtr) | |
72 | { | |
73 | - ((UInt32*)packetDataPtr)[1] = htonl(newTimeStamp); | |
74 | + ((UInt32*)packetDataPtr)[1] = bswap_32(newTimeStamp); | |
75 | } | |
76 | ||
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 | |
81 | @@ -30,6 +30,7 @@ | |
82 | ||
83 | ||
84 | #ifndef __Win32__ | |
85 | +#include <byteswap.h> | |
86 | #include <unistd.h> | |
87 | #include <dirent.h> | |
88 | #endif | |
89 | @@ -1068,7 +1069,7 @@ | |
90 | if( rmra == NULL ) | |
91 | return NULL; | |
92 | ||
93 | - rmraLen = htonl(rmraLen); | |
94 | + rmraLen = bswap_32(rmraLen); | |
95 | ||
96 | ::memcpy(&rmra[0], &rmraLen, 4); | |
97 | ::memcpy(&rmra[1], "rmra", 4); | |
98 | @@ -1076,20 +1077,20 @@ | |
99 | ||
100 | // Make the MOOV | |
101 | ||
102 | - *moovLen = ntohl(rmraLen) + 8; | |
103 | + *moovLen = bswap_32(rmraLen) + 8; | |
104 | moov = NEW UInt32[*moovLen]; | |
105 | if( moov == NULL ) | |
106 | return NULL; | |
107 | ||
108 | - *moovLen = htonl(*moovLen); | |
109 | + *moovLen = bswap_32(*moovLen); | |
110 | ||
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)); | |
115 | ||
116 | delete rmra; | |
117 | ||
118 | - *moovLen = ntohl(*moovLen); | |
119 | + *moovLen = bswap_32(*moovLen); | |
120 | ||
121 | // moov needs to be deleted by the calling function | |
122 | return moov; | |
123 | @@ -1099,8 +1100,8 @@ | |
124 | { | |
125 | UInt32 *rdrf, rdrfLen, *rmdr, rmdrLen, *rmda, zero, size; | |
126 | ||
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); | |
131 | ||
132 | // Make the RDRF | |
133 | size = ::strlen(url) + 1; | |
134 | @@ -1109,8 +1110,8 @@ | |
135 | if( rdrf == NULL ) | |
136 | return NULL; | |
137 | ||
138 | - rdrfLen = htonl(rdrfLen); | |
139 | - size = htonl(size); | |
140 | + rdrfLen = bswap_32(rdrfLen); | |
141 | + size = bswap_32(size); | |
142 | ||
143 | ::memcpy(&rdrf[0], &rdrfLen, 4); | |
144 | ::memcpy(&rdrf[1], "rdrf", 4); | |
145 | @@ -1125,7 +1126,7 @@ | |
146 | if( rmdr == NULL ) | |
147 | return NULL; | |
148 | ||
149 | - rmdrLen = htonl(rmdrLen); | |
150 | + rmdrLen = bswap_32(rmdrLen); | |
151 | ||
152 | ::memcpy(&rmdr[0], &rmdrLen, 4); | |
153 | ::memcpy(&rmdr[1], "rmdr", 4); | |
154 | @@ -1134,22 +1135,22 @@ | |
155 | ||
156 | // Make the RMDA | |
157 | ||
158 | - *rmdaLen = ntohl(rdrfLen) + ntohl(rmdrLen) + 8; | |
159 | + *rmdaLen = bswap_32(rdrfLen) + bswap_32(rmdrLen) + 8; | |
160 | rmda = NEW UInt32[*rmdaLen]; | |
161 | if( rmda == NULL ) | |
162 | return NULL; | |
163 | ||
164 | - *rmdaLen = htonl(*rmdaLen); | |
165 | + *rmdaLen = bswap_32(*rmdaLen); | |
166 | ||
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)); | |
173 | ||
174 | delete rdrf; | |
175 | delete rmdr; | |
176 | ||
177 | - *rmdaLen = ntohl(*rmdaLen); | |
178 | + *rmdaLen = bswap_32(*rmdaLen); | |
179 | ||
180 | // rmda needs to be deleted by the calling function | |
181 | return rmda; | |
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 | |
185 | @@ -36,6 +36,7 @@ | |
186 | #ifndef __Win32__ | |
187 | // | |
188 | // For gethostbyname | |
189 | +#include <byteswap.h> | |
190 | #include <netdb.h> | |
191 | #endif | |
192 | ||
193 | @@ -357,7 +358,7 @@ | |
194 | ||
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])); | |
199 | else | |
200 | theIPAddr = SocketUtils::ConvertStringToAddr(theDNSName); | |
201 | ||
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 | |
205 | @@ -31,6 +31,7 @@ | |
206 | ||
207 | */ | |
208 | ||
209 | +#include <byteswap.h> | |
210 | #include "QTSSReflectorModule.h" | |
211 | #include "QTSSModuleUtils.h" | |
212 | #include "ReflectorSession.h" | |
213 | @@ -654,7 +655,7 @@ | |
214 | ||
215 | UInt16 packetDataLen; | |
216 | memcpy(&packetDataLen,&packetData[2],2); | |
217 | - packetDataLen = ntohs(packetDataLen); | |
218 | + packetDataLen = bswap_16(packetDataLen); | |
219 | ||
220 | char* rtpPacket = &packetData[4]; | |
221 | ||
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 | |
225 | @@ -32,6 +32,7 @@ | |
226 | */ | |
227 | ||
228 | ||
229 | +#include <byteswap.h> | |
230 | #include "ReflectorSession.h" | |
231 | #include "RTCPPacket.h" | |
232 | #include "SocketUtils.h" | |
233 | @@ -283,7 +284,7 @@ | |
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); | |
241 | } | |
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 | |
245 | @@ -31,6 +31,7 @@ | |
246 | ||
247 | */ | |
248 | ||
249 | +#include <byteswap.h> | |
250 | #include "ReflectorStream.h" | |
251 | #include "QTSSModuleUtils.h" | |
252 | #include "OSMemory.h" | |
253 | @@ -162,31 +163,31 @@ | |
254 | ||
255 | //write the RR (just header + ssrc) | |
256 | UInt32* theRRWriter = (UInt32*)&fReceiverReportBuffer[0]; | |
257 | - *theRRWriter = htonl(0x80c90001); | |
258 | + *theRRWriter = bswap_32(0x80c90001); | |
259 | theRRWriter++; | |
260 | - *theRRWriter = htonl(theSsrc); | |
261 | + *theRRWriter = bswap_32(theSsrc); | |
262 | theRRWriter++; | |
263 | ||
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); | |
267 | theRRWriter++; | |
268 | - *theRRWriter = htonl(theSsrc); | |
269 | + *theRRWriter = bswap_32(theSsrc); | |
270 | theRRWriter++; | |
271 | ::memcpy(theRRWriter, theTempCName, cNameLen); | |
272 | theRRWriter += cNameLen >> 2; | |
273 | ||
274 | //APP packet format, QTSS specific stuff | |
275 | - *theRRWriter = htonl(0x80cc0008); | |
276 | + *theRRWriter = bswap_32(0x80cc0008); | |
277 | theRRWriter++; | |
278 | - *theRRWriter = htonl(theSsrc); | |
279 | + *theRRWriter = bswap_32(theSsrc); | |
280 | theRRWriter++; | |
281 | - *theRRWriter = htonl(FOUR_CHARS_TO_INT('Q','T','S','S')); | |
282 | + *theRRWriter = bswap_32(FOUR_CHARS_TO_INT('Q','T','S','S')); | |
283 | theRRWriter++; | |
284 | - *theRRWriter = htonl(0); | |
285 | + *theRRWriter = bswap_32(0); | |
286 | theRRWriter++; | |
287 | - *theRRWriter = htonl(0x00000004); | |
288 | + *theRRWriter = bswap_32(0x00000004); | |
289 | theRRWriter++; | |
290 | - *theRRWriter = htonl(0x6579000c); | |
291 | + *theRRWriter = bswap_32(0x6579000c); | |
292 | theRRWriter++; | |
293 | ||
294 | fEyeLocation = theRRWriter; | |
295 | @@ -474,11 +475,11 @@ | |
296 | ||
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! | |
301 | theEyeWriter++; | |
302 | - *theEyeWriter = htonl(theEyeCount) & 0x7fffffff; | |
303 | + *theEyeWriter = bswap_32(theEyeCount) & 0x7fffffff; | |
304 | theEyeWriter++; | |
305 | - *theEyeWriter = htonl(0) & 0x7fffffff; | |
306 | + *theEyeWriter = bswap_32(0) & 0x7fffffff; | |
307 | ||
308 | //send the packet to the multicast RTCP addr & port for this stream | |
309 | (void)fSockets->GetSocketB()->SendTo(fDestRTCPAddr, fDestRTCPPort, fReceiverReportBuffer, fReceiverReportSize); | |
310 | @@ -707,7 +708,7 @@ | |
311 | ||
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]); | |
316 | } | |
317 | ||
318 | ||
319 | @@ -1460,7 +1461,7 @@ | |
320 | if (theSender == NULL) | |
321 | { | |
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 | |
326 | done = true; | |
327 | break; | |
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 | |
331 | @@ -37,6 +37,7 @@ | |
332 | #ifndef _REFLECTOR_STREAM_H_ | |
333 | #define _REFLECTOR_STREAM_H_ | |
334 | ||
335 | +#include <byteswap.h> | |
336 | #include "QTSS.h" | |
337 | ||
338 | #include "IdleTask.h" | |
339 | @@ -121,12 +122,12 @@ | |
340 | ||
341 | UInt32* theSsrcPtr = (UInt32*)fPacketPtr.Ptr; | |
342 | if (isRTCP)// RTCP | |
343 | - return ntohl(theSsrcPtr[1]); | |
344 | + return bswap_32(theSsrcPtr[1]); | |
345 | ||
346 | if (fPacketPtr.Len < 12) | |
347 | return 0; | |
348 | ||
349 | - return ntohl(theSsrcPtr[2]); // RTP SSRC | |
350 | + return bswap_32(theSsrcPtr[2]); // RTP SSRC | |
351 | } | |
352 | ||
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) | |
357 | return 0; | |
358 | - timestamp = ntohl( ((UInt32*)fPacketPtr.Ptr)[1]); | |
359 | + timestamp = bswap_32( ((UInt32*)fPacketPtr.Ptr)[1]); | |
360 | } | |
361 | else | |
362 | { | |
363 | if (fPacketPtr.Ptr == NULL || fPacketPtr.Len < 20) | |
364 | return 0; | |
365 | - timestamp = ntohl( ((UInt32*)fPacketPtr.Ptr)[4]); | |
366 | + timestamp = bswap_32( ((UInt32*)fPacketPtr.Ptr)[4]); | |
367 | } | |
368 | return timestamp; | |
369 | } | |
370 | @@ -156,7 +157,7 @@ | |
371 | if (fPacketPtr.Ptr == NULL || fPacketPtr.Len < 4 || fIsRTCP) | |
372 | return 0; | |
373 | ||
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 | |
376 | return sequence; | |
377 | } | |
378 | ||
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 | |
382 | @@ -31,6 +31,7 @@ | |
383 | ||
384 | */ | |
385 | ||
386 | +#include <byteswap.h> | |
387 | #include "RelayOutput.h" | |
388 | ||
389 | #include "OSMemory.h" | |
390 | @@ -234,7 +235,7 @@ | |
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); | |
397 | ||
398 | // Begin writing the HTML | |
399 | @@ -538,14 +539,14 @@ | |
400 | StrPtrLen theIPAddr(theIPAddrBuf, 20); | |
401 | ||
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); | |
406 | ||
407 | theErr = QTSS_SetValue (fRelayOutputObject, sOutputDestAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len); | |
408 | Assert(theErr == QTSS_NoErr); | |
409 | ||
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); | |
414 | ||
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 | |
419 | @@ -32,6 +32,7 @@ | |
420 | */ | |
421 | ||
422 | ||
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); | |
429 | ||
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); | |
434 | ||
435 | theErr = QTSS_SetValue (fRelaySessionObject, sSourceIPAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len); | |
436 | Assert(theErr == QTSS_NoErr); | |
437 | ||
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); | |
442 | ||
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 | |
447 | @@ -31,6 +31,8 @@ | |
448 | */ | |
449 | ||
450 | ||
451 | +#include <byteswap.h> | |
452 | +#include <byteswap.h> | |
453 | #include "RTPSessionOutput.h" | |
454 | #include "ReflectorStream.h" | |
455 | ||
456 | @@ -442,18 +444,18 @@ | |
457 | //printf("rtptime offset time =%f in scale =%"_U32BITARG_"\n", rtpTimeFromStart, rtpTimeFromStartInScale ); | |
458 | ||
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); | |
462 | ||
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); | |
469 | ||
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); | |
475 | ||
476 | return QTSS_NoErr; | |
477 | } | |
478 | @@ -667,7 +669,7 @@ | |
479 | ||
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]); | |
484 | } | |
485 | ||
486 | void RTPSessionOutput::SetPacketSeqNumber(StrPtrLen* inPacket, UInt16 inSeqNumber) | |
487 | @@ -677,7 +679,7 @@ | |
488 | ||
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); | |
493 | } | |
494 | ||
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 | |
499 | @@ -31,6 +31,7 @@ | |
500 | ||
501 | */ | |
502 | ||
503 | +#include <byteswap.h> | |
504 | #include "RTSPSourceInfo.h" | |
505 | #include "StringParser.h" | |
506 | #include "SDPSourceInfo.h" | |
507 | @@ -384,7 +385,7 @@ | |
508 | StrPtrLen temp(buff); | |
509 | ||
510 | struct in_addr theIPAddr; | |
511 | - theIPAddr.s_addr = htonl(ipAddr); | |
512 | + theIPAddr.s_addr = bswap_32(ipAddr); | |
513 | SocketUtils::ConvertAddrToString(theIPAddr, &temp); | |
514 | ||
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 | |
519 | @@ -65,14 +65,14 @@ | |
520 | case $PLAT in | |
521 | ||
522 | Linux.ppc) | |
523 | - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
524 | + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
525 | CPLUS=gcc | |
526 | CCOMP=gcc | |
527 | LINKER='gcc' | |
528 | MAKE=make | |
529 | ||
530 | COMPILER_FLAGS="-D_REENTRANT -D__USE_POSIX -D__linuxppc__ -pipe" | |
531 | - INCLUDE_FLAG="-include" | |
532 | + INCLUDE_FLAG="-include" | |
533 | ||
534 | CORE_LINK_LIBS="-lpthread -ldl -lstdc++ -lm -lcrypt" | |
535 | ||
536 | @@ -85,16 +85,39 @@ | |
537 | fi | |
538 | ;; | |
539 | ||
540 | + Linux.i386 | \ | |
541 | + Linux.i486 | \ | |
542 | Linux.i586 | \ | |
543 | Linux.i686) | |
544 | - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
545 | + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
546 | CPLUS=gcc | |
547 | CCOMP=gcc | |
548 | LINKER='gcc' | |
549 | MAKE=make | |
550 | ||
551 | COMPILER_FLAGS="-D_REENTRANT -D__USE_POSIX -D__linux__ -pipe" | |
552 | - INCLUDE_FLAG="-include" | |
553 | + INCLUDE_FLAG="-include" | |
554 | + | |
555 | + CORE_LINK_LIBS="-lpthread -ldl -lstdc++ -lm -lcrypt" | |
556 | + | |
557 | + SHARED=-shared | |
558 | + MODULE_LIBS= | |
559 | + | |
560 | + if [ -f /usr/include/socketbits.h ]; then | |
561 | + NEED_SOCKETBITS=1 | |
562 | + export NEED_SOCKETBITS | |
563 | + fi | |
564 | + ;; | |
565 | + | |
566 | + Linux.x86_64) | |
567 | + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
568 | + CPLUS=gcc | |
569 | + CCOMP=gcc | |
570 | + LINKER='gcc' | |
571 | + MAKE=make | |
572 | + | |
573 | + COMPILER_FLAGS="-D_REENTRANT -D__USE_POSIX -D__linux__ -pipe -fPIC" | |
574 | + INCLUDE_FLAG="-include" | |
575 | ||
576 | CORE_LINK_LIBS="-lpthread -ldl -lstdc++ -lm -lcrypt" | |
577 | ||
578 | @@ -108,14 +131,14 @@ | |
579 | ;; | |
580 | ||
581 | Linux.mips) | |
582 | - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
583 | + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
584 | CPLUS=gcc | |
585 | CCOMP=gcc | |
586 | LINKER='egcs' | |
587 | MAKE=make | |
588 | ||
589 | COMPILER_FLAGS="-D_REENTRANT -D__linux__ -Wno-multichar -pipe" | |
590 | - INCLUDE_FLAG="-include" | |
591 | + INCLUDE_FLAG="-include" | |
592 | ||
593 | CORE_LINK_LIBS="-lpthread -ldl -lm -lcrypt" | |
594 | ||
595 | @@ -129,14 +152,14 @@ | |
596 | ;; | |
597 | ||
598 | FreeBSD.i386) | |
599 | - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
600 | + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
601 | CPLUS=gcc | |
602 | CCOMP=gcc | |
603 | LINKER="gcc" | |
604 | MAKE=make | |
605 | ||
606 | COMPILER_FLAGS= | |
607 | - INCLUDE_FLAG="-include" | |
608 | + INCLUDE_FLAG="-include" | |
609 | ||
610 | CORE_LINK_LIBS="-pthread -lm -lcrypt" | |
611 | ||
612 | @@ -147,14 +170,14 @@ | |
613 | # SunOS.sun4m | \ | |
614 | # SunOS.sun4u) | |
615 | SunOS.*) | |
616 | - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
617 | + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
618 | CPLUS=g++ | |
619 | CCOMP=gcc | |
620 | LINKER="g++" | |
621 | MAKE=make | |
622 | ||
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" | |
626 | ||
627 | CORE_LINK_LIBS="-lpthread -ldl -lsocket -lnsl -lresolv -lm -lcrypt -lstdc++" | |
628 | ||
629 | @@ -163,9 +186,9 @@ | |
630 | ;; | |
631 | ||
632 | IRIX*.*) | |
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" | |
639 | CPLUS=CC | |
640 | CCOMP=cc | |
641 | LINKER="CC" | |
642 | @@ -179,31 +202,31 @@ | |
643 | MODULE_LIBS= | |
644 | ;; | |
645 | ||
646 | - HP-UX.*) | |
647 | - echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
648 | - CPLUS=gcc | |
649 | - CCOMP=gcc | |
650 | - LINKER=gcc | |
651 | - MAKE=make | |
652 | + HP-UX.*) | |
653 | + echo "Configuring for the "$OSNAME" "$HARDWARENAME" platform" | |
654 | + CPLUS=gcc | |
655 | + CCOMP=gcc | |
656 | + LINKER=gcc | |
657 | + MAKE=make | |
658 | ||
659 | - COMPILER_FLAGS="-D__hpux__ -g -fPIC" | |
660 | - INCLUDE_FLAG="-include" | |
661 | + COMPILER_FLAGS="-D__hpux__ -g -fPIC" | |
662 | + INCLUDE_FLAG="-include" | |
663 | ||
664 | - CORE_LINK_LIBS="-lpthread -lnsl -lm -lcrypt -lstdc++" | |
665 | + CORE_LINK_LIBS="-lpthread -lnsl -lm -lcrypt -lstdc++" | |
666 | ||
667 | - SHARED=-shared | |
668 | - MODULE_LIBS="-lgcc -lstdc++" | |
669 | - ;; | |
670 | + SHARED=-shared | |
671 | + MODULE_LIBS="-lgcc -lstdc++" | |
672 | + ;; | |
673 | ||
674 | OSF1.alpha) | |
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 | |
679 | LINKER="cxx" | |
680 | MAKE=/usr/local/bin/make | |
681 | ||
682 | COMPILER_FLAGS="-D__osf__ -DTRUCLUSTER -pthread" | |
683 | - INCLUDE_FLAG="-FI" | |
684 | + INCLUDE_FLAG="-FI" | |
685 | ||
686 | CORE_LINK_LIBS="-lpthread -lclu -lm" | |
687 | ||
688 | @@ -213,7 +236,7 @@ | |
689 | ||
690 | "Darwin.i386" | \ | |
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." | |
694 | ||
695 | ;; | |
696 | ||
697 | @@ -227,7 +250,7 @@ | |
698 | MAKE=make | |
699 | ||
700 | COMPILER_FLAGS=-D__linux__ | |
701 | - INCLUDE_FLAG="-include" | |
702 | + INCLUDE_FLAG="-include" | |
703 | ||
704 | CORE_LINK_LIBS="-lpthread -ldl -lm -lcrypt" | |
705 | ||
706 | @@ -338,7 +361,11 @@ | |
707 | echo Building StreamingServer for $PLAT with $CPLUS | |
708 | cd .. | |
709 | ||
710 | - $MAKE -f Makefile.POSIX $* | |
711 | + if [ "$*" = "clean" ] ; then | |
712 | + $MAKE -B -f Makefile.POSIX $* | |
713 | + else | |
714 | + $MAKE -f Makefile.POSIX $* | |
715 | + fi | |
716 | ||
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__ | |
724 | /* Defines */ | |
725 | #define _64BITARG_ "q" | |
726 | - #define _S64BITARG_ "lld" | |
727 | - #define _U64BITARG_ "llu" | |
728 | + #define _S32BITARG_ "d" | |
729 | + #define _U32BITARG_ "u" | |
730 | #if __LP64__ | |
731 | - #define _S32BITARG_ "d" | |
732 | - #define _U32BITARG_ "u" | |
733 | + #define _S64BITARG_ "ld" | |
734 | + #define _U64BITARG_ "lu" | |
735 | #define _SPOINTERSIZEARG_ _S64BITARG_ | |
736 | #define _UPOINTERSIZEARG_ _U64BITARG_ | |
737 | #else | |
738 | - #define _S32BITARG_ "d" | |
739 | - #define _U32BITARG_ "u" | |
740 | + #define _S64BITARG_ "lld" | |
741 | + #define _U64BITARG_ "llu" | |
742 | #define _SPOINTERSIZEARG_ _S32BITARG_ | |
743 | #define _UPOINTERSIZEARG_ _U32BITARG_ | |
744 | #endif | |
745 | @@ -181,14 +181,14 @@ | |
746 | ||
747 | #define TW0_CHARS_TO_INT( c1, c2 ) ( c1 << 8 | c2 ) | |
748 | ||
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 | |
753 | ||
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 | |
758 | ||
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 | |
763 | ||
764 | #elif __Win32__ | |
765 | ||
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 | |
769 | @@ -31,6 +31,7 @@ | |
770 | ||
771 | */ | |
772 | ||
773 | +#include <byteswap.h> | |
774 | #include <string.h> | |
775 | ||
776 | #ifndef __Win32__ | |
777 | @@ -186,8 +187,8 @@ | |
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); | |
785 | ||
786 | int err; | |
787 | ||
788 | @@ -229,7 +230,7 @@ | |
789 | { | |
790 | for (UInt32 x = 0; x < SocketUtils::GetNumIPAddrs(); x++) | |
791 | { | |
792 | - if (SocketUtils::GetIPAddr(x) == ntohl(fLocalAddr.sin_addr.s_addr)) | |
793 | + if (SocketUtils::GetIPAddr(x) == bswap_32(fLocalAddr.sin_addr.s_addr)) | |
794 | { | |
795 | fLocalAddrStrPtr = SocketUtils::GetIPAddrStr(x); | |
796 | break; | |
797 | @@ -244,7 +245,7 @@ | |
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); | |
804 | ||
805 | printf("Socket::GetLocalAddrStr Search IPs failed, numIPs=%d\n",SocketUtils::GetNumIPAddrs()); | |
806 | @@ -270,7 +271,7 @@ | |
807 | { | |
808 | for (UInt32 x = 0; x < SocketUtils::GetNumIPAddrs(); x++) | |
809 | { | |
810 | - if (SocketUtils::GetIPAddr(x) == ntohl(fLocalAddr.sin_addr.s_addr)) | |
811 | + if (SocketUtils::GetIPAddr(x) == bswap_32(fLocalAddr.sin_addr.s_addr)) | |
812 | { | |
813 | fLocalDNSStrPtr = SocketUtils::GetDNSNameStr(x); | |
814 | break; | |
815 | @@ -290,7 +291,7 @@ | |
816 | { | |
817 | if (fPortStr.Len == kPortBufSizeInBytes) | |
818 | { | |
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); | |
823 | } | |
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 | |
827 | @@ -37,6 +37,7 @@ | |
828 | #define __SOCKET_H__ | |
829 | ||
830 | #ifndef __Win32__ | |
831 | +#include <byteswap.h> | |
832 | #include <netinet/in.h> | |
833 | #endif | |
834 | ||
835 | @@ -94,8 +95,8 @@ | |
836 | Bool16 IsBound() { return (Bool16) (fState & kBound); } | |
837 | ||
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); } | |
843 | ||
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 | |
849 | @@ -32,6 +32,7 @@ | |
850 | ||
851 | */ | |
852 | ||
853 | +#include <byteswap.h> | |
854 | #include <string.h> | |
855 | ||
856 | #ifndef __Win32__ | |
857 | @@ -123,7 +124,7 @@ | |
858 | char* theAddrStr = ::inet_ntoa(sockaddr->sin_addr); | |
859 | ||
860 | //store the IP addr | |
861 | - sIPAddrInfoArray[addrArrayIndex].fIPAddr = ntohl(sockaddr->sin_addr.s_addr); | |
862 | + sIPAddrInfoArray[addrArrayIndex].fIPAddr = bswap_32(sockaddr->sin_addr.s_addr); | |
863 | ||
864 | //store the IP addr as a string | |
865 | sIPAddrInfoArray[addrArrayIndex].fIPAddrStr.Len = ::strlen(theAddrStr); | |
866 | @@ -281,7 +282,7 @@ | |
867 | char* theAddrStr = ::inet_ntoa(theAddr->sin_addr); | |
868 | ||
869 | //store the IP addr | |
870 | - sIPAddrInfoArray[currentIndex].fIPAddr = ntohl(theAddr->sin_addr.s_addr); | |
871 | + sIPAddrInfoArray[currentIndex].fIPAddr = bswap_32(theAddr->sin_addr.s_addr); | |
872 | ||
873 | //store the IP addr as a string | |
874 | sIPAddrInfoArray[currentIndex].fIPAddrStr.Len = ::strlen(theAddrStr); | |
875 | @@ -438,7 +439,7 @@ | |
876 | char* theAddrStr = ::inet_ntoa(sin.sin_addr); | |
877 | ||
878 | //store the IP addr | |
879 | - sIPAddrInfoArray[currentIndex].fIPAddr = ntohl(sin.sin_addr.s_addr); | |
880 | + sIPAddrInfoArray[currentIndex].fIPAddr = bswap_32(sin.sin_addr.s_addr); | |
881 | ||
882 | //store the IP addr as a string | |
883 | sIPAddrInfoArray[currentIndex].fIPAddrStr.Len = ::strlen(theAddrStr); | |
884 | @@ -483,7 +484,7 @@ | |
885 | char* theAddrStr = ::inet_ntoa(addrPtr->sin_addr); | |
886 | ||
887 | //store the IP addr | |
888 | - sIPAddrInfoArray[currentIndex].fIPAddr = ntohl(addrPtr->sin_addr.s_addr); | |
889 | + sIPAddrInfoArray[currentIndex].fIPAddr = bswap_32(addrPtr->sin_addr.s_addr); | |
890 | ||
891 | //store the IP addr as a string | |
892 | sIPAddrInfoArray[currentIndex].fIPAddrStr.Len = ::strlen(theAddrStr); | |
893 | @@ -600,6 +601,6 @@ | |
894 | if (inAddrStr == NULL) | |
895 | return 0; | |
896 | ||
897 | - return ntohl(::inet_addr(inAddrStr)); | |
898 | + return bswap_32(::inet_addr(inAddrStr)); | |
899 | } | |
900 | ||
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 | |
904 | @@ -34,6 +34,7 @@ | |
905 | #define __SOCKETUTILS_H__ | |
906 | ||
907 | #ifndef __Win32__ | |
908 | +#include <byteswap.h> | |
909 | #include <sys/socket.h> | |
910 | #include <netinet/in.h> | |
911 | #include <net/if.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 | |
915 | @@ -32,6 +32,7 @@ | |
916 | */ | |
917 | ||
918 | #ifndef __Win32__ | |
919 | +#include <byteswap.h> | |
920 | #include <sys/types.h> | |
921 | #include <sys/socket.h> | |
922 | #include <arpa/inet.h> | |
923 | @@ -100,8 +101,8 @@ | |
924 | { | |
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); | |
931 | ||
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 | |
937 | @@ -35,6 +35,7 @@ | |
938 | #ifndef __TCPSOCKET_H__ | |
939 | #define __TCPSOCKET_H__ | |
940 | ||
941 | +#include <byteswap.h> | |
942 | #include <stdio.h> | |
943 | #include <stdlib.h> | |
944 | #include "SafeStdLib.h" | |
945 | @@ -81,8 +82,8 @@ | |
946 | //ACCESSORS: | |
947 | //Returns NULL if not currently available. | |
948 | ||
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(); | |
955 | ||
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 | |
959 | @@ -32,6 +32,7 @@ | |
960 | */ | |
961 | ||
962 | #ifndef __Win32__ | |
963 | +#include <byteswap.h> | |
964 | #include <sys/types.h> | |
965 | #include <sys/socket.h> | |
966 | ||
967 | @@ -74,8 +75,8 @@ | |
968 | ||
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); | |
975 | ||
976 | #ifdef __sgi__ | |
977 | int theErr = ::sendto(fFileDesc, inBuffer, inLength, 0, (sockaddr*)&theRemoteAddr, sizeof(theRemoteAddr)); | |
978 | @@ -112,8 +113,8 @@ | |
979 | if (theRecvLen == -1) | |
980 | return (OS_Error)OSThread::GetErrno(); | |
981 | ||
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; | |
988 | return OS_NoErr; | |
989 | @@ -125,10 +126,10 @@ | |
990 | UInt32 localAddr = fLocalAddr.sin_addr.s_addr; // Already in network byte order | |
991 | ||
992 | #if __solaris__ | |
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)); | |
997 | #endif | |
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()); | |
1003 | @@ -166,8 +167,8 @@ | |
1004 | OS_Error UDPSocket::LeaveMulticast(UInt32 inRemoteAddr) | |
1005 | { | |
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)); | |
1012 | if (err == -1) | |
1013 | return (OS_Error)OSThread::GetErrno(); | |
1014 | ||
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 | |
1018 | @@ -150,6 +150,7 @@ | |
1019 | ||
1020 | clean: | |
1021 | rm -f $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) | |
1022 | + rm -f DarwinStreamingServer | |
1023 | ||
1024 | .SUFFIXES: .cpp .c .o | |
1025 | ||
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 | |
1029 | @@ -216,7 +216,7 @@ | |
1030 | ||
1031 | struct sigaction act; | |
1032 | ||
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); | |
1036 | act.sa_flags = 0; | |
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 | |
1041 | @@ -23,6 +23,7 @@ | |
1042 | * | |
1043 | */ | |
1044 | ||
1045 | +#include <byteswap.h> | |
1046 | #include "MP3Broadcaster.h" | |
1047 | #include "MP3MetaInfoUpdater.h" | |
1048 | #include "StringTranslator.h" | |
1049 | @@ -874,7 +875,7 @@ | |
1050 | { | |
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])); | |
1055 | else | |
1056 | qtss_printf("Couldn't resolve address %s\n", mIPAddr); | |
1057 | } | |
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 | |
1061 | @@ -23,6 +23,7 @@ | |
1062 | * | |
1063 | */ | |
1064 | ||
1065 | +#include <byteswap.h> | |
1066 | #include "MP3FileBroadcaster.h" | |
1067 | #include <fcntl.h> | |
1068 | //#include <unistd.h> | |
1069 | @@ -312,7 +313,7 @@ | |
1070 | break; | |
1071 | ||
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; | |
1075 | ||
1076 | if (!strncmp(ptr, "TP1", 3)) // Artist | |
1077 | { | |
1078 | @@ -404,7 +405,7 @@ | |
1079 | if (*ptr == 0) | |
1080 | break; | |
1081 | ||
1082 | - int fieldLen = ntohl(OS::GetUInt32FromMemory((UInt32*)(ptr+4))); | |
1083 | + int fieldLen = bswap_32(OS::GetUInt32FromMemory((UInt32*)(ptr+4))); | |
1084 | ||
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 | |
1090 | @@ -31,6 +31,7 @@ | |
1091 | ||
1092 | */ | |
1093 | ||
1094 | +#include <byteswap.h> | |
1095 | #include "BroadcasterSession.h" | |
1096 | #include "OSMemory.h" | |
1097 | #include "StrPtrLen.h" | |
1098 | @@ -835,10 +836,10 @@ | |
1099 | return; | |
1100 | ||
1101 | UInt16* theSeqNumP = (UInt16*)inPacket; | |
1102 | - UInt16 theSeqNum = ntohs(theSeqNumP[1]); | |
1103 | + UInt16 theSeqNum = bswap_16(theSeqNumP[1]); | |
1104 | ||
1105 | // UInt32* theSsrcP = (UInt32*)inPacket; | |
1106 | -// UInt32 theSSRC = ntohl(theSsrcP[2]); | |
1107 | +// UInt32 theSSRC = bswap_32(theSsrcP[2]); | |
1108 | ||
1109 | for (UInt32 x = 0; x < fSDPParser.GetNumStreams(); x++) | |
1110 | { | |
1111 | @@ -940,11 +941,11 @@ | |
1112 | UInt32 *theWriter = (UInt32*)theRRBuffer; | |
1113 | ||
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); | |
1125 | ||
1126 | SInt16 theSeqNumDifference = inCurSeqNum - fStats[inTrackIndex].fHighestSeqNum; | |
1127 | ||
1128 | @@ -959,7 +960,7 @@ | |
1129 | ||
1130 | if (theSeqNumDifference > 0) | |
1131 | { | |
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); | |
1136 | #endif | |
1137 | @@ -997,20 +998,20 @@ | |
1138 | } | |
1139 | ||
1140 | // We have 1 completed mask. Add it to the packet | |
1141 | - *(theWriter++) = htonl(mask); | |
1142 | + *(theWriter++) = bswap_32(mask); | |
1143 | } | |
1144 | fStats[inTrackIndex].fLastAckedSeqNum = inCurSeqNum; | |
1145 | } | |
1146 | else | |
1147 | { | |
1148 | // Just ack cur seq num, this is an out of order packet | |
1149 | - *(theWriter++) = htonl(inCurSeqNum); | |
1150 | + *(theWriter++) = bswap_32(inCurSeqNum); | |
1151 | } | |
1152 | ||
1153 | // | |
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 | |
1158 | ||
1159 | // Send the packet | |
1160 | Assert(fStats[inTrackIndex].fDestRTCPPort != 0); | |
1161 | @@ -1037,11 +1038,11 @@ | |
1162 | UInt32 *theWriter = (UInt32*)theRRBuffer; | |
1163 | ||
1164 | // RECEIVER REPORT | |
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; | |
1177 | //else | |
1178 | @@ -1049,28 +1050,28 @@ | |
1179 | //temp = t; | |
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 | |
1191 | ||
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; | |
1218 | //else | |
1219 | // temp = 0; | |
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 | |
1240 | ||
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 | |
1246 | @@ -45,6 +45,7 @@ | |
1247 | ||
1248 | ||
1249 | ||
1250 | +#include <byteswap.h> | |
1251 | #include <stdio.h> | |
1252 | #include <stdlib.h> | |
1253 | #include "SafeStdLib.h" | |
1254 | @@ -419,7 +420,7 @@ | |
1255 | ||
1256 | // if the address is a multicast address then we can't announce the broadcast. | |
1257 | ||
1258 | - if(SocketUtils::IsMulticastIPAddr(ntohl(inet_addr(broadcastParms->mDestAddress)))) { | |
1259 | + if(SocketUtils::IsMulticastIPAddr(bswap_32(inet_addr(broadcastParms->mDestAddress)))) { | |
1260 | sAnnounceBroadcast = false; | |
1261 | return true; | |
1262 | } | |
1263 | @@ -2082,7 +2083,7 @@ | |
1264 | ||
1265 | struct sigaction act; | |
1266 | ||
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); | |
1270 | act.sa_flags = 0; | |
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 | |
1275 | @@ -23,6 +23,7 @@ | |
1276 | * | |
1277 | */ | |
1278 | ||
1279 | +#include <byteswap.h> | |
1280 | #include "playlist_elements.h" | |
1281 | #include "playlist_utils.h" | |
1282 | #include "OS.h" | |
1283 | @@ -100,7 +101,7 @@ | |
1284 | fData.fSavedSoundDescSize = descSize; | |
1285 | fData.fSavedDataRefIndex ++ ; // it is different than saved so change the index | |
1286 | } | |
1287 | - packetSDPtr->dataRefIndex = htons(fData.fSavedDataRefIndex); | |
1288 | + packetSDPtr->dataRefIndex = bswap_16(fData.fSavedDataRefIndex); | |
1289 | ||
1290 | } while (false); | |
1291 | } | |
1292 | @@ -168,10 +169,10 @@ | |
1293 | ||
1294 | //write the SR & SDES headers | |
1295 | UInt32* theSRWriter = (UInt32*)&fData.fSenderReportBuffer; | |
1296 | - *theSRWriter = htonl(0x80c80006); | |
1297 | + *theSRWriter = bswap_32(0x80c80006); | |
1298 | theSRWriter += 7; | |
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; | |
1304 | } | |
1305 | @@ -345,7 +346,7 @@ | |
1306 | UInt32* theReport = (UInt32*) fData.fSenderReportBuffer; | |
1307 | ||
1308 | theReport++; | |
1309 | - *theReport = htonl(fData.fSsrc); | |
1310 | + *theReport = bswap_32(fData.fSsrc); | |
1311 | ||
1312 | theReport++; | |
1313 | SInt64* theNTPTimestampP = (SInt64*)theReport; | |
1314 | @@ -353,7 +354,7 @@ | |
1315 | PlayListUtils::TimeMilli_To_Fixed64Secs(theTime - fData.fStreamStartTime)); | |
1316 | ||
1317 | theReport += 2; | |
1318 | - *theReport = htonl(fData.fTimeStamp); | |
1319 | + *theReport = bswap_32(fData.fTimeStamp); | |
1320 | ||
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 ); | |
1325 | ||
1326 | //qtss_printf("MediaStream::UpdateSenderReport RTCP timestamp = %"_U32BITARG_"\n",(UInt32) curTimeInScale); | |
1327 | - *theReport = htonl((UInt32) curTimeInScale); | |
1328 | + *theReport = bswap_32((UInt32) curTimeInScale); | |
1329 | ||
1330 | theReport++; | |
1331 | fData.fPacketCount = (UInt32) fData.fPacketsSent; | |
1332 | - *theReport = htonl(fData.fPacketCount); | |
1333 | + *theReport = bswap_32(fData.fPacketCount); | |
1334 | ||
1335 | theReport++; | |
1336 | fData.fByteCount = (UInt32) fData.fBytesSent; | |
1337 | - *theReport = htonl(fData.fByteCount); | |
1338 | + *theReport = bswap_32(fData.fByteCount); | |
1339 | ||
1340 | theReport += 2; | |
1341 | - *theReport = htonl(fData.fSsrc); | |
1342 | + *theReport = bswap_32(fData.fSsrc); | |
1343 | ||
1344 | LogStr("Sender Report\n"); | |
1345 | LogUInt("NTP ",(UInt32) ((*theNTPTimestampP) >> 32)," "); | |
1346 | @@ -463,23 +464,23 @@ | |
1347 | { | |
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); | |
1354 | ||
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); | |
1361 | ||
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); | |
1368 | ||
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); | |
1375 | } | |
1376 | ||
1377 | SInt16 UDPSocketPair::Bind(UInt32 addr) | |
1378 | @@ -502,8 +503,8 @@ | |
1379 | PortRTCp = count; | |
1380 | Assert( (PortRTCp & 1) == 1);// must be odd and one more than rtp port | |
1381 | ||
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); | |
1386 | ||
1387 | //qtss_printf("Attempting to bind to rtp port %d \n",PortRTp); | |
1388 | ||
1389 | @@ -546,7 +547,7 @@ | |
1390 | if (destAddrPtr == NULL) break; | |
1391 | if (socket == kInvalidSocket) break; | |
1392 | ||
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)); | |
1396 | ||
1397 | result = 0; | |
1398 | @@ -585,14 +586,14 @@ | |
1399 | { UInt32 netAddress = inet_addr(destAddress); | |
1400 | ||
1401 | fDestAddrRTp = fLocalAddrRTp; | |
1402 | - fDestAddrRTp.sin_port = htons(destPortRTp); | |
1403 | + fDestAddrRTp.sin_port = bswap_16(destPortRTp); | |
1404 | fDestAddrRTp.sin_addr.s_addr = netAddress; | |
1405 | ||
1406 | fDestAddrRTCp = fLocalAddrRTCp; | |
1407 | - fDestAddrRTCp.sin_port = htons(destPortRTCp); | |
1408 | + fDestAddrRTCp.sin_port = bswap_16(destPortRTCp); | |
1409 | fDestAddrRTCp.sin_addr.s_addr = netAddress; | |
1410 | ||
1411 | - fIsMultiCast = SocketUtils::IsMulticastIPAddr(ntohl(netAddress)); | |
1412 | + fIsMultiCast = SocketUtils::IsMulticastIPAddr(bswap_32(netAddress)); | |
1413 | ||
1414 | result = 0; | |
1415 | } | |
1416 | @@ -619,8 +620,8 @@ | |
1417 | UInt32 localAddr = fLocalAddrRTp.sin_addr.s_addr; // Already in network byte order | |
1418 | ||
1419 | #if __solaris__ | |
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)); | |
1424 | #endif | |
1425 | ||
1426 | struct ip_mreq theMulti; | |
1427 | @@ -656,8 +657,8 @@ | |
1428 | UInt32 localAddr = fLocalAddrRTp.sin_addr.s_addr; // Already in network byte order | |
1429 | ||
1430 | #if __solaris__ | |
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)); | |
1435 | #endif | |
1436 | ||
1437 | struct ip_mreq theMulti; | |
1438 | @@ -771,7 +772,7 @@ | |
1439 | { | |
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; | |
1445 | result = 0; | |
1446 | } | |
1447 | @@ -828,9 +829,9 @@ | |
1448 | if (fThePacket && timeStampPtr && sequencePtr && SSRCPtr && payloadTypeAndMarkPtr) | |
1449 | { | |
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]); | |
1457 | result = 0; | |
1458 | } | |
1459 | ||
1460 | @@ -859,9 +860,9 @@ | |
1461 | LogUInt("ssrc = ", SSRC, "\n"); | |
1462 | ||
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); | |
1470 | result = 0; | |
1471 | ||
1472 | LogBuffer(); | |
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 | |
1476 | @@ -22,6 +22,7 @@ | |
1477 | * @APPLE_LICENSE_HEADER_END@ | |
1478 | * | |
1479 | */ | |
1480 | +#include <byteswap.h> | |
1481 | #include "playlist_utils.h" | |
1482 | #include "playlist_SDPGen.h" | |
1483 | #include "playlist_broadcaster.h" | |
1484 | @@ -162,7 +163,7 @@ | |
1485 | // c=IN IP4 (destinatin ip address) | |
1486 | { | |
1487 | char sdpLine[255]; | |
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); | |
1491 | else | |
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 | |
1496 | @@ -28,6 +28,7 @@ | |
1497 | 8.2.99 - rt updated ShowSettings() to display user names for fields instead of C++ member names. | |
1498 | */ | |
1499 | ||
1500 | +#include <byteswap.h> | |
1501 | #include "PLBroadcastDef.h" | |
1502 | #include "MyAssert.h" | |
1503 | #include "SocketUtils.h" | |
1504 | @@ -473,7 +474,7 @@ | |
1505 | struct hostent* theHostent = ::gethostbyname(mDestAddress); | |
1506 | if (theHostent != NULL) | |
1507 | { | |
1508 | - inAddr = ntohl(*(UInt32*)(theHostent->h_addr_list[0])); | |
1509 | + inAddr = bswap_32(*(UInt32*)(theHostent->h_addr_list[0])); | |
1510 | ||
1511 | struct in_addr inAddrStruct; | |
1512 | char buffer[50]; | |
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 | |
1516 | @@ -30,6 +30,7 @@ | |
1517 | // ------------------------------------- | |
1518 | // Includes | |
1519 | // | |
1520 | +#include <byteswap.h> | |
1521 | #include <stdio.h> | |
1522 | #include <stdlib.h> | |
1523 | #include "SafeStdLib.h" | |
1524 | @@ -126,7 +127,7 @@ | |
1525 | if( !ReadBytes(Offset, (char *)&tempDatum, 2) ) | |
1526 | return false; | |
1527 | ||
1528 | - *Datum = ntohs(tempDatum); | |
1529 | + *Datum = bswap_16(tempDatum); | |
1530 | return true; | |
1531 | } | |
1532 | ||
1533 | @@ -141,7 +142,7 @@ | |
1534 | if( !ReadBytes(Offset, (char *)&tempDatum, 4) ) | |
1535 | return false; | |
1536 | ||
1537 | - *Datum = ntohl(tempDatum); | |
1538 | + *Datum = bswap_32(tempDatum); | |
1539 | return true; | |
1540 | } | |
1541 | ||
1542 | @@ -156,7 +157,7 @@ | |
1543 | if( !ReadBytes(Offset, (char *)&tempDatum, 4) ) | |
1544 | return false; | |
1545 | ||
1546 | - tempDatum = ntohl(tempDatum); | |
1547 | + tempDatum = bswap_32(tempDatum); | |
1548 | *Datum = (UInt64) tempDatum; | |
1549 | return true; | |
1550 | } | |
1551 | @@ -171,7 +172,7 @@ | |
1552 | if( !ReadBytes(Offset, (char *)&tempDatum, 4) ) | |
1553 | return false; | |
1554 | ||
1555 | - tempDatum = ntohl(tempDatum); | |
1556 | + tempDatum = bswap_32(tempDatum); | |
1557 | *Datum = (SInt64) (SInt32) tempDatum; | |
1558 | return true; | |
1559 | } | |
1560 | @@ -233,7 +234,7 @@ | |
1561 | if( !ReadSubAtomBytes(AtomPath, (char *)&tempDatum, 2) ) | |
1562 | return false; | |
1563 | ||
1564 | - *Datum = ntohs(tempDatum); | |
1565 | + *Datum = bswap_16(tempDatum); | |
1566 | return true; | |
1567 | } | |
1568 | ||
1569 | @@ -248,7 +249,7 @@ | |
1570 | if( !ReadSubAtomBytes(AtomPath, (char *)&tempDatum, 4) ) | |
1571 | return false; | |
1572 | ||
1573 | - *Datum = ntohl(tempDatum); | |
1574 | + *Datum = bswap_32(tempDatum); | |
1575 | return true; | |
1576 | } | |
1577 | ||
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 | |
1581 | @@ -31,6 +31,7 @@ | |
1582 | // ------------------------------------- | |
1583 | // Includes | |
1584 | // | |
1585 | +#include <byteswap.h> | |
1586 | #include <stdio.h> | |
1587 | #include <stdlib.h> | |
1588 | #include "SafeStdLib.h" | |
1589 | @@ -345,23 +346,23 @@ | |
1590 | for( int loopCount = kMaxMark - 1; loopCount >= 0; loopCount--) { | |
1591 | // | |
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) ) | |
1595 | break; | |
1596 | ||
1597 | // | |
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 */); | |
1601 | } | |
1602 | ||
1603 | ||
1604 | // | |
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'; | |
1609 | ||
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); | |
1615 | pathLength = -1; | |
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 | |
1621 | @@ -33,6 +33,7 @@ | |
1622 | // | |
1623 | // Includes | |
1624 | #ifndef __Win32__ | |
1625 | +#include <byteswap.h> | |
1626 | #include <netinet/in.h> | |
1627 | #endif | |
1628 | #include "QTFile.h" | |
1629 | @@ -63,7 +64,7 @@ | |
1630 | if (Offset && ChunkNumber && (ChunkNumber<=fNumEntries)) | |
1631 | { | |
1632 | if (4 == fOffSetSize) | |
1633 | - *Offset = (UInt64) ntohl( ( (UInt32 *) fTable)[ChunkNumber-1]); | |
1634 | + *Offset = (UInt64) bswap_32( ( (UInt32 *) fTable)[ChunkNumber-1]); | |
1635 | else | |
1636 | *Offset = (UInt64) QTAtom::NTOH64( ( (UInt64 *) fTable)[ChunkNumber-1]); | |
1637 | ||
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 | |
1641 | @@ -30,6 +30,7 @@ | |
1642 | // ------------------------------------- | |
1643 | // Includes | |
1644 | // | |
1645 | +#include <byteswap.h> | |
1646 | #include <stdio.h> | |
1647 | #include <stdlib.h> | |
1648 | #include "SafeStdLib.h" | |
1649 | @@ -255,7 +256,7 @@ | |
1650 | if (fNumEntries == 1) | |
1651 | { | |
1652 | memcpy(&samplesPerChunk, fSampleToChunkTable + (STCB->fCurEntry_GetChunkFirstLastSample * 12) + 4, 4); | |
1653 | - samplesPerChunk = ntohl(samplesPerChunk); | |
1654 | + samplesPerChunk = bswap_32(samplesPerChunk); | |
1655 | ||
1656 | prevSamplesPerChunk = ((chunkNumber -1 ) * samplesPerChunk); | |
1657 | totalSamples = chunkNumber * samplesPerChunk; | |
1658 | @@ -268,9 +269,9 @@ | |
1659 | prevFirstChunk = thisFirstChunk; | |
1660 | ||
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); | |
1667 | ||
1668 | if (prevSamplesPerChunk == 0) | |
1669 | prevSamplesPerChunk = samplesPerChunk; | |
1670 | @@ -347,11 +348,11 @@ | |
1671 | prevFirstChunk = thisFirstChunk; | |
1672 | ||
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); | |
1682 | ||
1683 | thisChunk = thisFirstChunk; | |
1684 | numChunks = thisFirstChunk - prevFirstChunk; | |
1685 | @@ -488,11 +489,11 @@ | |
1686 | // | |
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); | |
1697 | ||
1698 | // | |
1699 | // Check to see if the sample was actually in the last chunk and | |
1700 | @@ -605,11 +606,11 @@ | |
1701 | // | |
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); | |
1712 | ||
1713 | // | |
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 | |
1718 | @@ -31,6 +31,7 @@ | |
1719 | // ------------------------------------- | |
1720 | // Includes | |
1721 | // | |
1722 | +#include <byteswap.h> | |
1723 | #include <stdio.h> | |
1724 | #include <stdlib.h> | |
1725 | #include "SafeStdLib.h" | |
1726 | @@ -141,7 +142,7 @@ | |
1727 | // | |
1728 | // Skip over this mini-atom. | |
1729 | memcpy(&tempInt32, pSampleDescriptionTable, 4); | |
1730 | - pSampleDescriptionTable += ntohl(tempInt32); | |
1731 | + pSampleDescriptionTable += bswap_32(tempInt32); | |
1732 | if (pSampleDescriptionTable > maxSampleDescriptionPtr) | |
1733 | { return false; | |
1734 | } | |
1735 | @@ -171,7 +172,7 @@ | |
1736 | // | |
1737 | // Get this entry's data format. | |
1738 | memcpy(&tempInt32, fTable[CurDesc] + stsdDescPos_DataFormat, 4); | |
1739 | - tempInt32 = ntohl(tempInt32); | |
1740 | + tempInt32 = bswap_32(tempInt32); | |
1741 | ||
1742 | // | |
1743 | // Skip this entry if it does not match. | |
1744 | @@ -183,7 +184,7 @@ | |
1745 | *Buffer = fTable[CurDesc]; | |
1746 | ||
1747 | memcpy(&tempInt32, fTable[CurDesc] + stsdDescPos_Size, 4); | |
1748 | - *Length = ntohl(tempInt32); | |
1749 | + *Length = bswap_32(tempInt32); | |
1750 | ||
1751 | return true; | |
1752 | } | |
1753 | @@ -207,7 +208,7 @@ | |
1754 | // | |
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); | |
1759 | } | |
1760 | ||
1761 | ||
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 | |
1765 | @@ -31,6 +31,7 @@ | |
1766 | // ------------------------------------- | |
1767 | // Includes | |
1768 | // | |
1769 | +#include <byteswap.h> | |
1770 | #include <stdio.h> | |
1771 | #include <stdlib.h> | |
1772 | #include "SafeStdLib.h" | |
1773 | @@ -148,7 +149,7 @@ | |
1774 | ||
1775 | for ( sampleIndex = 0; sampleIndex < fNumEntries; sampleIndex++ ) | |
1776 | { | |
1777 | - fTable[sampleIndex] = ntohl( fTable[sampleIndex] ); | |
1778 | + fTable[sampleIndex] = bswap_32( fTable[sampleIndex] ); | |
1779 | ||
1780 | } | |
1781 | ||
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 | |
1785 | @@ -31,6 +31,7 @@ | |
1786 | // ------------------------------------- | |
1787 | // Includes | |
1788 | // | |
1789 | +#include <byteswap.h> | |
1790 | #include <stdio.h> | |
1791 | #include <stdlib.h> | |
1792 | #include "SafeStdLib.h" | |
1793 | @@ -164,7 +165,7 @@ | |
1794 | { *sizePtr = 0; | |
1795 | ||
1796 | for (UInt32 sampleNumber = firstSampleNumber; sampleNumber <= lastSampleNumber; sampleNumber++ ) | |
1797 | - *sizePtr += ntohl(fTable[sampleNumber-1]); | |
1798 | + *sizePtr += bswap_32(fTable[sampleNumber-1]); | |
1799 | ||
1800 | } | |
1801 | result = true; | |
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 | |
1805 | @@ -33,6 +33,7 @@ | |
1806 | ||
1807 | // | |
1808 | // Includes | |
1809 | +#include <byteswap.h> | |
1810 | #include "QTFile.h" | |
1811 | #include "QTAtom.h" | |
1812 | ||
1813 | @@ -62,7 +63,7 @@ | |
1814 | return true; \ | |
1815 | } else if(SampleNumber && (SampleNumber<=fNumEntries)) { \ | |
1816 | if( Size != NULL ) \ | |
1817 | - *Size = ntohl(fTable[SampleNumber-1]); \ | |
1818 | + *Size = bswap_32(fTable[SampleNumber-1]); \ | |
1819 | return true; \ | |
1820 | } else \ | |
1821 | return false; \ | |
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 | |
1825 | @@ -31,6 +31,7 @@ | |
1826 | // ------------------------------------- | |
1827 | // Includes | |
1828 | // | |
1829 | +#include <byteswap.h> | |
1830 | #include <stdio.h> | |
1831 | #include <stdlib.h> | |
1832 | #include "SafeStdLib.h" | |
1833 | @@ -195,9 +196,9 @@ | |
1834 | // | |
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); | |
1842 | ||
1843 | // | |
1844 | // Can we skip over this entry? | |
1845 | @@ -255,9 +256,9 @@ | |
1846 | // | |
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); | |
1854 | ||
1855 | // | |
1856 | // Can we skip over this entry? | |
1857 | @@ -312,9 +313,9 @@ | |
1858 | // | |
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); | |
1866 | ||
1867 | // Print out a listing. | |
1868 | qtss_printf(" %10"_U32BITARG_" : %10"_U32BITARG_" %10"_U32BITARG_"\n", CurEntry, SampleCount, SampleDuration); | |
1869 | @@ -454,9 +455,9 @@ | |
1870 | // | |
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); | |
1878 | ||
1879 | // | |
1880 | // Can we skip over this entry? | |
1881 | @@ -514,9 +515,9 @@ | |
1882 | // | |
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); | |
1890 | ||
1891 | // | |
1892 | // Can we skip over this entry? | |
1893 | @@ -571,9 +572,9 @@ | |
1894 | // | |
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); | |
1902 | ||
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 | |
1908 | @@ -33,6 +33,7 @@ | |
1909 | // | |
1910 | // Includes | |
1911 | #ifndef __Win32__ | |
1912 | +#include <byteswap.h> | |
1913 | #include <netinet/in.h> | |
1914 | #endif | |
1915 | ||
1916 | @@ -62,7 +63,7 @@ | |
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]); \ | |
1922 | return true; \ | |
1923 | } else \ | |
1924 | return false; \ | |
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 | |
1928 | @@ -32,6 +32,7 @@ | |
1929 | // Includes | |
1930 | // | |
1931 | ||
1932 | +#include <byteswap.h> | |
1933 | #include <fcntl.h> | |
1934 | ||
1935 | #include <stdio.h> | |
1936 | @@ -656,7 +657,7 @@ | |
1937 | // | |
1938 | // Swap the AtomLength for little-endian machines. | |
1939 | CurPos += 4; | |
1940 | - atomLength = ntohl(atomLength); | |
1941 | + atomLength = bswap_32(atomLength); | |
1942 | BigAtomLength = (UInt64) atomLength; | |
1943 | hasBigAtom = false; | |
1944 | ||
1945 | @@ -691,12 +692,12 @@ | |
1946 | if( !Read(CurPos, (char *)&atomLength, 4) ) | |
1947 | return false; | |
1948 | CurPos += 4; | |
1949 | - BigAtomLength = (UInt64) ntohl(atomLength); | |
1950 | + BigAtomLength = (UInt64) bswap_32(atomLength); | |
1951 | ||
1952 | if( !Read(CurPos, (char *)&AtomType, 4) ) | |
1953 | return false; | |
1954 | CurPos += 4; | |
1955 | - AtomType = ntohl(AtomType); | |
1956 | + AtomType = bswap_32(AtomType); | |
1957 | ||
1958 | // | |
1959 | // Skip over the rest of the fields. | |
1960 | @@ -716,7 +717,7 @@ | |
1961 | ||
1962 | CurPos += 4; | |
1963 | CurAtomHeaderSize = 4 + 4; // AtomLength + AtomType | |
1964 | - AtomType = ntohl(AtomType); | |
1965 | + AtomType = bswap_32(AtomType); | |
1966 | ||
1967 | if ( atomLength == 1 ) //large size atom | |
1968 | { | |
1969 | @@ -799,7 +800,7 @@ | |
1970 | NewTOCEntry->TOCID = fNextTOCID++; | |
1971 | ||
1972 | NewTOCEntry->AtomType = AtomType; | |
1973 | - NewTOCEntry->beAtomType = htonl(AtomType); | |
1974 | + NewTOCEntry->beAtomType = bswap_32(AtomType); | |
1975 | ||
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 | |
1981 | @@ -47,6 +47,7 @@ | |
1982 | // ------------------------------------- | |
1983 | // Includes | |
1984 | // | |
1985 | +#include <byteswap.h> | |
1986 | #include <stdio.h> | |
1987 | #include <stdlib.h> | |
1988 | #include "SafeStdLib.h" | |
1989 | @@ -236,7 +237,7 @@ | |
1990 | return errInvalidQuickTimeFile; | |
1991 | ||
1992 | ::memcpy(&fMaxPacketSize, sampleDescription + 20, 4); | |
1993 | - fMaxPacketSize = ntohl(fMaxPacketSize); | |
1994 | + fMaxPacketSize = bswap_32(fMaxPacketSize); | |
1995 | ||
1996 | for( pSampleDescription = (sampleDescription + 24); | |
1997 | pSampleDescription < (sampleDescription + sampleDescriptionLength); | |
1998 | @@ -248,27 +249,27 @@ | |
1999 | // | |
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); | |
2004 | ||
2005 | ::memcpy( &dataType, pSampleDescription + 4, 4); | |
2006 | - dataType = ntohl(dataType); | |
2007 | + dataType = bswap_32(dataType); | |
2008 | ||
2009 | // | |
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); | |
2016 | break; | |
2017 | ||
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); | |
2022 | break; | |
2023 | ||
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); | |
2028 | break; | |
2029 | } | |
2030 | ||
2031 | @@ -431,17 +432,17 @@ | |
2032 | // need to acquire the header info on every pass | |
2033 | ||
2034 | MOVE_WORD( hdrData.hintFlags, samplePacketPtr + 8); | |
2035 | - hdrData.hintFlags = ntohs( hdrData.hintFlags ); | |
2036 | + hdrData.hintFlags = bswap_16( hdrData.hintFlags ); | |
2037 | ||
2038 | MOVE_WORD( hdrData.dataEntryCount, samplePacketPtr + 10); | |
2039 | - hdrData.dataEntryCount = ntohs(hdrData.dataEntryCount); | |
2040 | + hdrData.dataEntryCount = bswap_16(hdrData.dataEntryCount); | |
2041 | ||
2042 | hdrData.tlvTimestampOffset = 0; | |
2043 | ||
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 | |
2046 | { | |
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 | |
2051 | ||
2052 | @@ -459,9 +460,9 @@ | |
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) | |
2055 | { | |
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 | |
2062 | ||
2063 | if (theType == FOUR_CHARS_TO_INT( 'r', 't', 'p', 'o' )) //'rtpo' | |
2064 | { | |
2065 | @@ -479,11 +480,11 @@ | |
2066 | } | |
2067 | ||
2068 | MOVE_LONG_WORD( hdrData.relativePacketTransmissionTime, samplePacketPtr ); | |
2069 | - hdrData.relativePacketTransmissionTime = ntohl(hdrData.relativePacketTransmissionTime); | |
2070 | + hdrData.relativePacketTransmissionTime = bswap_32(hdrData.relativePacketTransmissionTime); | |
2071 | ||
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); | |
2076 | ||
2077 | } | |
2078 | ||
2079 | @@ -671,7 +672,7 @@ | |
2080 | MOVE_WORD( entryCount, buf ); | |
2081 | //::memcpy(&entryCount, buf, 2); | |
2082 | ||
2083 | - *numPackets = ntohs(entryCount); | |
2084 | + *numPackets = bswap_16(entryCount); | |
2085 | ||
2086 | return errNoError; | |
2087 | } | |
2088 | @@ -729,21 +730,21 @@ | |
2089 | trackRefIndex = (SInt8)*(pBuf + 1); | |
2090 | ||
2091 | MOVE_WORD( readLength, pBuf + 2); | |
2092 | - cacheHintSampleLen = hintMaxRead = readLength = ntohs(readLength); | |
2093 | + cacheHintSampleLen = hintMaxRead = readLength = bswap_16(readLength); | |
2094 | ||
2095 | MOVE_LONG_WORD( mediaSampleNumber, pBuf + 4); | |
2096 | - mediaSampleNumber = ntohl(mediaSampleNumber); | |
2097 | + mediaSampleNumber = bswap_32(mediaSampleNumber); | |
2098 | ||
2099 | MOVE_LONG_WORD( readOffset, pBuf + 8); | |
2100 | - readOffset = ntohl(readOffset); | |
2101 | + readOffset = bswap_32(readOffset); | |
2102 | ||
2103 | MOVE_WORD( bytesPerCompressionBlock, pBuf + 12); | |
2104 | - bytesPerCompressionBlock = ntohs(bytesPerCompressionBlock); | |
2105 | + bytesPerCompressionBlock = bswap_16(bytesPerCompressionBlock); | |
2106 | if( bytesPerCompressionBlock == 0 ) | |
2107 | bytesPerCompressionBlock = 1; | |
2108 | ||
2109 | MOVE_WORD( samplesPerCompressionBlock, pBuf + 14); | |
2110 | - samplesPerCompressionBlock = ntohs(samplesPerCompressionBlock); | |
2111 | + samplesPerCompressionBlock = bswap_16(samplesPerCompressionBlock); | |
2112 | if( samplesPerCompressionBlock == 0 ) | |
2113 | samplesPerCompressionBlock = 1; | |
2114 | ||
2115 | @@ -1192,7 +1193,7 @@ | |
2116 | return errInvalidQuickTimeFile; | |
2117 | ||
2118 | MOVE_WORD( entryCount, (char *)buf + 0); | |
2119 | - entryCount = ntohs(entryCount); | |
2120 | + entryCount = bswap_16(entryCount); | |
2121 | if( (packetNumber-1) > entryCount ) | |
2122 | return errInvalidQuickTimeFile; | |
2123 | ||
2124 | @@ -1257,24 +1258,24 @@ | |
2125 | ||
2126 | // | |
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); | |
2131 | ||
2132 | //TEMP_PRINT_ONE( "QTHintTrack::GetPacket rtpHeaderBits %li.\n", (SInt32)rtpHeaderBits ); | |
2133 | pPacketOutBuf += 2; | |
2134 | ||
2135 | - tempInt16 = htons(hdrData.rtpSequenceNumber); | |
2136 | + tempInt16 = bswap_16(hdrData.rtpSequenceNumber); | |
2137 | COPY_WORD(pPacketOutBuf, &tempInt16); | |
2138 | pPacketOutBuf += 2; | |
2139 | ||
2140 | tempInt32 = rtpTimestamp; | |
2141 | tempInt32 += hdrData.tlvTimestampOffset; // rtpo tlv offset | |
2142 | ||
2143 | - tempInt32 = htonl(tempInt32); | |
2144 | + tempInt32 = bswap_32(tempInt32); | |
2145 | COPY_LONG_WORD(pPacketOutBuf, &tempInt32); | |
2146 | pPacketOutBuf += 4; | |
2147 | ||
2148 | - tempInt32 = htonl(ssrc); | |
2149 | + tempInt32 = bswap_32(ssrc); | |
2150 | COPY_LONG_WORD(pPacketOutBuf, &tempInt32); | |
2151 | pPacketOutBuf += 4; | |
2152 | ||
2153 | @@ -1321,7 +1322,7 @@ | |
2154 | else | |
2155 | theFrameType = RTPMetaInfoPacket::kPFrameType; | |
2156 | ||
2157 | - theFrameType = htons(theFrameType); | |
2158 | + theFrameType = bswap_16(theFrameType); | |
2159 | this->WriteMetaInfoField(RTPMetaInfoPacket::kFrameTypeField, htcb->fRTPMetaInfoFieldArray[fieldCount], &theFrameType, sizeof(theFrameType), &pPacketOutBuf); | |
2160 | break; | |
2161 | } | |
2162 | @@ -1333,7 +1334,7 @@ | |
2163 | } | |
2164 | case RTPMetaInfoPacket::kSeqNumField: | |
2165 | { | |
2166 | - tempInt16 = htons(hdrData.rtpSequenceNumber); | |
2167 | + tempInt16 = bswap_16(hdrData.rtpSequenceNumber); | |
2168 | this->WriteMetaInfoField(RTPMetaInfoPacket::kSeqNumField, htcb->fRTPMetaInfoFieldArray[fieldCount], &tempInt16, sizeof(tempInt16), &pPacketOutBuf); | |
2169 | break; | |
2170 | } | |
2171 | @@ -1365,7 +1366,7 @@ | |
2172 | { | |
2173 | // Sample Mode | |
2174 | MOVE_WORD( tempInt16, pSampleBuffer + 2); | |
2175 | - tempInt16 = ntohs(tempInt16); | |
2176 | + tempInt16 = bswap_16(tempInt16); | |
2177 | ||
2178 | DEEP_DEBUG_PRINT (( "QTHintTrack::GetPacket - ....Sample entry found (size=%u)\n", tempInt16 ) ); | |
2179 | packetSize += tempInt16; | |
2180 | @@ -1402,7 +1403,7 @@ | |
2181 | ||
2182 | // Sample Description Data Mode | |
2183 | MOVE_WORD( tempInt16, pSampleBuffer + 2); | |
2184 | - tempInt16 = ntohs(tempInt16); | |
2185 | + tempInt16 = bswap_16(tempInt16); | |
2186 | ||
2187 | DEEP_DEBUG_PRINT(("QTHintTrack::GetPacket - ....Sample Description entry found (size=%u)\n", tempInt16)); | |
2188 | packetSize += tempInt16; | |
2189 | @@ -1451,7 +1452,7 @@ | |
2190 | else | |
2191 | { | |
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); | |
2196 | } | |
2197 | } | |
2198 | @@ -1469,10 +1470,10 @@ | |
2199 | { | |
2200 | // | |
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); | |
2205 | (*ioBuffer)+=2; | |
2206 | - UInt16 theLen = htons((UInt16)inFieldLen); | |
2207 | + UInt16 theLen = bswap_16((UInt16)inFieldLen); | |
2208 | COPY_WORD(*ioBuffer, &theLen); | |
2209 | (*ioBuffer)+=2; | |
2210 | } | |
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 | |
2214 | @@ -31,6 +31,8 @@ | |
2215 | // ------------------------------------- | |
2216 | // Includes | |
2217 | // | |
2218 | +#include <byteswap.h> | |
2219 | +#include <byteswap.h> | |
2220 | #include <stdio.h> | |
2221 | #include <stdlib.h> | |
2222 | #include "SafeStdLib.h" | |
2223 | @@ -604,7 +606,7 @@ | |
2224 | // Verify that this is an SDP atom. | |
2225 | fFile->Read(globalSDPTOCEntry->AtomDataPos, (char *)&tempAtomType, 4); | |
2226 | ||
2227 | - if ( ntohl(tempAtomType) == FOUR_CHARS_TO_INT('s', 'd', 'p', ' ') ) | |
2228 | + if ( bswap_32(tempAtomType) == FOUR_CHARS_TO_INT('s', 'd', 'p', ' ') ) | |
2229 | { | |
2230 | haveGlobalSDPAtom = true; | |
2231 | fSDPFileLength += (UInt32) (globalSDPTOCEntry->AtomDataLength - 4); | |
2232 | @@ -1178,7 +1180,7 @@ | |
2233 | if (trackEntry->CurPacket) // we have the packet | |
2234 | { | |
2235 | timeStampP = (UInt32 *)((char *)trackEntry->CurPacket + 4); | |
2236 | - rtpTimestamp = ntohl(*timeStampP); | |
2237 | + rtpTimestamp = bswap_32(*timeStampP); | |
2238 | } | |
2239 | else | |
2240 | { | |
2241 | @@ -1244,7 +1246,7 @@ | |
2242 | // Read the sequence number right out of the packet. | |
2243 | ::memcpy(&rtpSequenceNumber, (char *)trackEntry->CurPacket + 2, 2); | |
2244 | ||
2245 | - return ntohs(rtpSequenceNumber); | |
2246 | + return bswap_16(rtpSequenceNumber); | |
2247 | } | |
2248 | ||
2249 | Float64 QTRTPFile::GetNextPacket(char ** outPacket, int * outPacketLength) | |
2250 | @@ -1297,7 +1299,7 @@ | |
2251 | ||
2252 | // | |
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); | |
2257 | ||
2258 | // | |
2259 | @@ -1533,10 +1535,10 @@ | |
2260 | pTimestamp = (UInt32 *)((char *)trackEntry->CurPacket + 4); | |
2261 | ||
2262 | if( doSeek || (trackEntry->QualityLevel > kAllPackets) ) | |
2263 | - trackEntry->SequenceNumberAdditive += (trackEntry->LastSequenceNumber + 1) - ntohs(*pSequenceNumber); | |
2264 | + trackEntry->SequenceNumberAdditive += (trackEntry->LastSequenceNumber + 1) - bswap_16(*pSequenceNumber); | |
2265 | ||
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); | |
2270 | ||
2271 | // | |
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 | |
2276 | @@ -23,6 +23,7 @@ | |
2277 | * | |
2278 | */ | |
2279 | ||
2280 | +#include <byteswap.h> | |
2281 | #include <stdio.h> | |
2282 | #include <stdlib.h> | |
2283 | #include "SafeStdLib.h" | |
2284 | @@ -204,7 +205,7 @@ | |
2285 | UInt32 value = RTPFile->GetLastPacketTrack()->Cookie2; | |
2286 | ||
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)); | |
2292 | } | |
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 | |
2296 | @@ -23,6 +23,7 @@ | |
2297 | * | |
2298 | */ | |
2299 | ||
2300 | +#include <byteswap.h> | |
2301 | #include <stdio.h> | |
2302 | #include <stdlib.h> | |
2303 | #include "SafeStdLib.h" | |
2304 | @@ -203,7 +204,7 @@ | |
2305 | break; | |
2306 | } | |
2307 | ||
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]); | |
2311 | trackcount --; | |
2312 | } | |
2313 | @@ -228,7 +229,7 @@ | |
2314 | } | |
2315 | ||
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)); | |
2320 | argv++; | |
2321 | } | |
2322 | @@ -293,9 +294,9 @@ | |
2323 | } | |
2324 | ||
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); | |
2331 | ||
2332 | if (!hintOnly) | |
2333 | if (!silent) | |
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 | |
2337 | @@ -31,6 +31,7 @@ | |
2338 | */ | |
2339 | ||
2340 | ||
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 | |
2348 | @@ -31,6 +31,7 @@ | |
2349 | #ifndef _RTCPACKPACKETFMT_H_ | |
2350 | #define _RTCPACKPACKETFMT_H_ | |
2351 | ||
2352 | +#include <byteswap.h> | |
2353 | #include <stdlib.h> | |
2354 | #include <arpa/inet.h> | |
2355 | #include "StrPtrLen.h" | |
2356 | @@ -85,15 +86,15 @@ | |
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')); | |
2366 | } | |
2367 | ||
2368 | void SetSSRC(UInt32 SSRC) | |
2369 | { | |
2370 | RTCPAckHeader &header = *reinterpret_cast<RTCPAckHeader *>(fBuf.Ptr); | |
2371 | - header.SSRC = htonl(SSRC); | |
2372 | + header.SSRC = bswap_32(SSRC); | |
2373 | } | |
2374 | ||
2375 | //Can handle duplicates | |
2376 | @@ -103,8 +104,8 @@ | |
2377 | ::qsort(AckList.begin(), AckList.size(), sizeof(UInt32), UInt32Compare); | |
2378 | ||
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())); | |
2384 | ||
2385 | fBitMaskSize = 0; | |
2386 | if (AckList.front() == AckList.back()) //no mask is needed | |
2387 | @@ -114,7 +115,7 @@ | |
2388 | UInt32 slotsInMaskNeeded = AckList.back() - AckList.front(); | |
2389 | fBitMaskSize = slotsInMaskNeeded % 32 == 0 ? (slotsInMaskNeeded / 32) * 4 : (slotsInMaskNeeded / 32 + 1) * 4; | |
2390 | ||
2391 | - header.length = htons(GetPacketLen() / 4 - 1); | |
2392 | + header.length = bswap_16(GetPacketLen() / 4 - 1); | |
2393 | Assert(fBuf.Len >= GetPacketLen()); | |
2394 | ||
2395 | UInt32 *mask = reinterpret_cast<UInt32 *>(fBuf.Ptr + sizeof(RTCPAckHeader)); | |
2396 | @@ -135,7 +136,7 @@ | |
2397 | ||
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]); | |
2402 | } | |
2403 | ||
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 | |
2408 | @@ -34,6 +34,7 @@ | |
2409 | #ifndef _RTCPACKPACKET_H_ | |
2410 | #define _RTCPACKPACKET_H_ | |
2411 | ||
2412 | +#include <byteswap.h> | |
2413 | #include "OSHeaders.h" | |
2414 | #include "RTCPAPPPacket.h" | |
2415 | #include <stdlib.h> | |
2416 | @@ -116,12 +117,12 @@ | |
2417 | ||
2418 | UInt16 RTCPAckPacket::GetAckSeqNum() | |
2419 | { | |
2420 | - return (UInt16) (ntohl(*(UInt32*)&fRTCPAckBuffer[kAckSeqNumOffset])); | |
2421 | + return (UInt16) (bswap_32(*(UInt32*)&fRTCPAckBuffer[kAckSeqNumOffset])); | |
2422 | } | |
2423 | ||
2424 | inline UInt16 RTCPAckPacket::GetPacketLength() | |
2425 | { | |
2426 | - return (UInt16) ( ntohl(*(UInt32*)fRTCPAckBuffer) & kPacketLengthMask); | |
2427 | + return (UInt16) ( bswap_32(*(UInt32*)fRTCPAckBuffer) & kPacketLengthMask); | |
2428 | } | |
2429 | ||
2430 | ||
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 | |
2434 | @@ -31,6 +31,7 @@ | |
2435 | */ | |
2436 | ||
2437 | ||
2438 | +#include <byteswap.h> | |
2439 | #include "RTCPAPPNADUPacket.h" | |
2440 | #include "MyAssert.h" | |
2441 | #include "OS.h" | |
2442 | @@ -131,46 +132,46 @@ | |
2443 | UInt32 *theWriterStart = (UInt32*)sRTCPTestBuffer; | |
2444 | UInt32 *theWriter = (UInt32*)sRTCPTestBuffer; | |
2445 | ||
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) | |
2454 | - | |
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) | |
2469 | + | |
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 | |
2476 | ||
2477 | ||
2478 | ||
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 | |
2481 | ||
2482 | UInt32 *appPacketLenStart = theWriter; | |
2483 | ||
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 | |
2488 | ||
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 | |
2496 | ||
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 | |
2504 | ||
2505 | UInt16 *packetLenOffsetPtr = &( (UInt16*)theWriterStart)[29]; | |
2506 | - UInt16 packetLenInWords = htons( ((UInt32*)theWriter - (UInt32*)appPacketLenStart) ) ; | |
2507 | + UInt16 packetLenInWords = bswap_16( ((UInt32*)theWriter - (UInt32*)appPacketLenStart) ) ; | |
2508 | ||
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; | |
2513 | if (resultPtr) | |
2514 | resultPtr->Set(sRTCPTestBuffer, len); | |
2515 | @@ -181,36 +182,36 @@ | |
2516 | UInt32 *theWriterStart = (UInt32*)sRTCPTestBuffer; | |
2517 | UInt32 *theWriter = (UInt32*)sRTCPTestBuffer; | |
2518 | ||
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) | |
2535 | ||
2536 | ||
2537 | ||
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 | |
2540 | ||
2541 | UInt32 *appPacketLenStart = theWriter; | |
2542 | ||
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 | |
2547 | ||
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 | |
2555 | ||
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 | |
2563 | ||
2564 | UInt16 *packetLenOffsetPtr = &( (UInt16*)theWriterStart)[17]; | |
2565 | - UInt16 packetLenInWords = htons( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ; | |
2566 | + UInt16 packetLenInWords = bswap_16( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ; | |
2567 | ||
2568 | *packetLenOffsetPtr = packetLenInWords; | |
2569 | ||
2570 | @@ -224,27 +225,27 @@ | |
2571 | UInt32 *theWriterStart = (UInt32*)sRTCPTestBuffer; | |
2572 | UInt32 *theWriter = (UInt32*)sRTCPTestBuffer; | |
2573 | ||
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 | |
2576 | ||
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 | |
2579 | ||
2580 | UInt32 *appPacketLenStart = theWriter; | |
2581 | ||
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 | |
2586 | ||
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 | |
2594 | ||
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 | |
2602 | ||
2603 | UInt16 *packetLenOffsetPtr = &( (UInt16*)theWriterStart)[3]; | |
2604 | - UInt16 packetLenInWords = htons( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ; | |
2605 | + UInt16 packetLenInWords = bswap_16( (UInt32*)theWriter - (UInt32*)appPacketLenStart) ; | |
2606 | ||
2607 | *packetLenOffsetPtr = packetLenInWords; | |
2608 | ||
2609 | @@ -375,7 +376,7 @@ | |
2610 | for (; count < fNumBlocks ; count ++) | |
2611 | { | |
2612 | blockBuffer = fNaduDataBuffer + (count * 3); | |
2613 | - ssrc = (UInt32) ntohl(*(UInt32*)&blockBuffer[kOffsetNaduSSRC]); | |
2614 | + ssrc = (UInt32) bswap_32(*(UInt32*)&blockBuffer[kOffsetNaduSSRC]); | |
2615 | ||
2616 | if (ssrc == inSSRC) | |
2617 | return count; | |
2618 | @@ -398,7 +399,7 @@ | |
2619 | return 0; | |
2620 | ||
2621 | UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3); | |
2622 | - UInt32 ssrc = (UInt32) ntohl(*(UInt32*)&blockBufferPtr[kOffsetNaduSSRC]); | |
2623 | + UInt32 ssrc = (UInt32) bswap_32(*(UInt32*)&blockBufferPtr[kOffsetNaduSSRC]); | |
2624 | ||
2625 | return ssrc; | |
2626 | ||
2627 | @@ -416,7 +417,7 @@ | |
2628 | return 0; | |
2629 | ||
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); | |
2633 | ||
2634 | return delay; | |
2635 | } | |
2636 | @@ -433,7 +434,7 @@ | |
2637 | return 0; | |
2638 | ||
2639 | UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3); | |
2640 | - UInt16 nsn = (UInt16) ( ntohl(blockBufferPtr[kOffsetNSN]) & kNSNMask ); | |
2641 | + UInt16 nsn = (UInt16) ( bswap_32(blockBufferPtr[kOffsetNSN]) & kNSNMask ); | |
2642 | ||
2643 | return nsn; | |
2644 | } | |
2645 | @@ -450,7 +451,7 @@ | |
2646 | return 0; | |
2647 | ||
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); | |
2651 | ||
2652 | return nun; | |
2653 | } | |
2654 | @@ -467,7 +468,7 @@ | |
2655 | return 0; | |
2656 | ||
2657 | UInt32 *blockBufferPtr = fNaduDataBuffer + (index * 3); | |
2658 | - UInt16 fbs = (UInt16) ntohl(blockBufferPtr[kOffsetFBS]) & kFBSMask; | |
2659 | + UInt16 fbs = (UInt16) bswap_32(blockBufferPtr[kOffsetFBS]) & kFBSMask; | |
2660 | ||
2661 | return fbs; | |
2662 | } | |
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 | |
2666 | @@ -31,6 +31,7 @@ | |
2667 | */ | |
2668 | ||
2669 | ||
2670 | +#include <byteswap.h> | |
2671 | #include "RTCPAPPPacket.h" | |
2672 | #include "MyAssert.h" | |
2673 | #include "OS.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 | |
2677 | @@ -34,6 +34,7 @@ | |
2678 | #ifndef _RTCPAPPPACKET_H_ | |
2679 | #define _RTCPAPPPACKET_H_ | |
2680 | ||
2681 | +#include <byteswap.h> | |
2682 | #include "RTCPPacket.h" | |
2683 | #include "StrPtrLen.h" | |
2684 | #include "ResizeableStringFormatter.h" | |
2685 | @@ -93,13 +94,13 @@ | |
2686 | outName[0] = 0; | |
2687 | } | |
2688 | ||
2689 | - return ntohl(packetName); | |
2690 | + return bswap_32(packetName); | |
2691 | } | |
2692 | ||
2693 | ||
2694 | inline UInt32 RTCPAPPPacket::GetAppPacketSSRC() | |
2695 | { | |
2696 | - return (UInt32) ntohl(*(UInt32*)&(GetPacketBuffer()[kAppSSRCOffset]) ) ; | |
2697 | + return (UInt32) bswap_32(*(UInt32*)&(GetPacketBuffer()[kAppSSRCOffset]) ) ; | |
2698 | } | |
2699 | ||
2700 | ||
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 | |
2704 | @@ -31,6 +31,7 @@ | |
2705 | */ | |
2706 | ||
2707 | ||
2708 | +#include <byteswap.h> | |
2709 | #include "RTCPAPPQTSSPacket.h" | |
2710 | #include "MyAssert.h" | |
2711 | #include "OS.h" | |
2712 | @@ -120,7 +121,7 @@ | |
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); | |
2721 | @@ -144,7 +145,7 @@ | |
2722 | { | |
2723 | case TW0_CHARS_TO_INT( 'r', 'r' ): //'rr': //'rrcv': | |
2724 | { | |
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); | |
2729 | } | |
2730 | @@ -152,7 +153,7 @@ | |
2731 | ||
2732 | case TW0_CHARS_TO_INT('l', 't'): //'lt': //'late': | |
2733 | { | |
2734 | - fAverageLateMilliseconds = ntohs(*(UInt16*)qtssDataBuffer); | |
2735 | + fAverageLateMilliseconds = bswap_16(*(UInt16*)qtssDataBuffer); | |
2736 | qtssDataBuffer += sizeof(fAverageLateMilliseconds); | |
2737 | APPEND_TO_DUMP_ARRAY(", avg_late=%u", fAverageLateMilliseconds); | |
2738 | } | |
2739 | @@ -160,7 +161,7 @@ | |
2740 | ||
2741 | case TW0_CHARS_TO_INT('l', 's'): // 'ls': //'loss': | |
2742 | { | |
2743 | - fPercentPacketsLost = ntohs(*(UInt16*)qtssDataBuffer); | |
2744 | + fPercentPacketsLost = bswap_16(*(UInt16*)qtssDataBuffer); | |
2745 | qtssDataBuffer += sizeof(fPercentPacketsLost); | |
2746 | APPEND_TO_DUMP_ARRAY(", percent_loss=%u", fPercentPacketsLost); | |
2747 | } | |
2748 | @@ -168,7 +169,7 @@ | |
2749 | ||
2750 | case TW0_CHARS_TO_INT('d', 'l'): //'dl': //'bdly': | |
2751 | { | |
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); | |
2756 | } | |
2757 | @@ -196,19 +197,19 @@ | |
2758 | ||
2759 | case TW0_CHARS_TO_INT('e', 'y' ): //'ey': //'eyes': | |
2760 | { | |
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); | |
2765 | ||
2766 | if (itemLengthInBytes >= 2) | |
2767 | { | |
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); | |
2772 | } | |
2773 | if (itemLengthInBytes >= 3) | |
2774 | { | |
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); | |
2779 | } | |
2780 | @@ -217,7 +218,7 @@ | |
2781 | ||
2782 | case TW0_CHARS_TO_INT('p', 'r' ): // 'pr': //'prcv': | |
2783 | { | |
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); | |
2788 | } | |
2789 | @@ -225,7 +226,7 @@ | |
2790 | ||
2791 | case TW0_CHARS_TO_INT('p', 'd'): //'pd': //'pdrp': | |
2792 | { | |
2793 | - fTotalPacketsDropped = ntohs(*(UInt16*)qtssDataBuffer); | |
2794 | + fTotalPacketsDropped = bswap_16(*(UInt16*)qtssDataBuffer); | |
2795 | qtssDataBuffer += sizeof(fTotalPacketsDropped); | |
2796 | APPEND_TO_DUMP_ARRAY(", pckts_drppd=%u", fTotalPacketsDropped); | |
2797 | } | |
2798 | @@ -233,7 +234,7 @@ | |
2799 | ||
2800 | case TW0_CHARS_TO_INT('p', 'l'): //'pl': //'p???': | |
2801 | { | |
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); | |
2806 | } | |
2807 | @@ -242,7 +243,7 @@ | |
2808 | ||
2809 | case TW0_CHARS_TO_INT('b', 'l'): //'bl': //'bufl': | |
2810 | { | |
2811 | - fClientBufferFill = ntohs(*(UInt16*)qtssDataBuffer); | |
2812 | + fClientBufferFill = bswap_16(*(UInt16*)qtssDataBuffer); | |
2813 | qtssDataBuffer += sizeof(fClientBufferFill); | |
2814 | APPEND_TO_DUMP_ARRAY(", buffr_fill=%u", fClientBufferFill); | |
2815 | } | |
2816 | @@ -251,7 +252,7 @@ | |
2817 | ||
2818 | case TW0_CHARS_TO_INT('f', 'r'): //'fr': //'frat': | |
2819 | { | |
2820 | - fFrameRate = ntohs(*(UInt16*)qtssDataBuffer); | |
2821 | + fFrameRate = bswap_16(*(UInt16*)qtssDataBuffer); | |
2822 | qtssDataBuffer += sizeof(fFrameRate); | |
2823 | APPEND_TO_DUMP_ARRAY(", frame_rate=%u", fFrameRate); | |
2824 | } | |
2825 | @@ -260,7 +261,7 @@ | |
2826 | ||
2827 | case TW0_CHARS_TO_INT('x', 'r'): //'xr': //'xrat': | |
2828 | { | |
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); | |
2833 | } | |
2834 | @@ -269,7 +270,7 @@ | |
2835 | ||
2836 | case TW0_CHARS_TO_INT('d', '#'): //'d#': //'dry#': | |
2837 | { | |
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); | |
2842 | } | |
2843 | @@ -277,7 +278,7 @@ | |
2844 | ||
2845 | case TW0_CHARS_TO_INT('o', 'b'): //'ob': // overbuffer window size | |
2846 | { | |
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); | |
2851 | } | |
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 | |
2855 | @@ -34,6 +34,7 @@ | |
2856 | #ifndef _RTCPAPPQTSSPACKET_H_ | |
2857 | #define _RTCPAPPQTSSPACKET_H_ | |
2858 | ||
2859 | +#include <byteswap.h> | |
2860 | #include "RTCPAPPPacket.h" | |
2861 | #include "StrPtrLen.h" | |
2862 | ||
2863 | @@ -143,21 +144,21 @@ | |
2864 | ||
2865 | inline UInt32 RTCPCompressedQTSSPacket::GetQTSSReportSourceID() | |
2866 | { | |
2867 | - return (UInt32) ntohl( ((UInt32*)this->GetPacketBuffer())[kQTSSReportSourceIDOffset] ) ; | |
2868 | + return (UInt32) bswap_32( ((UInt32*)this->GetPacketBuffer())[kQTSSReportSourceIDOffset] ) ; | |
2869 | } | |
2870 | ||
2871 | ||
2872 | inline UInt16 RTCPCompressedQTSSPacket::GetQTSSPacketVersion() | |
2873 | { | |
2874 | UInt32 field = ((UInt32*)this->GetPacketBuffer())[kQTSSPacketVersionOffset]; | |
2875 | - UInt16 vers = (UInt16) ( ( ntohl(field) & kQTSSPacketVersionMask) >> kQTSSPacketVersionShift ); | |
2876 | + UInt16 vers = (UInt16) ( ( bswap_32(field) & kQTSSPacketVersionMask) >> kQTSSPacketVersionShift ); | |
2877 | return vers; | |
2878 | } | |
2879 | ||
2880 | inline UInt16 RTCPCompressedQTSSPacket::GetQTSSPacketLength() | |
2881 | { | |
2882 | UInt32 field = ((UInt32*)this->GetPacketBuffer())[kQTSSPacketLengthOffset]; | |
2883 | - return (UInt16) ( (UInt32) ntohl(field) & kQTSSPacketLengthMask ); | |
2884 | + return (UInt16) ( (UInt32) bswap_32(field) & kQTSSPacketLengthMask ); | |
2885 | } | |
2886 | ||
2887 | /* | |
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 | |
2891 | @@ -31,6 +31,7 @@ | |
2892 | #ifndef _RTCPNADUPACKETFMT_H_ | |
2893 | #define _RTCPNADUPACKETFMT_H_ | |
2894 | ||
2895 | +#include <byteswap.h> | |
2896 | #include "StrPtrLen.h" | |
2897 | #include "arpa/inet.h" | |
2898 | #include "OSHeaders.h" | |
2899 | @@ -89,9 +90,9 @@ | |
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); | |
2909 | } | |
2910 | ||
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)); | |
2914 | ||
2915 | fNumNADUBlocks++; | |
2916 | - reinterpret_cast<NADUHeader *>(fBuf.Ptr)->length = htons(GetPacketLen() / 4 - 1); | |
2917 | + reinterpret_cast<NADUHeader *>(fBuf.Ptr)->length = bswap_16(GetPacketLen() / 4 - 1); | |
2918 | ||
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); | |
2925 | ||
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)); | |
2930 | ||
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)); | |
2935 | } | |
2936 | ||
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); } | |
2939 | ||
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 | |
2945 | @@ -30,6 +30,7 @@ | |
2946 | */ | |
2947 | ||
2948 | ||
2949 | +#include <byteswap.h> | |
2950 | #include "RTCPPacket.h" | |
2951 | #include "RTCPAckPacket.h" | |
2952 | #include "OS.h" | |
2953 | @@ -44,7 +45,7 @@ | |
2954 | return false; | |
2955 | ||
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)); | |
2959 | ||
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 | |
2965 | @@ -36,6 +36,7 @@ | |
2966 | #ifndef _RTCPPACKET_H_ | |
2967 | #define _RTCPPACKET_H_ | |
2968 | ||
2969 | +#include <byteswap.h> | |
2970 | #include <stdlib.h> | |
2971 | #include "SafeStdLib.h" | |
2972 | #ifndef __Win32__ | |
2973 | @@ -185,14 +186,14 @@ | |
2974 | SInt64 GetNTPTimeStamp() | |
2975 | { | |
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); | |
2982 | } | |
2983 | UInt32 GetRTPTimeStamp() | |
2984 | { | |
2985 | UInt32* fieldPtr = (UInt32*)&fReceiverPacketBuffer[kSRPacketRTPTimeStamp]; | |
2986 | - return ntohl(*fieldPtr); | |
2987 | + return bswap_32(*fieldPtr); | |
2988 | } | |
2989 | protected: | |
2990 | enum | |
2991 | @@ -209,46 +210,46 @@ | |
2992 | inline int RTCPPacket::GetVersion() | |
2993 | { | |
2994 | UInt32* theVersionPtr = (UInt32*)&fReceiverPacketBuffer[kVersionOffset]; | |
2995 | - UInt32 theVersion = ntohl(*theVersionPtr); | |
2996 | + UInt32 theVersion = bswap_32(*theVersionPtr); | |
2997 | return (int) ((theVersion & kVersionMask) >> kVersionShift); | |
2998 | } | |
2999 | ||
3000 | inline Bool16 RTCPPacket::GetHasPadding() | |
3001 | { | |
3002 | UInt32* theHasPaddingPtr = (UInt32*)&fReceiverPacketBuffer[kHasPaddingOffset]; | |
3003 | - UInt32 theHasPadding = ntohl(*theHasPaddingPtr); | |
3004 | + UInt32 theHasPadding = bswap_32(*theHasPaddingPtr); | |
3005 | return (Bool16) (theHasPadding & kHasPaddingMask); | |
3006 | } | |
3007 | ||
3008 | inline int RTCPPacket::GetReportCount() | |
3009 | { | |
3010 | UInt32* theReportCountPtr = (UInt32*)&fReceiverPacketBuffer[kReportCountOffset]; | |
3011 | - UInt32 theReportCount = ntohl(*theReportCountPtr); | |
3012 | + UInt32 theReportCount = bswap_32(*theReportCountPtr); | |
3013 | return (int) ((theReportCount & kReportCountMask) >> kReportCountShift); | |
3014 | } | |
3015 | ||
3016 | inline UInt8 RTCPPacket::GetPacketType() | |
3017 | { | |
3018 | UInt32* thePacketTypePtr = (UInt32*)&fReceiverPacketBuffer[kPacketTypeOffset]; | |
3019 | - UInt32 thePacketType = ntohl(*thePacketTypePtr); | |
3020 | + UInt32 thePacketType = bswap_32(*thePacketTypePtr); | |
3021 | return (UInt8) ((thePacketType & kPacketTypeMask) >> kPacketTypeShift); | |
3022 | } | |
3023 | ||
3024 | inline UInt16 RTCPPacket::GetPacketLength() | |
3025 | { | |
3026 | UInt32* fieldPtr = (UInt32*)&fReceiverPacketBuffer[kPacketLengthOffset]; | |
3027 | - UInt32 field = ntohl(*fieldPtr); | |
3028 | + UInt32 field = bswap_32(*fieldPtr); | |
3029 | return (UInt16) (field & kPacketLengthMask); | |
3030 | } | |
3031 | ||
3032 | inline UInt32 RTCPPacket::GetPacketSSRC() | |
3033 | { | |
3034 | UInt32* fieldPtr = (UInt32*)&fReceiverPacketBuffer[kPacketSourceIDOffset]; | |
3035 | - UInt32 field = ntohl(*fieldPtr); | |
3036 | + UInt32 field = bswap_32(*fieldPtr); | |
3037 | return field; | |
3038 | } | |
3039 | ||
3040 | -inline SInt16 RTCPPacket::GetHeader(){ return (SInt16) ntohs(*(SInt16*)&fReceiverPacketBuffer[0]) ;} | |
3041 | +inline SInt16 RTCPPacket::GetHeader(){ return (SInt16) bswap_16(*(SInt16*)&fReceiverPacketBuffer[0]) ;} | |
3042 | ||
3043 | /************** RTCPReceiverPacket inlines **************/ | |
3044 | inline int RTCPReceiverPacket::RecordOffset(int inReportNum) | |
3045 | @@ -259,41 +260,41 @@ | |
3046 | ||
3047 | inline UInt32 RTCPReceiverPacket::GetReportSourceID(int inReportNum) | |
3048 | { | |
3049 | - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kReportSourceIDOffset]) ; | |
3050 | + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kReportSourceIDOffset]) ; | |
3051 | } | |
3052 | ||
3053 | inline UInt8 RTCPReceiverPacket::GetFractionLostPackets(int inReportNum) | |
3054 | { | |
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 ); | |
3057 | } | |
3058 | ||
3059 | ||
3060 | inline UInt32 RTCPReceiverPacket::GetTotalLostPackets(int inReportNum) | |
3061 | { | |
3062 | - return (ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kTotalLostPacketsOffset]) & kTotalLostPacketsMask ); | |
3063 | + return (bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kTotalLostPacketsOffset]) & kTotalLostPacketsMask ); | |
3064 | } | |
3065 | ||
3066 | ||
3067 | inline UInt32 RTCPReceiverPacket::GetHighestSeqNumReceived(int inReportNum) | |
3068 | { | |
3069 | - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kHighestSeqNumReceivedOffset]) ; | |
3070 | + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kHighestSeqNumReceivedOffset]) ; | |
3071 | } | |
3072 | ||
3073 | inline UInt32 RTCPReceiverPacket::GetJitter(int inReportNum) | |
3074 | { | |
3075 | - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kJitterOffset]) ; | |
3076 | + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kJitterOffset]) ; | |
3077 | } | |
3078 | ||
3079 | ||
3080 | inline UInt32 RTCPReceiverPacket::GetLastSenderReportTime(int inReportNum) | |
3081 | { | |
3082 | - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportOffset]) ; | |
3083 | + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportOffset]) ; | |
3084 | } | |
3085 | ||
3086 | ||
3087 | inline UInt32 RTCPReceiverPacket::GetLastSenderReportDelay(int inReportNum) | |
3088 | { | |
3089 | - return (UInt32) ntohl(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportDelayOffset]) ; | |
3090 | + return (UInt32) bswap_32(*(UInt32*)&fRTCPReceiverReportArray[this->RecordOffset(inReportNum)+kLastSenderReportDelayOffset]) ; | |
3091 | } | |
3092 | ||
3093 | ||
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 | |
3097 | @@ -31,6 +31,7 @@ | |
3098 | #ifndef _RTCPRRPACKET_H_ | |
3099 | #define _RTCPRRPACKET_H_ | |
3100 | ||
3101 | +#include <byteswap.h> | |
3102 | #include "StrPtrLen.h" | |
3103 | #include "arpa/inet.h" | |
3104 | #include "OSHeaders.h" | |
3105 | @@ -92,11 +93,11 @@ | |
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); | |
3113 | } | |
3114 | ||
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); } | |
3117 | ||
3118 | ||
3119 | void SetCount(UInt16 count) | |
3120 | @@ -105,10 +106,10 @@ | |
3121 | { return; | |
3122 | } | |
3123 | ||
3124 | - UInt16 newVal = ntohs(*reinterpret_cast<UInt16 *>(fBuf.Ptr)); | |
3125 | + UInt16 newVal = bswap_16(*reinterpret_cast<UInt16 *>(fBuf.Ptr)); | |
3126 | count <<= 8; | |
3127 | newVal |= count; | |
3128 | - *reinterpret_cast<UInt16 *>(fBuf.Ptr) = htons(newVal); | |
3129 | + *reinterpret_cast<UInt16 *>(fBuf.Ptr) = bswap_16(newVal); | |
3130 | ||
3131 | } | |
3132 | ||
3133 | @@ -122,22 +123,22 @@ | |
3134 | RTCPReportBlock &reportBlock = *reinterpret_cast<RTCPReportBlock *>(fBuf.Ptr + GetPacketLen()); | |
3135 | ::memset(&reportBlock, 0, sizeof(RTCPReportBlock)); | |
3136 | ||
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); | |
3146 | ||
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); | |
3154 | else | |
3155 | - reportBlock.lost = htonl(cumLostPackets); | |
3156 | + reportBlock.lost = bswap_32(cumLostPackets); | |
3157 | ||
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); | |
3161 | } | |
3162 | ||
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 | |
3167 | @@ -33,6 +33,7 @@ | |
3168 | ||
3169 | */ | |
3170 | ||
3171 | +#include <byteswap.h> | |
3172 | #include <string.h> | |
3173 | ||
3174 | #include "RTCPSRPacket.h" | |
3175 | @@ -47,11 +48,11 @@ | |
3176 | ||
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. | |
3182 | ||
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; | |
3188 | ||
3189 | @@ -72,16 +73,16 @@ | |
3190 | // | |
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; | |
3204 | ||
3205 | UInt32* theByeWriter = (UInt32*)&fSenderReportBuffer[fSenderReportWithServerInfoSize]; | |
3206 | - *theByeWriter = htonl(0x81cb0001); | |
3207 | + *theByeWriter = bswap_32(0x81cb0001); | |
3208 | } | |
3209 | ||
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 | |
3214 | @@ -35,6 +35,7 @@ | |
3215 | #ifndef __RTCP_SR_PACKET__ | |
3216 | #define __RTCP_SR_PACKET__ | |
3217 | ||
3218 | +#include <byteswap.h> | |
3219 | #include "OSHeaders.h" | |
3220 | #include "OS.h" | |
3221 | #include "MyAssert.h" | |
3222 | @@ -109,25 +110,25 @@ | |
3223 | inline void RTCPSRPacket::SetSSRC(UInt32 inSSRC) | |
3224 | { | |
3225 | // Set SSRC in SR | |
3226 | - ((UInt32*)&fSenderReportBuffer)[1] = htonl(inSSRC); | |
3227 | + ((UInt32*)&fSenderReportBuffer)[1] = bswap_32(inSSRC); | |
3228 | ||
3229 | // Set SSRC in SDES | |
3230 | - ((UInt32*)&fSenderReportBuffer)[8] = htonl(inSSRC); | |
3231 | + ((UInt32*)&fSenderReportBuffer)[8] = bswap_32(inSSRC); | |
3232 | ||
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); | |
3237 | ||
3238 | // Set SSRC in BYE | |
3239 | Assert((fSenderReportWithServerInfoSize & 3) == 0); | |
3240 | - ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) + 1] = htonl(inSSRC); | |
3241 | + ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) + 1] = bswap_32(inSSRC); | |
3242 | } | |
3243 | ||
3244 | inline void RTCPSRPacket::SetClientSSRC(UInt32 inClientSSRC) | |
3245 | { | |
3246 | // | |
3247 | // Set Client SSRC in SERVER INFO | |
3248 | - ((UInt32*)&fSenderReportBuffer)[(fSenderReportSize >> 2) + 3] = htonl(inClientSSRC); | |
3249 | + ((UInt32*)&fSenderReportBuffer)[(fSenderReportSize >> 2) + 3] = bswap_32(inClientSSRC); | |
3250 | } | |
3251 | ||
3252 | inline void RTCPSRPacket::SetNTPTimestamp(SInt64 inNTPTimestamp) | |
3253 | @@ -142,22 +143,22 @@ | |
3254 | ||
3255 | inline void RTCPSRPacket::SetRTPTimestamp(UInt32 inRTPTimestamp) | |
3256 | { | |
3257 | - ((UInt32*)&fSenderReportBuffer)[4] = htonl(inRTPTimestamp); | |
3258 | + ((UInt32*)&fSenderReportBuffer)[4] = bswap_32(inRTPTimestamp); | |
3259 | } | |
3260 | ||
3261 | inline void RTCPSRPacket::SetPacketCount(UInt32 inPacketCount) | |
3262 | { | |
3263 | - ((UInt32*)&fSenderReportBuffer)[5] = htonl(inPacketCount); | |
3264 | + ((UInt32*)&fSenderReportBuffer)[5] = bswap_32(inPacketCount); | |
3265 | } | |
3266 | ||
3267 | inline void RTCPSRPacket::SetByteCount(UInt32 inByteCount) | |
3268 | { | |
3269 | - ((UInt32*)&fSenderReportBuffer)[6] = htonl(inByteCount); | |
3270 | + ((UInt32*)&fSenderReportBuffer)[6] = bswap_32(inByteCount); | |
3271 | } | |
3272 | ||
3273 | inline void RTCPSRPacket::SetAckTimeout(UInt32 inAckTimeoutInMsec) | |
3274 | { | |
3275 | - ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) - 1] = htonl(inAckTimeoutInMsec); | |
3276 | + ((UInt32*)&fSenderReportBuffer)[(fSenderReportWithServerInfoSize >> 2) - 1] = bswap_32(inAckTimeoutInMsec); | |
3277 | } | |
3278 | ||
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 | |
3283 | @@ -27,6 +27,7 @@ | |
3284 | // Some defs for RTP-Meta-Info payloads. | |
3285 | ||
3286 | ||
3287 | +#include <byteswap.h> | |
3288 | #include "RTPMetaInfoPacket.h" | |
3289 | #include "MyAssert.h" | |
3290 | #include "StringParser.h" | |
3291 | @@ -93,8 +94,8 @@ | |
3292 | // | |
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)); | |
3299 | ||
3300 | // | |
3301 | // Get the Field ID if there is one. | |
3302 | @@ -153,10 +154,10 @@ | |
3303 | break; | |
3304 | ||
3305 | ::memcpy(&uInt16Val, theFieldP, sizeof(uInt16Val)); | |
3306 | - theFieldIndex = this->GetFieldIndexForName(ntohs(uInt16Val)); | |
3307 | + theFieldIndex = this->GetFieldIndexForName(bswap_16(uInt16Val)); | |
3308 | ||
3309 | ::memcpy(&uInt16Val, theFieldP + 2, sizeof(uInt16Val)); | |
3310 | - theFieldLen = ntohs(uInt16Val); | |
3311 | + theFieldLen = bswap_16(uInt16Val); | |
3312 | theFieldP += 4; | |
3313 | } | |
3314 | ||
3315 | @@ -188,7 +189,7 @@ | |
3316 | } | |
3317 | case kFrameTypeField: | |
3318 | { | |
3319 | - fFrameType = ntohs(*((FrameTypeField*)theFieldP)); | |
3320 | + fFrameType = bswap_16(*((FrameTypeField*)theFieldP)); | |
3321 | break; | |
3322 | } | |
3323 | case kPacketNumField: | |
3324 | @@ -201,7 +202,7 @@ | |
3325 | { | |
3326 | ||
3327 | ::memcpy(&uInt16Val, theFieldP, sizeof(uInt16Val)); | |
3328 | - fSeqNum = ntohs(uInt16Val); | |
3329 | + fSeqNum = bswap_16(uInt16Val); | |
3330 | break; | |
3331 | } | |
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 | |
3336 | @@ -31,6 +31,7 @@ | |
3337 | ||
3338 | */ | |
3339 | ||
3340 | +#include <byteswap.h> | |
3341 | #include <arpa/inet.h> | |
3342 | //#include <stdlib.h> | |
3343 | #include "ClientSession.h" | |
3344 | @@ -985,11 +986,11 @@ | |
3345 | ||
3346 | // RECEIVER REPORT | |
3347 | /* | |
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) | |
3363 | { | |
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; | |
3390 | //else | |
3391 | // temp = 0; | |
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 | |
3416 | } | |
3417 | ||
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 | |
3422 | @@ -30,6 +30,7 @@ | |
3423 | #ifndef _RTPPACKET_H_ | |
3424 | #define _RTPPACKET_H_ | |
3425 | ||
3426 | +#include <byteswap.h> | |
3427 | #include "arpa/inet.h" | |
3428 | #include "OSHeaders.h" | |
3429 | #include "StrPtrLen.h" | |
3430 | @@ -74,19 +75,19 @@ | |
3431 | : fPacket(reinterpret_cast<RTPHeader *>(inPacket)), fLen(inLen) | |
3432 | {} | |
3433 | ||
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; } | |
3438 | ||
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); } | |
3445 | ||
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); } | |
3450 | ||
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); } | |
3455 | ||
3456 | //Includes the variable CSRC portion | |
3457 | UInt32 GetHeaderLen() const { return sizeof(RTPHeader) + GetCSRCCount() * 4; } | |
3458 | @@ -99,7 +100,7 @@ | |
3459 | Assert(sizeof(RTPHeader) == 12); | |
3460 | if (fLen < sizeof(RTPHeader)) | |
3461 | return false; | |
3462 | - if ( ( ntohs(fPacket->rtpheader) >> 14) != RTP_VERSION ) | |
3463 | + if ( ( bswap_16(fPacket->rtpheader) >> 14) != RTP_VERSION ) | |
3464 | return false; | |
3465 | if (GetHeaderLen() > fLen) | |
3466 | return false; | |
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 | |
3470 | @@ -31,6 +31,7 @@ | |
3471 | */ | |
3472 | ||
3473 | #ifndef __Win32__ | |
3474 | +#include <byteswap.h> | |
3475 | #include <sys/types.h> | |
3476 | #include <sys/socket.h> | |
3477 | #include <netinet/in.h> | |
3478 | @@ -1261,7 +1262,7 @@ | |
3479 | header[0] = '$'; | |
3480 | header[1] = (UInt8)x; | |
3481 | UInt16* theLenP = (UInt16*)header; | |
3482 | - theLenP[1] = htons(inLen); | |
3483 | + theLenP[1] = bswap_16(inLen); | |
3484 | ||
3485 | // | |
3486 | // Build the iovec | |
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); | |
3495 | ||
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]); | |
3502 | ||
3503 | Assert(fPacketBuffer[0] == '$'); | |
3504 | ||
3505 | @@ -1442,7 +1443,7 @@ | |
3506 | { | |
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)) | |
3513 | { | |
3514 | @@ -1929,7 +1930,7 @@ | |
3515 | Socket::Initialize(); | |
3516 | SocketUtils::Initialize(); | |
3517 | ||
3518 | - UInt32 ipAddr = (UInt32)ntohl(::inet_addr("17.221.41.111")); | |
3519 | + UInt32 ipAddr = (UInt32)bswap_32(::inet_addr("17.221.41.111")); | |
3520 | UInt16 port = 554; | |
3521 | StrPtrLen theURL("rtsp://17.221.41.111/mystery.mov"); | |
3522 | ||
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 | |
3526 | @@ -216,7 +216,7 @@ | |
3527 | //(void) ::signal(SIGPIPE, SIG_IGN); | |
3528 | struct sigaction act; | |
3529 | ||
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); | |
3533 | act.sa_flags = 0; | |
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 | |
3538 | @@ -30,6 +30,7 @@ | |
3539 | ||
3540 | */ | |
3541 | ||
3542 | +#include <byteswap.h> | |
3543 | #include <stdio.h> | |
3544 | ||
3545 | #include "RTPPacketResender.h" | |
3546 | @@ -315,7 +316,7 @@ | |
3547 | // we compute a re-transmit timeout based on the Karns RTT esmitate | |
3548 | ||
3549 | UInt16* theSeqNumP = (UInt16*)inRTPPacket; | |
3550 | - UInt16 theSeqNum = ntohs(theSeqNumP[1]); | |
3551 | + UInt16 theSeqNum = bswap_16(theSeqNumP[1]); | |
3552 | ||
3553 | if ( ageLimit > 0 ) | |
3554 | { | |
3555 | @@ -348,7 +349,7 @@ | |
3556 | else | |
3557 | { | |
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 ); | |
3561 | #endif | |
3562 | fNumExpired++; | |
3563 | } | |
3564 | @@ -425,7 +426,7 @@ | |
3565 | { | |
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() ); | |
3571 | #endif | |
3572 | } | |
3573 | @@ -508,8 +509,8 @@ | |
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() ); | |
3581 | #endif | |
3582 | // | |
3583 | // This packet is expired | |
3584 | @@ -527,8 +528,8 @@ | |
3585 | ||
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()); | |
3593 | #endif | |
3594 | ||
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 | |
3598 | @@ -33,6 +33,7 @@ | |
3599 | ||
3600 | ||
3601 | ||
3602 | +#include <byteswap.h> | |
3603 | #include <stdlib.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); | |
3612 | ||
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); | |
3619 | ||
3620 | if (sin.sin_port != 0) | |
3621 | { | |
3622 | @@ -782,7 +783,7 @@ | |
3623 | { if (result < 0) | |
3624 | qtss_printf("RTCP Monitor Socket sendto failed\n"); | |
3625 | else if (0) | |
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); | |
3628 | } | |
3629 | } | |
3630 | ||
3631 | @@ -1211,7 +1212,7 @@ | |
3632 | this->PrintPacketPrefEnabled( (char*) thePacket->packetData, inLen, (SInt32) RTPStream::rtp); | |
3633 | ||
3634 | UInt16* theSeqNumP = (UInt16*)thePacket->packetData; | |
3635 | - UInt16 theSeqNum = ntohs(theSeqNumP[1]); | |
3636 | + UInt16 theSeqNum = bswap_16(theSeqNumP[1]); | |
3637 | ||
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); | |
3643 | else | |
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); | |
3646 | #endif | |
3647 | //if (err != QTSS_NoErr) | |
3648 | // qtss_printf("flow controlled\n"); | |
3649 | @@ -1283,7 +1284,7 @@ | |
3650 | ||
3651 | // Record the RTP timestamp for RTCPs | |
3652 | UInt32* timeStampP = (UInt32*)(thePacket->packetData); | |
3653 | - fLastRTPTimestamp = ntohl(timeStampP[1]); | |
3654 | + fLastRTPTimestamp = bswap_32(timeStampP[1]); | |
3655 | ||
3656 | //stream statistics | |
3657 | fPacketCount++; | |
3658 | @@ -1786,9 +1787,9 @@ | |
3659 | void RTPStream::PrintRTP(char* packetBuff, UInt32 inLen) | |
3660 | { | |
3661 | ||
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]); | |
3668 | ||
3669 | ||
3670 | ||
3671 | @@ -1819,7 +1820,7 @@ | |
3672 | UInt32* theReport = (UInt32*)packetBuff; | |
3673 | ||
3674 | theReport++; | |
3675 | - UInt32 ssrc = htonl(*theReport); | |
3676 | + UInt32 ssrc = bswap_32(*theReport); | |
3677 | ||
3678 | theReport++; | |
3679 | SInt64 ntp = 0; | |
3680 | @@ -1828,7 +1829,7 @@ | |
3681 | time_t theTime = OS::Time1900Fixed64Secs_To_UnixTimeSecs(ntp); | |
3682 | ||
3683 | theReport += 2; | |
3684 | - UInt32 timestamp = ntohl(*theReport); | |
3685 | + UInt32 timestamp = bswap_32(*theReport); | |
3686 | Float32 theTimeInSecs = 0.0; | |
3687 | ||
3688 | if (fFirstTimeStamp == 0) | |
3689 | @@ -1838,10 +1839,10 @@ | |
3690 | theTimeInSecs = (Float32) (timestamp - fFirstTimeStamp) / (Float32) fTimescale; | |
3691 | ||
3692 | theReport++; | |
3693 | - UInt32 packetcount = ntohl(*theReport); | |
3694 | + UInt32 packetcount = bswap_32(*theReport); | |
3695 | ||
3696 | theReport++; | |
3697 | - UInt32 bytecount = ntohl(*theReport); | |
3698 | + UInt32 bytecount = bswap_32(*theReport); | |
3699 | ||
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 | |
3705 | @@ -35,6 +35,7 @@ | |
3706 | ||
3707 | //INCLUDES: | |
3708 | #ifndef __Win32__ | |
3709 | +#include <byteswap.h> | |
3710 | #include <sys/types.h> | |
3711 | #include <sys/uio.h> | |
3712 | #endif | |
3713 | @@ -443,7 +444,7 @@ | |
3714 | ||
3715 | UInt32 ssrcVal = 0; | |
3716 | ::sscanf(theCString, "%"_U32BITARG_"", &ssrcVal); | |
3717 | - ssrcVal = htonl(ssrcVal); | |
3718 | + ssrcVal = bswap_32(ssrcVal); | |
3719 | ||
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 | |
3725 | @@ -32,6 +32,7 @@ | |
3726 | */ | |
3727 | ||
3728 | ||
3729 | +#include <byteswap.h> | |
3730 | #include "RTSPRequestStream.h" | |
3731 | #include "StringParser.h" | |
3732 | #include "OSMemory.h" | |
3733 | @@ -163,7 +164,7 @@ | |
3734 | if (fRequest.Len < 4) | |
3735 | continue; | |
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) | |
3740 | continue; | |
3741 | ||
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 | |
3745 | @@ -34,6 +34,7 @@ | |
3746 | #define __RTSP_AUTH_DEBUG__ 0 | |
3747 | #define debug_printf if (__RTSP_AUTH_DEBUG__) qtss_printf | |
3748 | ||
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, | |
3755 | &ncValue, | |
3756 | &bufSize); | |
3757 | - ncValue = ntohl(ncValue); | |
3758 | + ncValue = bswap_32(ncValue); | |
3759 | ||
3760 | } | |
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 | |
3765 | @@ -31,6 +31,7 @@ | |
3766 | ||
3767 | */ | |
3768 | ||
3769 | +#include <byteswap.h> | |
3770 | #include "atomic.h" | |
3771 | ||
3772 | #include "RTSPSessionInterface.h" | |
3773 | @@ -332,7 +333,7 @@ | |
3774 | // write direct to stream | |
3775 | rih.header = '$'; | |
3776 | rih.channel = channel; | |
3777 | - rih.len = htons( (UInt16)inLen); | |
3778 | + rih.len = bswap_16( (UInt16)inLen); | |
3779 | ||
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++; | |
3785 | ||
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. | |
3790 | ||
3791 | - SInt16 pcketLen = htons( (UInt16) inLen); | |
3792 | + SInt16 pcketLen = bswap_16( (UInt16) inLen); | |
3793 | ::memcpy( &fTCPCoalesceBuffer[fNumInCoalesceBuffer], &pcketLen, 2 ); | |
3794 | fNumInCoalesceBuffer += 2; | |
3795 | ||
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 | |
3799 | @@ -61,6 +61,7 @@ | |
3800 | ||
3801 | clean: | |
3802 | rm -f $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) | |
3803 | + rm -f StreamingLoadTool | |
3804 | ||
3805 | .SUFFIXES: .cpp .c .o | |
3806 | ||
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 | |
3810 | @@ -28,6 +28,7 @@ | |
3811 | Contains: Tool that simulates streaming movie load | |
3812 | */ | |
3813 | ||
3814 | +#include <byteswap.h> | |
3815 | #include <stdio.h> | |
3816 | #include <stdlib.h> | |
3817 | #include <sys/types.h> | |
3818 | @@ -135,7 +136,7 @@ | |
3819 | #ifndef __Win32__ | |
3820 | struct sigaction act; | |
3821 | ||
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); | |
3825 | act.sa_flags = 0; | |
3826 | act.sa_handler = (void(*)(int))&sigcatcher; | |
3827 | @@ -913,7 +914,7 @@ | |
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]); | |
3833 | ||
3834 | SocketUtils::ConvertAddrToString(theAddr, &theAddrBufPtr); | |
3835 | ||
3836 | @@ -1015,7 +1016,7 @@ | |
3837 | struct hostent* theHostent = ::gethostbyname(theDNSName); | |
3838 | ||
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])); | |
3842 | else | |
3843 | ioIPAddrs[x] = SocketUtils::ConvertStringToAddr(theDNSName); | |
3844 | ||
3845 | @@ -1117,7 +1118,7 @@ | |
3846 | { | |
3847 | UInt32 theReason = inSession->GetReasonForDying(); | |
3848 | in_addr theAddr; | |
3849 | - theAddr.s_addr = htonl(inSession->GetSocket()->GetHostAddr()); | |
3850 | + theAddr.s_addr = bswap_32(inSession->GetSocket()->GetHostAddr()); | |
3851 | char* theAddrStr = ::inet_ntoa(theAddr); | |
3852 | ||
3853 | // | |
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 | |
3857 | @@ -15,6 +15,7 @@ | |
3858 | ||
3859 | CCFLAGS += -I. | |
3860 | CCFLAGS += -I.. | |
3861 | +CCFLAGS += -I../CommonUtilitiesLib | |
3862 | ||
3863 | C++FLAGS = $(CCFLAGS) | |
3864 | ||
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 | |
3868 | @@ -29,6 +29,7 @@ | |
3869 | * | |
3870 | */ | |
3871 | ||
3872 | +#include <byteswap.h> | |
3873 | #include <stdio.h> | |
3874 | #include <stdlib.h> | |
3875 | #include <string.h> | |
3876 | @@ -56,6 +57,7 @@ | |
3877 | #include "./proxy_plat.h" | |
3878 | #include "util.h" | |
3879 | #include "proxy.h" | |
3880 | +#include "OSHeaders.h" | |
3881 | ||
3882 | #include <unistd.h> | |
3883 | ||
3884 | @@ -862,7 +864,7 @@ | |
3885 | } | |
3886 | *cmd = '\0'; | |
3887 | if (gVerbose) | |
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); | |
3890 | ||
3891 | if (strn_casecmp(p, " rtsp://", 8) != 0) | |
3892 | return 0; | |
3893 | @@ -877,7 +879,7 @@ | |
3894 | } | |
3895 | *server = '\0'; | |
3896 | if (gVerbose) | |
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); | |
3899 | ||
3900 | return 1; | |
3901 | } | |
3902 | @@ -1821,7 +1823,7 @@ | |
3903 | temp[num] = '\0'; | |
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)); | |
3908 | if (gVerbose) | |
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); | |
3913 | ||
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); | |
3917 | else | |
3918 | { | |
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); | |
3922 | } | |
3923 | ||
3924 | - add_rtsp_port_listener( (int) ntohl(bindaddr.s_addr),port); | |
3925 | + add_rtsp_port_listener( (int) bswap_32(bindaddr.s_addr),port); | |
3926 | } | |
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 | |
3932 | @@ -29,6 +29,7 @@ | |
3933 | */ | |
3934 | ||
3935 | ||
3936 | +#include <byteswap.h> | |
3937 | #include <stdlib.h> | |
3938 | #include <stdio.h> | |
3939 | #include <string.h> | |
3940 | @@ -113,7 +114,7 @@ | |
3941 | *pb->result = -1; | |
3942 | pthread_exit(NULL); | |
3943 | } while(0); | |
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); | |
3946 | *pb->result = id; | |
3947 | free(pb); | |
3948 | pthread_exit(NULL); | |
3949 | @@ -155,7 +156,7 @@ | |
3950 | ||
3951 | tryAgain ++; | |
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 ); | |
3956 | return 0; | |
3957 | } | |
3958 | @@ -168,7 +169,7 @@ | |
3959 | add_to_IP_cache(name, -1); | |
3960 | return -1; | |
3961 | } | |
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); | |
3965 | return 0; | |
3966 | } | |
3967 | @@ -188,8 +189,8 @@ | |
3968 | if (status >= 0) | |
3969 | { | |
3970 | if (port) | |
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); | |
3975 | } | |
3976 | return -1; | |
3977 | } | |
3978 | @@ -207,8 +208,8 @@ | |
3979 | if (status >= 0) | |
3980 | { | |
3981 | if (port) | |
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); | |
3986 | } | |
3987 | return -1; | |
3988 | } | |
3989 | @@ -243,7 +244,7 @@ | |
3990 | } | |
3991 | return -1; | |
3992 | } | |
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; | |
3996 | } | |
3997 | ||
3998 | @@ -397,8 +398,8 @@ | |
3999 | ||
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)); | |
4007 | } | |
4008 | ||
4009 | @@ -454,8 +455,8 @@ | |
4010 | ||
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)); | |
4018 | } | |
4019 | ||
4020 | @@ -467,7 +468,7 @@ | |
4021 | memset(&localAddr, 0, sizeof(localAddr)); | |
4022 | ||
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); | |
4026 | } | |
4027 | ||
4028 | /**********************************************/ | |
4029 | @@ -482,9 +483,9 @@ | |
4030 | ret = recvfrom(socket, buf, (size_t) amt, 0, (struct sockaddr*)&sin, &len); | |
4031 | if (ret != -1) { | |
4032 | if (fromip) | |
4033 | - *fromip = ntohl(sin.sin_addr.s_addr); | |
4034 | + *fromip = bswap_32(sin.sin_addr.s_addr); | |
4035 | if (fromport) | |
4036 | - *fromport = ntohs(sin.sin_port); | |
4037 | + *fromport = bswap_16(sin.sin_port); | |
4038 | } | |
4039 | return ret; | |
4040 | } | |
4041 | @@ -496,8 +497,8 @@ | |
4042 | ||
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)); | |
4050 | } | |
4051 |