live video streaming server in golang
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

47 lines
819 B

package cache
import (
"bytes"
"github.com/gwuhaolin/livego/av"
"github.com/gwuhaolin/livego/protocol/amf"
log "github.com/sirupsen/logrus"
)
const (
SetDataFrame string = "@setDataFrame"
OnMetaData string = "onMetaData"
)
var setFrameFrame []byte
func init() {
b := bytes.NewBuffer(nil)
encoder := &amf.Encoder{}
if _, err := encoder.Encode(b, SetDataFrame, amf.AMF0); err != nil {
log.Fatal(err)
}
setFrameFrame = b.Bytes()
}
type SpecialCache struct {
full bool
p *av.Packet
}
func NewSpecialCache() *SpecialCache {
return &SpecialCache{}
}
func (specialCache *SpecialCache) Write(p *av.Packet) {
specialCache.p = p
specialCache.full = true
}
func (specialCache *SpecialCache) Send(w av.WriteCloser) error {
if !specialCache.full {
return nil
}
return w.Write(specialCache.p)
}