[rtmpdump] r227 - trunk/rtmp.c

hyc subversion at mplayerhq.hu
Sat Jan 9 08:09:14 CET 2010


Author: hyc
Date: Sat Jan  9 08:09:13 2010
New Revision: 227

Log:
Tweak SendChunk to use a single WriteN call

Modified:
   trunk/rtmp.c

Modified: trunk/rtmp.c
==============================================================================
--- trunk/rtmp.c	Sat Jan  9 08:00:31 2010	(r226)
+++ trunk/rtmp.c	Sat Jan  9 08:09:13 2010	(r227)
@@ -2177,14 +2177,22 @@ bool
 RTMP_SendChunk(RTMP *r, RTMPChunk *chunk)
 {
   bool wrote;
+  char hbuf[RTMP_MAX_HEADER_SIZE];
 
   Log(LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_socket, chunk->c_chunkSize);
   LogHexString(LOGDEBUG2, chunk->c_header, chunk->c_headerSize);
   if (chunk->c_chunkSize)
-    LogHexString(LOGDEBUG2, chunk->c_chunk, chunk->c_chunkSize);
-  wrote = WriteN(r, chunk->c_header, chunk->c_headerSize);
-  if (wrote && chunk->c_chunkSize)
-    wrote = WriteN(r, chunk->c_chunk, chunk->c_chunkSize);
+    {
+      char *ptr = chunk->c_chunk - chunk->c_headerSize;
+      LogHexString(LOGDEBUG2, chunk->c_chunk, chunk->c_chunkSize);
+      /* save header bytes we're about to overwrite */
+      memcpy(hbuf, ptr, chunk->c_headerSize);
+      memcpy(ptr, chunk->c_header, chunk->c_headerSize);
+      wrote = WriteN(r, ptr, chunk->c_headerSize + chunk->c_chunkSize);
+      memcpy(ptr, hbuf, chunk->c_headerSize);
+    }
+  else
+    wrote = WriteN(r, chunk->c_header, chunk->c_headerSize);
   return wrote;
 }
 


More information about the rtmpdump mailing list