fixed merge conflicts
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
// Give the platform some time to set itself up
|
||||
// Give the platform some time to set itself up
|
||||
time.Sleep(30 * time.Second)
|
||||
config := revid.Config{
|
||||
Input: revid.Raspivid,
|
||||
|
@ -18,13 +18,13 @@ func main() {
|
|||
Bitrate: "500000",
|
||||
Packetization: revid.Flv,
|
||||
}
|
||||
revidInst, err := revid.NewRevidInstance(config)
|
||||
revidInst, err := revid.NewRevid(config)
|
||||
if err != nil {
|
||||
fmt.Println("Should not have got error!")
|
||||
return
|
||||
}
|
||||
// Run this instance for 2 days! Power to the pi will surely turn itself
|
||||
// off before this time is up.
|
||||
// Run this instance for 2 days! Power to the pi will surely turn itself
|
||||
// off before this time is up.
|
||||
revidInst.Start()
|
||||
time.Sleep(2 * 43200 * time.Second)
|
||||
revidInst.Stop()
|
||||
|
|
|
@ -51,15 +51,15 @@ var dummyAudioTag2Data = []byte{0x01, 0xdc, 0x00, 0x4c, 0x61, 0x76, 0x63, 0x35,
|
|||
// flvGenerator provides properties required for the generation of flv video
|
||||
// from raw video data
|
||||
type flvGenerator struct {
|
||||
fps uint
|
||||
inputChan chan []byte
|
||||
outputChan chan []byte
|
||||
audioFlag bool
|
||||
videoFlag bool
|
||||
lastTagSize int
|
||||
header flv.Header
|
||||
startTime time.Time
|
||||
firstTag bool
|
||||
fps uint
|
||||
inputChan chan []byte
|
||||
outputChan chan []byte
|
||||
audioFlag bool
|
||||
videoFlag bool
|
||||
lastTagSize int
|
||||
header flv.Header
|
||||
startTime time.Time
|
||||
firstTag bool
|
||||
}
|
||||
|
||||
// GetInputChan returns the input channel to the generator. This is where the
|
||||
|
@ -215,7 +215,7 @@ func (g *flvGenerator) generate() {
|
|||
// Do we even have some audio to send off ?
|
||||
if g.audioFlag {
|
||||
// Not sure why but we need two audio tags for dummy silent audio
|
||||
// TODO: create constants or SoundSize and SoundType parameters
|
||||
// TODO: create constants or SoundSize and SoundType parameters
|
||||
tag := flv.AudioTag{
|
||||
TagType: uint8(flv.AudioTagType),
|
||||
DataSize: 7,
|
||||
|
|
|
@ -34,6 +34,8 @@ import (
|
|||
"../pes"
|
||||
*/)
|
||||
|
||||
const mpegtsPacketSize = 184
|
||||
|
||||
// TODO: really need to finish the at and pmt stuff - this is too hacky
|
||||
var (
|
||||
patTableStart = []byte{0, 0, 176, 13, 0, 1, 193, 0, 0, 0, 1, 240, 0, 42, 177, 4, 178}
|
||||
|
@ -46,15 +48,15 @@ var (
|
|||
// with 0xFFs - because it looks ugly to hardcode above. This is called through
|
||||
// NewMpegtsgenerator
|
||||
func genPatAndPmt() {
|
||||
patTable = make([]byte, 0, 184)
|
||||
patTable = make([]byte, 0, mpegtsPacketSize)
|
||||
patTable = append(patTable, patTableStart...)
|
||||
for i := 0; i < 167; i++ {
|
||||
pmtTable = append(pmtTable, 255)
|
||||
for i := len(pmtTableStart); i < mpegtsPacketSize - len(pmtTableStart); i++ {
|
||||
pmtTable[i] = 255
|
||||
}
|
||||
pmtTable = make([]byte, 0, 184)
|
||||
pmtTable = make([]byte, 0, mpegtsPacketSize)
|
||||
pmtTable = append(pmtTable, pmtTableStart...)
|
||||
for i := 0; i < 162; i++ {
|
||||
pmtTable = append(pmtTable, 255)
|
||||
for i := len(patTableStart); i < mpegtsPacketSize - len(patTableStart); i++ {
|
||||
pmtTable[i] = 255
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +179,7 @@ func (g *tsGenerator) generate() {
|
|||
}
|
||||
pkt.FillPayload(g.payloadByteChan)
|
||||
|
||||
// TODO: create consts for AFC parameters
|
||||
// TODO: create consts for AFC parameters
|
||||
if pusi {
|
||||
// Create pat table
|
||||
patPkt := mpegts.MpegTsPacket{
|
||||
|
|
|
@ -30,4 +30,4 @@ package itut
|
|||
|
||||
func StartCode1() []byte { return []byte{0x00, 0x00, 0x01} }
|
||||
func StartCode2() []byte { return []byte{0x00, 0x00, 0x00, 0x01} }
|
||||
func AUD() []byte { return []byte{0x09, 0xF0} }
|
||||
func AUD() []byte { return []byte{0x09, 0xF0} }
|
||||
|
|
|
@ -136,25 +136,25 @@ type MpegTsPacket struct {
|
|||
// channel is empty or we've the packet reaches capacity
|
||||
func (p *MpegTsPacket) FillPayload(channel chan byte) {
|
||||
p.Payload = make([]byte, 0, mpegtsPayloadSize)
|
||||
currentPktLength := 6 + int(btb(p.PCRF))*6 + int(btb(p.OPCRF))*6 +
|
||||
int(btb(p.SPF))*1 + int(btb(p.TPDF))*1 + len(p.TPD)
|
||||
currentPktLength := 6 + int(toByte(p.PCRF))*6 + int(toByte(p.OPCRF))*6 +
|
||||
int(toByte(p.SPF))*1 + int(toByte(p.TPDF))*1 + len(p.TPD)
|
||||
// While we're within the mpegts packet size and we still have data we can use
|
||||
for (currentPktLength+len(p.Payload)) < mpegTsSize && len(channel) > 0 {
|
||||
p.Payload = append(p.Payload, <-channel)
|
||||
}
|
||||
}
|
||||
|
||||
// btb is a simple wrapper function for tools.BoolToByte which takes a bool
|
||||
// toByte is a simple wrapper function for tools.BoolToByte which takes a bool
|
||||
// and returns an equivalent byte
|
||||
func btb(b bool) byte {
|
||||
func toByte(b bool) byte {
|
||||
return tools.BoolToByte(b)
|
||||
}
|
||||
|
||||
// ToByteSlice interprets the fields of the ts packet instance and outputs a
|
||||
// corresponding byte slice
|
||||
func (p *MpegTsPacket) ToByteSlice() (output []byte) {
|
||||
stuffingLength := 182 - len(p.Payload) - len(p.TPD) - int(btb(p.PCRF))*6 -
|
||||
int(btb(p.OPCRF))*6 - int(btb(p.SPF))
|
||||
stuffingLength := 182 - len(p.Payload) - len(p.TPD) - int(toByte(p.PCRF))*6 -
|
||||
int(toByte(p.OPCRF))*6 - int(toByte(p.SPF))
|
||||
var stuffing []byte
|
||||
if stuffingLength > 0 {
|
||||
stuffing = make([]byte, stuffingLength)
|
||||
|
@ -162,20 +162,20 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte) {
|
|||
for i := range stuffing {
|
||||
stuffing[i] = 0xFF
|
||||
}
|
||||
afl := 1 + int(btb(p.PCRF))*6 + int(btb(p.OPCRF))*6 + int(btb(p.SPF)) + int(btb(p.TPDF)) + len(p.TPD) + len(stuffing)
|
||||
afl := 1 + int(toByte(p.PCRF))*6 + int(toByte(p.OPCRF))*6 + int(toByte(p.SPF)) + int(toByte(p.TPDF)) + len(p.TPD) + len(stuffing)
|
||||
output = make([]byte, 0, mpegTsSize)
|
||||
output = append(output, []byte{
|
||||
0x47,
|
||||
(btb(p.TEI)<<7 | btb(p.PUSI)<<6 | btb(p.Priority)<<5 | byte((p.PID&0xFF00)>>8)),
|
||||
(toByte(p.TEI)<<7 | toByte(p.PUSI)<<6 | toByte(p.Priority)<<5 | byte((p.PID&0xFF00)>>8)),
|
||||
byte(p.PID & 0x00FF),
|
||||
(p.TSC<<6 | p.AFC<<4 | p.CC),
|
||||
}...)
|
||||
|
||||
if p.AFC == 3 || p.AFC == 2 {
|
||||
output = append(output, []byte{
|
||||
byte(afl), (btb(p.DI)<<7 | btb(p.RAI)<<6 | btb(p.ESPI)<<5 |
|
||||
btb(p.PCRF)<<4 | btb(p.OPCRF)<<3 | btb(p.SPF)<<2 |
|
||||
btb(p.TPDF)<<1 | btb(p.AFEF)),
|
||||
byte(afl), (toByte(p.DI)<<7 | toByte(p.RAI)<<6 | toByte(p.ESPI)<<5 |
|
||||
toByte(p.PCRF)<<4 | toByte(p.OPCRF)<<3 | toByte(p.SPF)<<2 |
|
||||
toByte(p.TPDF)<<1 | toByte(p.AFEF)),
|
||||
}...)
|
||||
for i := 40; p.PCRF && i >= 0; i -= 8 {
|
||||
output = append(output, byte((p.PCR<<15)>>uint(i)))
|
||||
|
|
|
@ -62,7 +62,7 @@ func TestMpegTsToByteSlice(t *testing.T) {
|
|||
expectedOutput = append(expectedOutput, payload...)
|
||||
tsPktAsByteSlice, err := tsPkt.ToByteSlice()
|
||||
if err != nil {
|
||||
t.Errorf("Should not have got error!")
|
||||
t.Errorf("Should not have got error!: %v",err)
|
||||
}
|
||||
for i := 0; i < 188; i++ {
|
||||
if tsPktAsByteSlice[i] != expectedOutput[i] {
|
||||
|
|
|
@ -28,20 +28,20 @@ LICENSE
|
|||
package psi
|
||||
|
||||
type PMT struct {
|
||||
PF byte // POint field
|
||||
PFB []byte // pointer filler bytes
|
||||
TableID byte // Table ID
|
||||
SSI bool // Sectiopn syntax indicator (1 for PAT, PMT, CAT)
|
||||
PB bool // Private bit (0 for PAT, PMT, CAT)
|
||||
SL uint16 // Section length
|
||||
TIE uint16 // Table ID extension
|
||||
Version byte // Version number
|
||||
CNI bool // Current/next indicator
|
||||
Section byte // Section number
|
||||
LSN byte // Last section number
|
||||
|
||||
}
|
||||
|
||||
func (p* PMT)ToByteSlice()(output []byte){
|
||||
PF byte // POint field
|
||||
PFB []byte // pointer filler bytes
|
||||
TableID byte // Table ID
|
||||
SSI bool // Sectiopn syntax indicator (1 for PAT, PMT, CAT)
|
||||
PB bool // Private bit (0 for PAT, PMT, CAT)
|
||||
SL uint16 // Section length
|
||||
TIE uint16 // Table ID extension
|
||||
Version byte // Version number
|
||||
CNI bool // Current/next indicator
|
||||
Section byte // Section number
|
||||
LSN byte // Last section number
|
||||
|
||||
}
|
||||
|
||||
func (p *PMT) ToByteSlice() (output []byte) {
|
||||
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |