mirror of https://bitbucket.org/ausocean/av.git
Added RTMP_PACKET_SIZE_AUTO.
This commit is contained in:
parent
6e034fd264
commit
3c83ba0022
|
@ -60,6 +60,7 @@ const (
|
|||
RTMP_PACKET_SIZE_MEDIUM = 1
|
||||
RTMP_PACKET_SIZE_SMALL = 2
|
||||
RTMP_PACKET_SIZE_MINIMUM = 3
|
||||
RTMP_PACKET_SIZE_AUTO = 4
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -260,9 +261,25 @@ func readPacket(s *Session, pkt *packet) error {
|
|||
// resizePacket adjusts the packet's storage to accommodate a body of the given size.
|
||||
func resizePacket(pkt *packet, size uint32, ht uint8) {
|
||||
buf := make([]byte, RTMP_MAX_HEADER_SIZE+size)
|
||||
pkt.headerType = ht
|
||||
pkt.header = buf
|
||||
pkt.body = buf[RTMP_MAX_HEADER_SIZE:]
|
||||
if ht != RTMP_PACKET_SIZE_AUTO {
|
||||
pkt.headerType = ht
|
||||
return
|
||||
}
|
||||
switch pkt.packetType {
|
||||
case RTMP_PACKET_TYPE_VIDEO, RTMP_PACKET_TYPE_AUDIO:
|
||||
if pkt.timestamp == 0 {
|
||||
pkt.headerType = RTMP_PACKET_SIZE_LARGE
|
||||
} else {
|
||||
pkt.headerType = RTMP_PACKET_SIZE_MEDIUM
|
||||
}
|
||||
case RTMP_PACKET_TYPE_INFO:
|
||||
pkt.headerType = RTMP_PACKET_SIZE_LARGE
|
||||
pkt.bodySize += 16
|
||||
default:
|
||||
pkt.headerType = RTMP_PACKET_SIZE_MEDIUM
|
||||
}
|
||||
}
|
||||
|
||||
// sendPacket sends a packet.
|
||||
|
|
|
@ -91,7 +91,7 @@ const (
|
|||
RTMP_BUFFER_CACHE_SIZE = (16 * 1024)
|
||||
RTMP_SIG_SIZE = 1536
|
||||
RTMP_LARGE_HEADER_SIZE = 12
|
||||
RTMP_MAX_HEADER_SIZE = 18
|
||||
RTMP_MAX_HEADER_SIZE = RTMP_LARGE_HEADER_SIZE
|
||||
)
|
||||
|
||||
type link struct {
|
||||
|
|
Loading…
Reference in New Issue