mirror of https://bitbucket.org/ausocean/av.git
packet.read/write -> readFrom/writeTo.
This commit is contained in:
parent
bef7177c5a
commit
82c010b6f7
|
@ -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
|
||||
}
|
||||
|
|
20
rtmp/rtmp.go
20
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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue