From 82c010b6f7944f2d5bb050c73704bd0eb1a6a0c5 Mon Sep 17 00:00:00 2001 From: scruzin Date: Sun, 13 Jan 2019 13:09:29 +1030 Subject: [PATCH] packet.read/write -> readFrom/writeTo. --- rtmp/packet.go | 5 ++--- rtmp/rtmp.go | 20 ++++++++++---------- rtmp/session.go | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/rtmp/packet.go b/rtmp/packet.go index 8c0fc0f3..2822c7ac 100644 --- a/rtmp/packet.go +++ b/rtmp/packet.go @@ -96,7 +96,7 @@ type packet struct { } // read reads an RTMP packet. -func (pkt *packet) read(s *Session) error { +func (pkt *packet) readFrom(s *Session) error { var hbuf [fullHeaderSize]byte header := hbuf[:] @@ -197,7 +197,6 @@ func (pkt *packet) read(s *Session) error { s.log(DebugLevel, pkg+"failed to read extended timestamp", "error", err.Error()) return err } - // TODO: port this pkt.timestamp = amf.DecodeInt32(header[size : size+4]) hSize += 4 } @@ -272,7 +271,7 @@ func (pkt *packet) resize(size uint32, ht uint8) { // Packets are written in chunks which are Session.chunkSize in length (128 bytes in length). // We defers sending small audio packets and combine consecutive small audio packets where possible to reduce I/O. // When queue is true, we expect a response to this request and cache the method on s.methodCalls. -func (pkt *packet) write(s *Session, queue bool) error { +func (pkt *packet) writeTo(s *Session, queue bool) error { if pkt.body == nil { return errInvalidBody } diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index e10657ef..d0a34e77 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -218,7 +218,7 @@ func connectStream(s *Session) error { var err error for !s.isPlaying { pkt := packet{} - err = pkt.read(s) + err = pkt.readFrom(s) if err != nil { break } @@ -335,7 +335,7 @@ func sendConnectPacket(s *Session) error { pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, true) // response expected + return pkt.writeTo(s, true) // response expected } func sendCreateStream(s *Session) error { @@ -363,7 +363,7 @@ func sendCreateStream(s *Session) error { pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, true) // response expected + return pkt.writeTo(s, true) // response expected } func sendReleaseStream(s *Session) error { @@ -394,7 +394,7 @@ func sendReleaseStream(s *Session) error { } pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, false) + return pkt.writeTo(s, false) } func sendFCPublish(s *Session) error { @@ -426,7 +426,7 @@ func sendFCPublish(s *Session) error { pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, false) + return pkt.writeTo(s, false) } func sendFCUnpublish(s *Session) error { @@ -458,7 +458,7 @@ func sendFCUnpublish(s *Session) error { pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, false) + return pkt.writeTo(s, false) } func sendPublish(s *Session) error { @@ -494,7 +494,7 @@ func sendPublish(s *Session) error { pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, true) // response expected + return pkt.writeTo(s, true) // response expected } func sendDeleteStream(s *Session, dStreamId float64) error { @@ -525,7 +525,7 @@ func sendDeleteStream(s *Session, dStreamId float64) error { } pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, false) + return pkt.writeTo(s, false) } // sendBytesReceived tells the server how many bytes the client has received. @@ -548,7 +548,7 @@ func sendBytesReceived(s *Session) error { } pkt.bodySize = 4 - return pkt.write(s, false) + return pkt.writeTo(s, false) } func sendCheckBW(s *Session) error { @@ -576,7 +576,7 @@ func sendCheckBW(s *Session) error { pkt.bodySize = uint32((len(pbuf) - fullHeaderSize) - len(enc)) - return pkt.write(s, false) + return pkt.writeTo(s, false) } func eraseMethod(m []method, i int) []method { diff --git a/rtmp/session.go b/rtmp/session.go index 610cb484..f555d00e 100644 --- a/rtmp/session.go +++ b/rtmp/session.go @@ -185,7 +185,7 @@ func (s *Session) Write(data []byte) (int, error) { pkt.resize(pkt.bodySize, headerSizeAuto) copy(pkt.body, data[flvTagheaderSize:flvTagheaderSize+pkt.bodySize]) - err := pkt.write(s, false) + err := pkt.writeTo(s, false) if err != nil { return 0, err }