rtmp: re-add recvtimeout option setting

This commit is contained in:
Dan Kortschak 2018-10-01 11:25:16 +09:30
parent c91896d919
commit 50884b8034
3 changed files with 27 additions and 0 deletions

View File

@ -37,6 +37,8 @@ import (
"fmt"
"log"
"net"
"golang.org/x/sys/unix"
)
// int RTMP_Connect(RTMP *r, RTMPPacket* cp);
@ -66,6 +68,17 @@ func C_RTMP_Connect(r *C_RTMP, cp *C_RTMPPacket) (ok bool) {
}
}
f, err := r.m_sb.conn.File()
if err != nil {
log.Printf("failed to get fd to set timeout: %v", err)
return false
}
tv := setTimeval(int(r.Link.timeout))
err = unix.SetsockoptTimeval(int(f.Fd()), unix.SOL_SOCKET, unix.SO_RCVTIMEO, &tv)
if err != nil {
log.Printf("failed to set timeout: %v", err)
}
r.m_bSendCounter = true
return C_RTMP_Connect1(r, cp)

7
rtmp/timeval_amd64.go Normal file
View File

@ -0,0 +1,7 @@
package rtmp
import "golang.org/x/sys/unix"
func setTimeval(sec int) unix.Timeval {
return unix.Timeval{Sec: int64(sec)}
}

7
rtmp/timeval_arm.go Normal file
View File

@ -0,0 +1,7 @@
package rtmp
import "golang.org/x/sys/unix"
func setTimeval(sec int) unix.Timeval {
return unix.Timeval{Sec: int32(sec)}
}