From 46be6abf206c6296341d5eaa834cc5d6d9deb704 Mon Sep 17 00:00:00 2001 From: hyc Date: Sat, 9 Jan 2010 07:09:13 +0000 Subject: [PATCH] Tweak SendChunk to use a single WriteN call git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@227 400ebc74-4327-4243-bc38-086b20814532 --- rtmp.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rtmp.c b/rtmp.c index 2dfc717..aafc3cf 100644 --- a/rtmp.c +++ b/rtmp.c @@ -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; } -- 2.40.0