From 0b2c38117ff2d0591af032adc288769bd9b07f46 Mon Sep 17 00:00:00 2001 From: saxon Date: Wed, 2 Jan 2019 21:28:20 +1030 Subject: [PATCH] revid: trying to fix rtmp --- rtmp/rtmp_headers.go | 2 +- rtmp/socket.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/rtmp/rtmp_headers.go b/rtmp/rtmp_headers.go index 90ae39db..eb33814f 100644 --- a/rtmp/rtmp_headers.go +++ b/rtmp/rtmp_headers.go @@ -139,7 +139,7 @@ type C_RTMPPacket struct { // typedef struct RTMPSockBuf // rtmp.h +127 type C_RTMPSockBuf struct { - conn *net.IPConn + conn *net.TCPConn timeout int32 sb_size int sb_start int diff --git a/rtmp/socket.go b/rtmp/socket.go index 627db8b0..35533471 100644 --- a/rtmp/socket.go +++ b/rtmp/socket.go @@ -53,12 +53,15 @@ func C_RTMP_Connect(r *C_RTMP, cp *C_RTMPPacket) (ok bool) { } else { hostname = fmt.Sprintf("%s:%d", r.Link.hostname, r.Link.port) } - addr, err := net.ResolveIPAddr("tcp4", hostname) + addr, err := net.ResolveTCPAddr("tcp4", hostname) if err != nil { + fmt.Println(err) + fmt.Println("socket.go:58") return false } - r.m_sb.conn, err = net.DialIP("tcp4", nil, addr) + r.m_sb.conn, err = net.DialTCP("tcp4", nil, addr) if err != nil { + fmt.Println("socket.go:63") return false } if r.Link.socksport != 0 { @@ -67,14 +70,14 @@ func C_RTMP_Connect(r *C_RTMP, cp *C_RTMPPacket) (ok bool) { } } - r.m_sb.timeout= r.Link.timeout + r.m_sb.timeout = r.Link.timeout r.m_bSendCounter = true return C_RTMP_Connect1(r, cp) } // int SocksNegotiate(RTMP* r); // rtmp.c +1062 -func C_SocksNegotiate(r *C_RTMP, addr *net.IPAddr) (ok bool) { +func C_SocksNegotiate(r *C_RTMP, addr *net.TCPAddr) (ok bool) { ip := addr.IP.To4() packet := []byte{ 0x4, // SOCKS version @@ -106,6 +109,7 @@ func C_RTMPSockBuf_Fill(sb *C_RTMPSockBuf) int { } err := sb.conn.SetReadDeadline(time.Now().Local().Add(time.Second * time.Duration(sb.timeout))) if err != nil { + fmt.Println("socket.go:111") return -1 } n, err := sb.conn.Read(sb.sb_buf[sb.sb_start+sb.sb_size:]) @@ -122,6 +126,7 @@ func C_RTMPSockBuf_Fill(sb *C_RTMPSockBuf) int { func C_RTMPSockBuf_Send(sb *C_RTMPSockBuf, buf []byte) int32 { err := sb.conn.SetWriteDeadline(time.Now().Local().Add(time.Second * time.Duration(sb.timeout))) if err != nil { + fmt.Println("socket.go:128") return -1 } n, err := sb.conn.Write(buf)