mirror of https://bitbucket.org/ausocean/av.git
Just updating remote
This commit is contained in:
parent
2415160b5a
commit
f86cd0a289
|
@ -28,6 +28,8 @@ LICENSE
|
|||
|
||||
package packets
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Length of some fields in bits
|
||||
const (
|
||||
syncByteLength = 8
|
||||
|
@ -89,5 +91,7 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte) {
|
|||
for ii := headerSize; ii < packetLength; ii++ {
|
||||
output[ii] = p.Payload[ii-headerSize]
|
||||
}
|
||||
fmt.Printf("Packet size: %v\n",len(output))
|
||||
//fmt.Printf("Packet: %v\n",output)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -28,10 +28,7 @@ LICENSE
|
|||
|
||||
package packets
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
import "fmt"
|
||||
|
||||
type RtpToTsConverter interface {
|
||||
Convert()
|
||||
|
@ -88,9 +85,15 @@ func (c* rtpToTsConverter) Convert(rtpSession *Session) {
|
|||
c.currentTsPacket.AF = make([]byte,2 + stuffingLength) // adaptationfield flag length = 16
|
||||
c.currentTsPacket.AF[0] = byte(1 + stuffingLength)
|
||||
c.currentTsPacket.AF[1] = 0
|
||||
if c.currentTsPacket.PUSI {
|
||||
c.currentTsPacket.AF[1] = 0x40
|
||||
}
|
||||
|
||||
for ii := 0; ii < stuffingLength; ii++ {
|
||||
c.currentTsPacket.AF[2+ii] = 0xFF
|
||||
}
|
||||
fmt.Printf("AF length: %v\n",c.currentTsPacket.AF[0])
|
||||
fmt.Printf("AF length2: %v\n",len(c.currentTsPacket.AF))
|
||||
c.currentTsPacket.Payload = make([]byte, payloadLength)
|
||||
for ii:=0; ii < payloadLength; ii++ {
|
||||
c.currentTsPacket.Payload[ii] = <-c.payloadByteChan
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main(){
|
||||
data := []byte{ 2,176,18,0,1,193,0,0,225,0,240,0,27,225,0,240,0}
|
||||
|
||||
crc32 := 0xffffffff
|
||||
|
||||
for i := 1 + data[0]; i < len(data); i++ {
|
||||
b := data[i]
|
||||
for bit := 0; bit < 8; bit++ {
|
||||
if (crc32 >= 0x80000000) != (b >= 0x90) {
|
||||
crc32 = (crc32 << 1) ^ 0x04C11DB7
|
||||
} else {
|
||||
crc32 = crc32 << 1
|
||||
b <<= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println(crc32)
|
||||
}
|
|
@ -293,11 +293,17 @@ func input(input string, output string) {
|
|||
prevTime := now
|
||||
fmt.Printf("Looping\n")
|
||||
|
||||
|
||||
startPackets := [][]byte{
|
||||
{71,64,17,16,0,66,240,65,0,1,193,0,0,255,1,255,0,1,252,128,48,72,46,1,6,70,70,109,112,101,103,37,115,116,114,101,97,109,101,100,32,98,121,32,116,104,101,32,71,101,111,86,105,115,105,111,110,32,82,116,115,112,32,83,101,114,118,101,114,99,176,214,195,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
|
||||
{71,64,0,16,0,0,176,13,0,1,193,0,0,0,1,240,0,42,177,4,178,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
|
||||
{71,80,0,16,0,2,176,18,0,1,193,0,0,225,0,240,0,27,225,0,240,0,21,189,77,86,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
|
||||
/*PMT*/{71,80,0,16,
|
||||
/*Start of payload*/
|
||||
0,2,176,18,0,1,193,0,0,255,255,240,0,27,225,0,240,0,193,91,65,224,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
|
||||
}
|
||||
|
||||
donePSI := false
|
||||
|
||||
for {
|
||||
if clip, err := ringBuffer.Get(); err != nil {
|
||||
inputErrChan <- err
|
||||
|
@ -306,11 +312,13 @@ func input(input string, output string) {
|
|||
ii := 0
|
||||
for {
|
||||
upperBound := clipSize + mp2tPacketSize
|
||||
if ii < 3 {
|
||||
|
||||
if ii < 3 && !donePSI {
|
||||
packetByteSlice := startPackets[ii]
|
||||
copy(clip[clipSize:upperBound],packetByteSlice)
|
||||
ii++
|
||||
} else {
|
||||
donePSI = true
|
||||
packet := <-converter.TsChan
|
||||
packetByteSlice := packet.ToByteSlice()
|
||||
copy(clip[clipSize:upperBound],packetByteSlice)
|
||||
|
|
Loading…
Reference in New Issue