working on flv

This commit is contained in:
Saxon Milton 2018-02-10 23:55:55 +10:30
parent 1a083d3059
commit 2bb1d4cfe0
2 changed files with 95 additions and 1 deletions

46
flv/FLV.go Normal file
View File

@ -0,0 +1,46 @@
package flv
import (
"../tools"
)
const (
headerLength = 72
version = 0x01
)
type Header struct {
audioFlag bool
videoFlag bool
}
func (h *Header) toByteSlice() []byte {
output = make([]byte, 0, headerLength)
output = append(output, []byte{ 0x46, 0x4C, 0x56,
version,
0x00 | tools.boolToByte(h.audioFlag) << 3 | tools.boolToByte(h.videoFlag),
0x00, 0x00, 0x00, byte(72),
}...)
return
}
type VideoTag struct {
prevTagSize uint32
tagType uint
dataSize uint32
timeStamp uint32
timestampExtended uint32
data []byte
}
func (t *VideoTag) toByteSlice() (output []byte) {
}
type AudioTag struct {
}
func (t *AudioTage) toByteSlice() (output []byte) {
}

View File

@ -1,3 +1,51 @@
type FLVGenerator struct {
package generator
type flvGenerator struct {
fps uint
inputChan chan []byte
outputChan chan []byte
headerChan []
}
func (g *flvGenerator)GetInputChan() chan []byte {
return g.inputChan
}
func (g *flvGenerator)GetOutputChan() chan []byte {
return g.outputChan
}
func NewFlvGenerator() (g *flvGenerator) {
g = new(flvGenerator)
g.timestamp = 0
return
}
func (g *flvGenerator) Start(){
g.GenHeader()
go g.generate()
}
func (g *flvGenerator) GenHeader(){
header = flv.Header{
}
g.outputChan <- header
}
func (g *flvGenerator) GetNextTimestamp() (timestamp uint32){
timestamp = g.currentTimestamp
g.currentTimeStamp += 100*time.Millisecond() / g.fps
return
}
func (g *flvGenerator) ResetTimestamp() {
g.timestamp = 0
}
func (g *tsGenerator) generate() {
for {
select {
case videoFrame := <-g.inputChan
}
}
}