mirror of https://bitbucket.org/ausocean/av.git
minDataSize is out and flvTagheaderSize is in!
This commit is contained in:
parent
d87dfca283
commit
e78cc93432
|
@ -46,7 +46,6 @@ import (
|
|||
|
||||
const (
|
||||
pkg = "rtmp:"
|
||||
minDataSize = 11 // ToDo: this should be the same as fullHeaderSize
|
||||
signatureSize = 1536
|
||||
fullHeaderSize = 12
|
||||
)
|
||||
|
@ -159,7 +158,7 @@ var (
|
|||
errConnStream = errors.New("rtmp: connection stream error")
|
||||
errInvalidHeader = errors.New("rtmp: invalid header")
|
||||
errInvalidBody = errors.New("rtmp: invalid body")
|
||||
errTinyPacket = errors.New("rtmp: packet too small")
|
||||
errInvalidFlvTag = errors.New("rtmp: invalid FLV tag")
|
||||
errEncoding = errors.New("rtmp: encoding error")
|
||||
errDecoding = errors.New("rtmp: decoding error")
|
||||
errUnimplemented = errors.New("rtmp: unimplemented feature")
|
||||
|
|
|
@ -106,6 +106,10 @@ const (
|
|||
FatalLevel int8 = 5
|
||||
)
|
||||
|
||||
// flvTagheaderSize is the FLV header size we expect.
|
||||
// NB: We don't accept extended headers.
|
||||
const flvTagheaderSize = 11
|
||||
|
||||
// NewSession returns a new Session.
|
||||
func NewSession(url string, timeout uint, log Log) *Session {
|
||||
return &Session{
|
||||
|
@ -174,8 +178,8 @@ func (s *Session) Write(data []byte) (int, error) {
|
|||
if !s.isConnected() {
|
||||
return 0, errNotConnected
|
||||
}
|
||||
if len(data) < minDataSize {
|
||||
return 0, errTinyPacket
|
||||
if len(data) < flvTagheaderSize {
|
||||
return 0, errInvalidFlvTag
|
||||
}
|
||||
if data[0] == packetTypeInfo || (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') {
|
||||
return 0, errUnimplemented
|
||||
|
@ -190,7 +194,7 @@ func (s *Session) Write(data []byte) (int, error) {
|
|||
}
|
||||
|
||||
pkt.resize(pkt.bodySize, headerSizeAuto)
|
||||
copy(pkt.body, data[minDataSize:minDataSize+pkt.bodySize])
|
||||
copy(pkt.body, data[flvTagheaderSize:flvTagheaderSize+pkt.bodySize])
|
||||
err := pkt.write(s, false)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
|
Loading…
Reference in New Issue