mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
rewrite extraction of control attribute
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -500,23 +499,10 @@ func (sc *ServerConn) handleRequest(req *base.Request) (*base.Response, error) {
|
||||
|
||||
trackID, err := func() (int, error) {
|
||||
if th.Mode == nil || *th.Mode == headers.TransportModePlay {
|
||||
i := strings.Index(pathAndQuery, "/trackID=")
|
||||
|
||||
// URL doesn't contain trackID - we assume it's track 0
|
||||
if i < 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
tmp, err := strconv.ParseInt(pathAndQuery[i+len("/trackID="):], 10, 64)
|
||||
if err != nil || tmp < 0 {
|
||||
trackID, _, ok := base.PathSplitControlAttribute(pathAndQuery)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("invalid track (%s)", pathAndQuery)
|
||||
}
|
||||
trackID := int(tmp)
|
||||
|
||||
// remove track ID from path
|
||||
nu := req.URL.Clone()
|
||||
nu.SetRTSPPathAndQuery(pathAndQuery[:i])
|
||||
req.URL = nu
|
||||
|
||||
return trackID, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user