mirror of https://github.com/EasyDarwin/EasyDarwin
parent
9cb4462a8b
commit
02ee38a14c
|
@ -11,15 +11,21 @@ type RichConn struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *RichConn) Read(b []byte) (n int, err error) {
|
func (conn *RichConn) Read(b []byte) (n int, err error) {
|
||||||
//if conn.timeout > 0 {
|
if conn.timeout > 0 {
|
||||||
// conn.Conn.SetReadDeadline(time.Now().Add(conn.timeout))
|
conn.Conn.SetReadDeadline(time.Now().Add(conn.timeout))
|
||||||
//}
|
} else {
|
||||||
|
var t time.Time
|
||||||
|
conn.Conn.SetReadDeadline(t)
|
||||||
|
}
|
||||||
return conn.Conn.Read(b)
|
return conn.Conn.Read(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *RichConn) Write(b []byte) (n int, err error) {
|
func (conn *RichConn) Write(b []byte) (n int, err error) {
|
||||||
//if conn.timeout > 0 {
|
if conn.timeout > 0 {
|
||||||
// conn.Conn.SetWriteDeadline(time.Now().Add(conn.timeout))
|
conn.Conn.SetWriteDeadline(time.Now().Add(conn.timeout))
|
||||||
//}
|
} else {
|
||||||
|
var t time.Time
|
||||||
|
conn.Conn.SetWriteDeadline(t)
|
||||||
|
}
|
||||||
return conn.Conn.Write(b)
|
return conn.Conn.Write(b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ const UDP_BUF_SIZE = 1048576
|
||||||
type Session struct {
|
type Session struct {
|
||||||
ID string
|
ID string
|
||||||
Server *Server
|
Server *Server
|
||||||
Conn net.Conn
|
Conn *RichConn
|
||||||
connRW *bufio.ReadWriter
|
connRW *bufio.ReadWriter
|
||||||
connWLock sync.RWMutex
|
connWLock sync.RWMutex
|
||||||
Type SessionType
|
Type SessionType
|
||||||
|
@ -130,13 +130,13 @@ func (session *Session) String() string {
|
||||||
func NewSession(server *Server, conn net.Conn) *Session {
|
func NewSession(server *Server, conn net.Conn) *Session {
|
||||||
networkBuffer := utils.Conf().Section("rtsp").Key("network_buffer").MustInt(1048576)
|
networkBuffer := utils.Conf().Section("rtsp").Key("network_buffer").MustInt(1048576)
|
||||||
timeoutMillis := utils.Conf().Section("rtsp").Key("timeout").MustInt(0)
|
timeoutMillis := utils.Conf().Section("rtsp").Key("timeout").MustInt(0)
|
||||||
timeoutTCPConn := RichConn{conn, time.Duration(timeoutMillis) * time.Millisecond}
|
timeoutTCPConn := &RichConn{conn, time.Duration(timeoutMillis) * time.Millisecond}
|
||||||
|
|
||||||
session := &Session{
|
session := &Session{
|
||||||
ID: shortid.MustGenerate(),
|
ID: shortid.MustGenerate(),
|
||||||
Server: server,
|
Server: server,
|
||||||
Conn: conn,
|
Conn: timeoutTCPConn,
|
||||||
connRW: bufio.NewReadWriter(bufio.NewReaderSize(&timeoutTCPConn, networkBuffer), bufio.NewWriterSize(&timeoutTCPConn, networkBuffer)),
|
connRW: bufio.NewReadWriter(bufio.NewReaderSize(timeoutTCPConn, networkBuffer), bufio.NewWriterSize(timeoutTCPConn, networkBuffer)),
|
||||||
StartAt: time.Now(),
|
StartAt: time.Now(),
|
||||||
Timeout: utils.Conf().Section("rtsp").Key("timeout").MustInt(0),
|
Timeout: utils.Conf().Section("rtsp").Key("timeout").MustInt(0),
|
||||||
|
|
||||||
|
@ -356,6 +356,7 @@ func (session *Session) handleRequest(req *Request) {
|
||||||
session.VControl = pusher.VControl()
|
session.VControl = pusher.VControl()
|
||||||
session.ACodec = pusher.ACodec()
|
session.ACodec = pusher.ACodec()
|
||||||
session.VCodec = pusher.VCodec()
|
session.VCodec = pusher.VCodec()
|
||||||
|
session.Conn.timeout = 0
|
||||||
res.SetBody(session.Pusher.SDPRaw())
|
res.SetBody(session.Pusher.SDPRaw())
|
||||||
case "SETUP":
|
case "SETUP":
|
||||||
ts := req.Header["Transport"]
|
ts := req.Header["Transport"]
|
||||||
|
|
Loading…
Reference in New Issue