|
|
@ -104,6 +104,7 @@ type Session struct {
|
|
|
|
|
|
|
|
|
|
|
|
authorizationEnable bool
|
|
|
|
authorizationEnable bool
|
|
|
|
nonce string
|
|
|
|
nonce string
|
|
|
|
|
|
|
|
closeOld bool
|
|
|
|
|
|
|
|
|
|
|
|
AControl string
|
|
|
|
AControl string
|
|
|
|
VControl string
|
|
|
|
VControl string
|
|
|
@ -140,6 +141,7 @@ func NewSession(server *Server, conn net.Conn) *Session {
|
|
|
|
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}
|
|
|
|
authorizationEnable := utils.Conf().Section("rtsp").Key("authorization_enable").MustInt(0)
|
|
|
|
authorizationEnable := utils.Conf().Section("rtsp").Key("authorization_enable").MustInt(0)
|
|
|
|
|
|
|
|
close_old := utils.Conf().Section("rtsp").Key("close_old").MustInt(0)
|
|
|
|
session := &Session{
|
|
|
|
session := &Session{
|
|
|
|
ID: shortid.MustGenerate(),
|
|
|
|
ID: shortid.MustGenerate(),
|
|
|
|
Server: server,
|
|
|
|
Server: server,
|
|
|
@ -154,6 +156,7 @@ func NewSession(server *Server, conn net.Conn) *Session {
|
|
|
|
vRTPControlChannel: -1,
|
|
|
|
vRTPControlChannel: -1,
|
|
|
|
aRTPChannel: -1,
|
|
|
|
aRTPChannel: -1,
|
|
|
|
aRTPControlChannel: -1,
|
|
|
|
aRTPControlChannel: -1,
|
|
|
|
|
|
|
|
closeOld: close_old != 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
session.logger = log.New(os.Stdout, fmt.Sprintf("[%s]", session.ID), log.LstdFlags|log.Lshortfile)
|
|
|
|
session.logger = log.New(os.Stdout, fmt.Sprintf("[%s]", session.ID), log.LstdFlags|log.Lshortfile)
|
|
|
@ -365,13 +368,13 @@ func (session *Session) handleRequest(req *Request) {
|
|
|
|
session.connWLock.Unlock()
|
|
|
|
session.connWLock.Unlock()
|
|
|
|
session.OutBytes += len(outBytes)
|
|
|
|
session.OutBytes += len(outBytes)
|
|
|
|
switch req.Method {
|
|
|
|
switch req.Method {
|
|
|
|
case "PLAY", "RECORD":
|
|
|
|
// case "PLAY", "RECORD":
|
|
|
|
switch session.Type {
|
|
|
|
// switch session.Type {
|
|
|
|
case SESSEION_TYPE_PLAYER:
|
|
|
|
// case SESSEION_TYPE_PLAYER:
|
|
|
|
session.Pusher.AddPlayer(session.Player)
|
|
|
|
// session.Pusher.AddPlayer(session.Player)
|
|
|
|
case SESSION_TYPE_PUSHER:
|
|
|
|
// case SESSION_TYPE_PUSHER:
|
|
|
|
session.Server.AddPusher(session.Pusher)
|
|
|
|
// session.Server.AddPusher(session.Pusher)
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
case "TEARDOWN":
|
|
|
|
case "TEARDOWN":
|
|
|
|
{
|
|
|
|
{
|
|
|
|
session.Stop()
|
|
|
|
session.Stop()
|
|
|
@ -435,12 +438,12 @@ func (session *Session) handleRequest(req *Request) {
|
|
|
|
logger.Printf("video codec[%s]\n", session.VCodec)
|
|
|
|
logger.Printf("video codec[%s]\n", session.VCodec)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
session.Pusher = NewPusher(session)
|
|
|
|
session.Pusher = NewPusher(session)
|
|
|
|
if session.Server.GetPusher(session.Path) == nil {
|
|
|
|
|
|
|
|
session.Server.AddPusher(session.Pusher)
|
|
|
|
addedToServer := session.Server.AddPusher(session.Pusher, session.closeOld)
|
|
|
|
} else {
|
|
|
|
if !addedToServer {
|
|
|
|
|
|
|
|
logger.Printf("reject pusher.")
|
|
|
|
res.StatusCode = 406
|
|
|
|
res.StatusCode = 406
|
|
|
|
res.Status = "Not Acceptable"
|
|
|
|
res.Status = "Not Acceptable"
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "DESCRIBE":
|
|
|
|
case "DESCRIBE":
|
|
|
|
session.Type = SESSEION_TYPE_PLAYER
|
|
|
|
session.Type = SESSEION_TYPE_PLAYER
|
|
|
|