revid: trying to fix rtmp

This commit is contained in:
saxon 2019-01-02 21:28:20 +10:30
parent 30f3f0558f
commit 0b2c38117f
2 changed files with 10 additions and 5 deletions

View File

@ -139,7 +139,7 @@ type C_RTMPPacket struct {
// typedef struct RTMPSockBuf // typedef struct RTMPSockBuf
// rtmp.h +127 // rtmp.h +127
type C_RTMPSockBuf struct { type C_RTMPSockBuf struct {
conn *net.IPConn conn *net.TCPConn
timeout int32 timeout int32
sb_size int sb_size int
sb_start int sb_start int

View File

@ -53,12 +53,15 @@ func C_RTMP_Connect(r *C_RTMP, cp *C_RTMPPacket) (ok bool) {
} else { } else {
hostname = fmt.Sprintf("%s:%d", r.Link.hostname, r.Link.port) 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 { if err != nil {
fmt.Println(err)
fmt.Println("socket.go:58")
return false 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 { if err != nil {
fmt.Println("socket.go:63")
return false return false
} }
if r.Link.socksport != 0 { 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 r.m_bSendCounter = true
return C_RTMP_Connect1(r, cp) return C_RTMP_Connect1(r, cp)
} }
// int SocksNegotiate(RTMP* r); // int SocksNegotiate(RTMP* r);
// rtmp.c +1062 // 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() ip := addr.IP.To4()
packet := []byte{ packet := []byte{
0x4, // SOCKS version 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))) err := sb.conn.SetReadDeadline(time.Now().Local().Add(time.Second * time.Duration(sb.timeout)))
if err != nil { if err != nil {
fmt.Println("socket.go:111")
return -1 return -1
} }
n, err := sb.conn.Read(sb.sb_buf[sb.sb_start+sb.sb_size:]) 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 { func C_RTMPSockBuf_Send(sb *C_RTMPSockBuf, buf []byte) int32 {
err := sb.conn.SetWriteDeadline(time.Now().Local().Add(time.Second * time.Duration(sb.timeout))) err := sb.conn.SetWriteDeadline(time.Now().Local().Add(time.Second * time.Duration(sb.timeout)))
if err != nil { if err != nil {
fmt.Println("socket.go:128")
return -1 return -1
} }
n, err := sb.conn.Write(buf) n, err := sb.conn.Write(buf)