From 9335e2701d432d5624656aad505c07b034034a72 Mon Sep 17 00:00:00 2001 From: scruzin Date: Sun, 6 Jan 2019 17:17:51 +1030 Subject: [PATCH] Fixed debug mode for C_RTMP_SendPacket(). --- rtmp/rtmp.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 468a7299..f05769fa 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -1431,16 +1431,12 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error { if debugMode { if r.Link.conn != nil { - f, err := r.Link.conn.File() - if err != nil { - log.Printf("could not get file: %v", err) - } else { - log.Printf("C_RTMP_SendPacket: fd=%d, size=%v", f.Fd(), nSize) - } + log.Printf("C_RTMP_SendPacket: %v=>%v, size=%v", r.Link.conn.LocalAddr(), r.Link.conn.RemoteAddr(), nSize) } } // TODO(kortschak): Rewrite this horrific peice of premature optimisation. + // NB: RTMP wants packets in chunks which are 128 bytes by default, but the server may request a different size. for nSize+hSize != 0 { if nChunkSize > nSize { nChunkSize = nSize @@ -1450,10 +1446,9 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error { if err != nil { return err } - n := nChunkSize + hSize // Since C_WriteN doesn't return number of bytes written. nSize -= nChunkSize - origIdx += n + origIdx += nChunkSize + hSize hSize = 0 if nSize > 0 {