Skip to content

Commit

Permalink
fix hk camera setup error
Browse files Browse the repository at this point in the history
  • Loading branch information
macbookpro committed Jan 4, 2019
1 parent a4fcb7a commit cd373b1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions rtsp/rtsp-session.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,22 @@ func (session *Session) handleRequest(req *Request) {

if tcpMatchs := mtcp.FindStringSubmatch(ts); tcpMatchs != nil {
session.TransType = TRANS_TYPE_TCP
if setupPath == aPath || strings.LastIndex(setupPath, aPath) == len(setupPath)-len(aPath) {
if setupPath == aPath || aPath != "" && strings.LastIndex(setupPath, aPath) == len(setupPath)-len(aPath) {
session.aRTPChannel, _ = strconv.Atoi(tcpMatchs[1])
session.aRTPControlChannel, _ = strconv.Atoi(tcpMatchs[3])
} else if setupPath == vPath || strings.LastIndex(setupPath, vPath) == len(setupPath)-len(vPath) {
} else if setupPath == vPath || vPath != "" && strings.LastIndex(setupPath, vPath) == len(setupPath)-len(vPath) {
session.vRTPChannel, _ = strconv.Atoi(tcpMatchs[1])
session.vRTPControlChannel, _ = strconv.Atoi(tcpMatchs[3])
} else {
res.StatusCode = 500
res.Status = fmt.Sprintf("SETUP [TCP] got UnKown control:%s", setupPath)
logger.Printf("SETUP [TCP] got UnKown control:%s", setupPath)
}
logger.Printf("Parse SETUP req.TRANSPORT:TCP.Session.Type:%d,control:%s, AControl:%s,VControl:%s", session.Type, setupPath, aPath, vPath)
} else if udpMatchs := mudp.FindStringSubmatch(ts); udpMatchs != nil {
session.TransType = TRANS_TYPE_UDP
// no need for tcp timeout.
session.Conn.timeout = 0
logger.Printf("Parse SETUP req.TRANSPORT:UDP.Session.Type:%d,control:%s, AControl:%s,VControl:%s", session.Type, setupPath, aPath, vPath)
if session.UDPClient == nil {
session.UDPClient = &UDPClient{
Session: session,
Expand All @@ -453,7 +456,8 @@ func (session *Session) handleRequest(req *Request) {
Session: session,
}
}
if setupPath == aPath || strings.LastIndex(setupPath, aPath) == len(setupPath)-len(aPath) {
logger.Printf("Parse SETUP req.TRANSPORT:UDP.Session.Type:%d,control:%s, AControl:%s,VControl:%s", session.Type, setupPath, aPath, vPath)
if setupPath == aPath || aPath != "" && strings.LastIndex(setupPath, aPath) == len(setupPath)-len(aPath) {
session.UDPClient.APort, _ = strconv.Atoi(udpMatchs[1])
session.UDPClient.AControlPort, _ = strconv.Atoi(udpMatchs[3])
if err := session.UDPClient.SetupAudio(); err != nil {
Expand All @@ -480,7 +484,7 @@ func (session *Session) handleRequest(req *Request) {
tss = append(tss, tail...)
ts = strings.Join(tss, ";")
}
} else if setupPath == vPath || strings.LastIndex(setupPath, vPath) == len(setupPath)-len(vPath) {
} else if setupPath == vPath || vPath != "" && strings.LastIndex(setupPath, vPath) == len(setupPath)-len(vPath) {
session.UDPClient.VPort, _ = strconv.Atoi(udpMatchs[1])
session.UDPClient.VControlPort, _ = strconv.Atoi(udpMatchs[3])
if err := session.UDPClient.SetupVideo(); err != nil {
Expand Down Expand Up @@ -508,7 +512,7 @@ func (session *Session) handleRequest(req *Request) {
ts = strings.Join(tss, ";")
}
} else {
logger.Printf("SETUP got UnKown control:%s", setupPath)
logger.Printf("SETUP [UDP] got UnKown control:%s", setupPath)
}
}
res.Header["Transport"] = ts
Expand Down

0 comments on commit cd373b1

Please sign in to comment.