From 8fde0c5747b4582d0110ea70a6ec845e71b96c51 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 1 Jan 2018 17:08:26 +1030 Subject: [PATCH] Fixed invalid header error, but still not playing for some reason --- packets/Rtp.go | 12 ++---------- packets/RtpToTsConverter.go | 11 +---------- revid/revidv2.go | 2 +- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/packets/Rtp.go b/packets/Rtp.go index 8df41007..5f5543db 100644 --- a/packets/Rtp.go +++ b/packets/Rtp.go @@ -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) { diff --git a/packets/RtpToTsConverter.go b/packets/RtpToTsConverter.go index 719ad3ed..7523ffa1 100644 --- a/packets/RtpToTsConverter.go +++ b/packets/RtpToTsConverter.go @@ -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") } } } diff --git a/revid/revidv2.go b/revid/revidv2.go index ff8e7b3c..587adb65 100644 --- a/revid/revidv2.go +++ b/revid/revidv2.go @@ -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])