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 (
|
const (
|
||||||
pkg = "rtmp:"
|
pkg = "rtmp:"
|
||||||
minDataSize = 11 // ToDo: this should be the same as fullHeaderSize
|
|
||||||
signatureSize = 1536
|
signatureSize = 1536
|
||||||
fullHeaderSize = 12
|
fullHeaderSize = 12
|
||||||
)
|
)
|
||||||
|
@ -159,7 +158,7 @@ var (
|
||||||
errConnStream = errors.New("rtmp: connection stream error")
|
errConnStream = errors.New("rtmp: connection stream error")
|
||||||
errInvalidHeader = errors.New("rtmp: invalid header")
|
errInvalidHeader = errors.New("rtmp: invalid header")
|
||||||
errInvalidBody = errors.New("rtmp: invalid body")
|
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")
|
errEncoding = errors.New("rtmp: encoding error")
|
||||||
errDecoding = errors.New("rtmp: decoding error")
|
errDecoding = errors.New("rtmp: decoding error")
|
||||||
errUnimplemented = errors.New("rtmp: unimplemented feature")
|
errUnimplemented = errors.New("rtmp: unimplemented feature")
|
||||||
|
|
|
@ -106,6 +106,10 @@ const (
|
||||||
FatalLevel int8 = 5
|
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.
|
// NewSession returns a new Session.
|
||||||
func NewSession(url string, timeout uint, log Log) *Session {
|
func NewSession(url string, timeout uint, log Log) *Session {
|
||||||
return &Session{
|
return &Session{
|
||||||
|
@ -174,8 +178,8 @@ func (s *Session) Write(data []byte) (int, error) {
|
||||||
if !s.isConnected() {
|
if !s.isConnected() {
|
||||||
return 0, errNotConnected
|
return 0, errNotConnected
|
||||||
}
|
}
|
||||||
if len(data) < minDataSize {
|
if len(data) < flvTagheaderSize {
|
||||||
return 0, errTinyPacket
|
return 0, errInvalidFlvTag
|
||||||
}
|
}
|
||||||
if data[0] == packetTypeInfo || (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') {
|
if data[0] == packetTypeInfo || (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') {
|
||||||
return 0, errUnimplemented
|
return 0, errUnimplemented
|
||||||
|
@ -190,7 +194,7 @@ func (s *Session) Write(data []byte) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt.resize(pkt.bodySize, headerSizeAuto)
|
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)
|
err := pkt.write(s, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
Loading…
Reference in New Issue