Skip to content

Commit

Permalink
Fix parsing RTSP Transport header #1235
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Dec 6, 2024
1 parent d8c0f9d commit f1ba5e9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/rtsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,21 @@ func (c *Conn) Accept() error {
}

const transport = "RTP/AVP/TCP;unicast;interleaved="
if strings.HasPrefix(tr, transport) {
if tr = core.Between(tr, "interleaved=", ";"); tr != "" {
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("RTP/AVP/TCP;unicast;interleaved=%d-%d", i*2, i*2+1)
res.Header.Set("Transport", tr)
tr = fmt.Sprintf("%d-%d", i*2, i*2+1)
res.Header.Set("Transport", transport+tr)
} else {
res.Status = "400 Bad Request"
}
} else {
res.Header.Set("Transport", tr[:len(transport)+3])
res.Header.Set("Transport", transport+tr)
}
} else {
res.Status = "461 Unsupported transport"
Expand Down

0 comments on commit f1ba5e9

Please sign in to comment.