Skip to content

Commit

Permalink
fix: allow publishing with RTP/AVP
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Jan 15, 2020
1 parent 5d5ac15 commit e78f3f2
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ func (c *client) handleRequest(req *rtsp.Request) bool {
return true

case "SETUP":
transportstr, ok := req.Headers["Transport"]
transportStr, ok := req.Headers["Transport"]
if !ok {
c.writeResError(req, fmt.Errorf("transport header missing"))
return false
}

th := newTransportHeader(transportstr)
th := newTransportHeader(transportStr)

if _, ok := th["unicast"]; !ok {
c.writeResError(req, fmt.Errorf("transport header does not contain unicast"))
Expand All @@ -388,7 +388,7 @@ func (c *client) handleRequest(req *rtsp.Request) bool {
}() {
rtpPort, rtcpPort := th.getClientPorts()
if rtpPort == 0 || rtcpPort == 0 {
c.writeResError(req, fmt.Errorf("transport header does not have valid client ports (%s)", transportstr))
c.writeResError(req, fmt.Errorf("transport header does not have valid client ports (%s)", transportStr))
return false
}

Expand Down Expand Up @@ -502,7 +502,7 @@ func (c *client) handleRequest(req *rtsp.Request) bool {
return true

} else {
c.writeResError(req, fmt.Errorf("transport header does not contain a valid protocol (RTP/AVP or RTP/AVP/TCP) (%s)", transportstr))
c.writeResError(req, fmt.Errorf("transport header does not contain a valid protocol (RTP/AVP, RTP/AVP/UDP or RTP/AVP/TCP) (%s)", transportStr))
return false
}

Expand All @@ -519,10 +519,20 @@ func (c *client) handleRequest(req *rtsp.Request) bool {
}

// record via UDP
if _, ok := th["RTP/AVP/UDP"]; ok {
if func() bool {
_, ok := th["RTP/AVP"]
if ok {
return true
}
_, ok = th["RTP/AVP/UDP"]
if ok {
return true
}
return false
}(); ok {
rtpPort, rtcpPort := th.getClientPorts()
if rtpPort == 0 || rtcpPort == 0 {
c.writeResError(req, fmt.Errorf("transport header does not have valid client ports (%s)", transportstr))
c.writeResError(req, fmt.Errorf("transport header does not have valid client ports (%s)", transportStr))
return false
}

Expand Down Expand Up @@ -623,7 +633,7 @@ func (c *client) handleRequest(req *rtsp.Request) bool {
return true

} else {
c.writeResError(req, fmt.Errorf("transport header does not contain a valid protocol (RTP/AVP or RTP/AVP/TCP) (%s)", transportstr))
c.writeResError(req, fmt.Errorf("transport header does not contain a valid protocol (RTP/AVP, RTP/AVP/UDP or RTP/AVP/TCP) (%s)", transportStr))
return false
}

Expand Down

0 comments on commit e78f3f2

Please sign in to comment.