Skip to content

Commit

Permalink
Merge pull request #1511 from fmcloudconsulting/fix/rtsp-server-inter…
Browse files Browse the repository at this point in the history
…leaved

Accept rtsp client without interleaved parameter
  • Loading branch information
AlexxIT authored Feb 18, 2025
2 parents b3f83fd + 637e65e commit 19cf781
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/rtsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,28 @@ func (c *Conn) Accept() error {
}

case MethodSetup:
tr := req.Header.Get("Transport")

res := &tcp.Response{
Header: map[string][]string{},
Request: req,
}

const transport = "RTP/AVP/TCP;unicast;interleaved="
if tr = core.Between(tr, "interleaved=", ";"); tr != "" {
// Test if client requests TCP transport, otherwise return 461 Transport not supported
// This allows smart clients who initially requested UDP to fall back on TCP transport
if tr := req.Header.Get("Transport"); strings.HasPrefix(tr, "RTP/AVP/TCP") {
c.session = core.RandString(8, 10)
c.state = StateSetup

if c.mode == core.ModePassiveConsumer {
if i := reqTrackID(req); i >= 0 && i < len(c.Senders) {
// mark sender as SETUP
c.Senders[i].Media.ID = MethodSetup
tr = fmt.Sprintf("%d-%d", i*2, i*2+1)
res.Header.Set("Transport", transport+tr)
tr = fmt.Sprintf("RTP/AVP/TCP;unicast;interleaved=%d-%d", i*2, i*2+1)
res.Header.Set("Transport", tr)
} else {
res.Status = "400 Bad Request"
}
} else {
res.Header.Set("Transport", transport+tr)
res.Header.Set("Transport", tr)
}
} else {
res.Status = "461 Unsupported transport"
Expand Down

0 comments on commit 19cf781

Please sign in to comment.