code: func (self *Queue) WritePacket(pkt av.Packet) (err error) {
  	self.lock.Lock()
  
  	self.buf.Push(pkt)
  	if pkt.Idx == int8(self.videoidx) && pkt.IsKeyFrame {
  		self.curgopcount++
  	}
  
  	for self.curgopcount >= self.maxgopcount && self.buf.Count > 1 {
  		pkt := self.buf.Pop()
  		if pkt.Idx == int8(self.videoidx) && pkt.IsKeyFrame {
  			self.curgopcount--
  		}
  		if self.curgopcount < self.maxgopcount {
  			break
  		}
  	}
  	//println("shrink", self.curgopcount, self.maxgopcount, self.buf.Head, self.buf.Tail, "count", self.buf.Count, "size", self.buf.Size)
  
  	self.cond.Broadcast()
  
  	self.lock.Unlock()
  	return
  }
docs: // Put packet into buffer, old packets will be discared.