func (b *Buffer) available(size int) bool {
	available := b.head - b.tail
	if available <= 0 {
		available += len(b.data)
	}
	if size+2+1 > available {
		return false
	}
	return true
}
available returns true if the buffer is large enough to fit a packet
of the given size, taking overhead into account.
package packetio
import (
	"errors"
	"io"
	"sync"
	"time"
	"github.com/pion/transport/deadline"
)
var errPacketTooBig = errors.New("packet too big")
type BufferPacketType int
const (
	RTPBufferPacket BufferPacketType = 1
	RTCPBufferPacket BufferPacketType = 2
)
type Buffer struct {
	mutex sync.Mutex
	data       []byte
	head, tail int
	notify chan struct{}
	subs   bool
	closed bool
	count                 int
	limitCount, limitSize int
	readDeadline *deadline.Deadline
}
const (
	minSize    = 2048
	cutoffSize = 128 * 1024
	maxSize    = 4 * 1024 * 1024
)
func NewBuffer() *Buffer {
	return &Buffer{
		notify:       make(chan struct{}),
		readDeadline: deadline.New(),
	}
}