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
// rtmp.h +127
type C_RTMPSockBuf struct {
conn *net.IPConn
conn *net.TCPConn
timeout int32
sb_size int
sb_start int

View File

@ -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 {
@ -74,7 +77,7 @@ func C_RTMP_Connect(r *C_RTMP, cp *C_RTMPPacket) (ok bool) {
// 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)