Fixed invalid header error, but still not playing for some reason

This commit is contained in:
Unknown 2018-01-01 17:08:26 +10:30
parent a6303a9617
commit 8fde0c5747
3 changed files with 4 additions and 21 deletions

View File

@ -33,7 +33,7 @@ package packets
import (
"net"
"fmt"
_"fmt"
)
const (
@ -97,20 +97,13 @@ func toUint(arr []byte) (ret uint) {
func (s *Session) HandleRtpConn(conn net.PacketConn) {
buf := make([]byte, 4096)
for {
fmt.Println("handling rtp conn")
n, _, err := conn.ReadFrom(buf)
fmt.Printf("n: %v\n",n)
fmt.Println("here1")
if err != nil {
panic(err)
}
fmt.Println("here2")
cpy := make([]byte, n)
fmt.Println("here3")
copy(cpy, buf)
fmt.Println("here4")
go s.handleRtp(cpy)
fmt.Println("here5")
}
}
@ -158,9 +151,8 @@ func (s *Session) handleRtp(buf []byte) {
}
}
packet.Payload = buf[i:]
fmt.Println("sending rtp packet")
s.rtpChan <- packet
fmt.Println("Sent")
}
func (s *Session) handleRtcp(buf []byte) {

View File

@ -28,7 +28,7 @@ LICENSE
package packets
import "fmt"
import _"fmt"
type RtpToTsConverter interface {
Convert()
@ -66,23 +66,18 @@ func (c* rtpToTsConverter) Convert() {
select {
default:
case rtpPacket := <-c.inputChan:
fmt.Println("case1")
if GetNalType( rtpPacket.Payload ) == 28 {
nalUnitChan<-ParseNALFragment(rtpPacket.Payload)
} else {
nalUnitChan<-ParseNALSpsPps(rtpPacket.Payload)
}
fmt.Println("done case1")
case nalUnit := <-nalUnitChan:
fmt.Println("case2")
nalUnitByteSlice := nalUnit.ToByteSlice()
fmt.Printf("len(nalUnitByteSlice): %v\n", len(nalUnitByteSlice))
for ii := range nalUnitByteSlice {
pesDataChan<-nalUnitByteSlice[ii]
}
if nalFragment, isNALFragment := nalUnit.(*NALFragment);
(isNALFragment && nalFragment.End) || !isNALFragment {
fmt.Printf("lenPesDataChan: %v\n",len(pesDataChan))
pesDataChanLen := len(pesDataChan)
pesPkt := new(PESPacket)
pesPkt.StreamID = 0xE0
@ -106,13 +101,10 @@ func (c* rtpToTsConverter) Convert() {
}
pesPktChan<-pesPkt.ToByteSlice()
}
fmt.Println("done case2")
case pesPkt := <-pesPktChan:
fmt.Println("case3")
for ii:=range pesPkt {
payloadByteChan<-pesPkt[ii]
}
fmt.Println("done loading")
firstPacket:=true
for len(payloadByteChan) > 0 {
lengthOfByteChan := len(payloadByteChan)
@ -150,7 +142,6 @@ func (c* rtpToTsConverter) Convert() {
}
c.tsChan<-c.currentTsPacket
}
fmt.Println("done case3")
}
}
}

View File

@ -328,9 +328,9 @@ func input(input string, output string) {
ii++
} else {
donePSI = true
fmt.Println("getting TS packet")
packet := <-converter.TsChan
packetByteSlice := packet.ToByteSlice()
fmt.Printf("ts packet: %v\n", packetByteSlice)
copy(clip[clipSize:upperBound],packetByteSlice)
}
//fmt.Println(clip[clipSize:upperBound])