func (self *Queue) Close() (err error) {
	self.lock.Lock()
	self.closed = true
	self.cond.Broadcast()
	self.lock.Unlock()
	return
}
After Close() called, all QueueCursor's ReadPacket will return io.EOF.
package pubsub
import (
	"github.com/nareix/joy4/av"
	"github.com/nareix/joy4/av/pktque"
	"io"
	"sync"
	"time"
)
type Queue struct {
	buf                      *pktque.Buf
	head, tail               int
	lock                     *sync.RWMutex
	cond                     *sync.Cond
	curgopcount, maxgopcount int
	streams                  []av.CodecData
	videoidx                 int
	closed                   bool
}
func NewQueue() *Queue {
	q := &Queue{}
	q.buf = pktque.NewBuf()
	q.maxgopcount = 2
	q.lock = &sync.RWMutex{}
	q.cond = sync.NewCond(q.lock.RLocker())
	q.videoidx = -1
	return q
}
func (self *Queue) SetMaxGopCount(n int) {
	self.lock.Lock()
	self.maxgopcount = n
	self.lock.Unlock()
	return
}
func (self *Queue) WriteHeader(streams []av.CodecData) error {
	self.lock.Lock()
	self.streams = streams
	for i, stream := range streams {
		if stream.Type().IsVideo() {
			self.videoidx = i
		}
	}
	self.cond.Broadcast()
	self.lock.Unlock()
	return nil
}
func (self *Queue) WriteTrailer() error {
	return nil
}